@fuzdev/fuz_app 0.1.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 (457) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/dist/actions/action_bridge.d.ts +65 -0
  4. package/dist/actions/action_bridge.d.ts.map +1 -0
  5. package/dist/actions/action_bridge.js +76 -0
  6. package/dist/actions/action_codegen.d.ts +97 -0
  7. package/dist/actions/action_codegen.d.ts.map +1 -0
  8. package/dist/actions/action_codegen.js +280 -0
  9. package/dist/actions/action_registry.d.ts +35 -0
  10. package/dist/actions/action_registry.d.ts.map +1 -0
  11. package/dist/actions/action_registry.js +83 -0
  12. package/dist/actions/action_spec.d.ts +169 -0
  13. package/dist/actions/action_spec.d.ts.map +1 -0
  14. package/dist/actions/action_spec.js +76 -0
  15. package/dist/auth/account_queries.d.ts +96 -0
  16. package/dist/auth/account_queries.d.ts.map +1 -0
  17. package/dist/auth/account_queries.js +172 -0
  18. package/dist/auth/account_routes.d.ts +86 -0
  19. package/dist/auth/account_routes.d.ts.map +1 -0
  20. package/dist/auth/account_routes.js +406 -0
  21. package/dist/auth/account_schema.d.ts +192 -0
  22. package/dist/auth/account_schema.d.ts.map +1 -0
  23. package/dist/auth/account_schema.js +105 -0
  24. package/dist/auth/admin_routes.d.ts +29 -0
  25. package/dist/auth/admin_routes.d.ts.map +1 -0
  26. package/dist/auth/admin_routes.js +193 -0
  27. package/dist/auth/api_token.d.ts +33 -0
  28. package/dist/auth/api_token.d.ts.map +1 -0
  29. package/dist/auth/api_token.js +36 -0
  30. package/dist/auth/api_token_queries.d.ts +80 -0
  31. package/dist/auth/api_token_queries.d.ts.map +1 -0
  32. package/dist/auth/api_token_queries.js +116 -0
  33. package/dist/auth/app_settings_queries.d.ts +33 -0
  34. package/dist/auth/app_settings_queries.d.ts.map +1 -0
  35. package/dist/auth/app_settings_queries.js +51 -0
  36. package/dist/auth/app_settings_routes.d.ts +27 -0
  37. package/dist/auth/app_settings_routes.d.ts.map +1 -0
  38. package/dist/auth/app_settings_routes.js +66 -0
  39. package/dist/auth/app_settings_schema.d.ts +35 -0
  40. package/dist/auth/app_settings_schema.d.ts.map +1 -0
  41. package/dist/auth/app_settings_schema.js +22 -0
  42. package/dist/auth/audit_log_queries.d.ts +90 -0
  43. package/dist/auth/audit_log_queries.d.ts.map +1 -0
  44. package/dist/auth/audit_log_queries.js +205 -0
  45. package/dist/auth/audit_log_routes.d.ts +33 -0
  46. package/dist/auth/audit_log_routes.d.ts.map +1 -0
  47. package/dist/auth/audit_log_routes.js +106 -0
  48. package/dist/auth/audit_log_schema.d.ts +259 -0
  49. package/dist/auth/audit_log_schema.d.ts.map +1 -0
  50. package/dist/auth/audit_log_schema.js +123 -0
  51. package/dist/auth/bearer_auth.d.ts +32 -0
  52. package/dist/auth/bearer_auth.d.ts.map +1 -0
  53. package/dist/auth/bearer_auth.js +90 -0
  54. package/dist/auth/bootstrap_account.d.ts +82 -0
  55. package/dist/auth/bootstrap_account.d.ts.map +1 -0
  56. package/dist/auth/bootstrap_account.js +97 -0
  57. package/dist/auth/bootstrap_routes.d.ts +74 -0
  58. package/dist/auth/bootstrap_routes.d.ts.map +1 -0
  59. package/dist/auth/bootstrap_routes.js +154 -0
  60. package/dist/auth/daemon_token.d.ts +49 -0
  61. package/dist/auth/daemon_token.d.ts.map +1 -0
  62. package/dist/auth/daemon_token.js +49 -0
  63. package/dist/auth/daemon_token_middleware.d.ts +93 -0
  64. package/dist/auth/daemon_token_middleware.d.ts.map +1 -0
  65. package/dist/auth/daemon_token_middleware.js +167 -0
  66. package/dist/auth/ddl.d.ts +27 -0
  67. package/dist/auth/ddl.d.ts.map +1 -0
  68. package/dist/auth/ddl.js +111 -0
  69. package/dist/auth/deps.d.ts +52 -0
  70. package/dist/auth/deps.d.ts.map +1 -0
  71. package/dist/auth/deps.js +10 -0
  72. package/dist/auth/invite_queries.d.ts +68 -0
  73. package/dist/auth/invite_queries.d.ts.map +1 -0
  74. package/dist/auth/invite_queries.js +105 -0
  75. package/dist/auth/invite_routes.d.ts +18 -0
  76. package/dist/auth/invite_routes.d.ts.map +1 -0
  77. package/dist/auth/invite_routes.js +129 -0
  78. package/dist/auth/invite_schema.d.ts +51 -0
  79. package/dist/auth/invite_schema.d.ts.map +1 -0
  80. package/dist/auth/invite_schema.js +25 -0
  81. package/dist/auth/keyring.d.ts +87 -0
  82. package/dist/auth/keyring.d.ts.map +1 -0
  83. package/dist/auth/keyring.js +142 -0
  84. package/dist/auth/middleware.d.ts +40 -0
  85. package/dist/auth/middleware.d.ts.map +1 -0
  86. package/dist/auth/middleware.js +64 -0
  87. package/dist/auth/migrations.d.ts +42 -0
  88. package/dist/auth/migrations.d.ts.map +1 -0
  89. package/dist/auth/migrations.js +79 -0
  90. package/dist/auth/password.d.ts +39 -0
  91. package/dist/auth/password.d.ts.map +1 -0
  92. package/dist/auth/password.js +25 -0
  93. package/dist/auth/password_argon2.d.ts +43 -0
  94. package/dist/auth/password_argon2.d.ts.map +1 -0
  95. package/dist/auth/password_argon2.js +76 -0
  96. package/dist/auth/permit_queries.d.ts +72 -0
  97. package/dist/auth/permit_queries.d.ts.map +1 -0
  98. package/dist/auth/permit_queries.js +116 -0
  99. package/dist/auth/request_context.d.ts +114 -0
  100. package/dist/auth/request_context.d.ts.map +1 -0
  101. package/dist/auth/request_context.js +176 -0
  102. package/dist/auth/require_keeper.d.ts +20 -0
  103. package/dist/auth/require_keeper.d.ts.map +1 -0
  104. package/dist/auth/require_keeper.js +35 -0
  105. package/dist/auth/role_schema.d.ts +69 -0
  106. package/dist/auth/role_schema.d.ts.map +1 -0
  107. package/dist/auth/role_schema.js +70 -0
  108. package/dist/auth/route_guards.d.ts +21 -0
  109. package/dist/auth/route_guards.d.ts.map +1 -0
  110. package/dist/auth/route_guards.js +32 -0
  111. package/dist/auth/session_cookie.d.ts +158 -0
  112. package/dist/auth/session_cookie.d.ts.map +1 -0
  113. package/dist/auth/session_cookie.js +135 -0
  114. package/dist/auth/session_lifecycle.d.ts +35 -0
  115. package/dist/auth/session_lifecycle.d.ts.map +1 -0
  116. package/dist/auth/session_lifecycle.js +27 -0
  117. package/dist/auth/session_middleware.d.ts +33 -0
  118. package/dist/auth/session_middleware.d.ts.map +1 -0
  119. package/dist/auth/session_middleware.js +62 -0
  120. package/dist/auth/session_queries.d.ts +135 -0
  121. package/dist/auth/session_queries.d.ts.map +1 -0
  122. package/dist/auth/session_queries.js +186 -0
  123. package/dist/auth/signup_routes.d.ts +32 -0
  124. package/dist/auth/signup_routes.d.ts.map +1 -0
  125. package/dist/auth/signup_routes.js +150 -0
  126. package/dist/cli/args.d.ts +48 -0
  127. package/dist/cli/args.d.ts.map +1 -0
  128. package/dist/cli/args.js +76 -0
  129. package/dist/cli/config.d.ts +48 -0
  130. package/dist/cli/config.d.ts.map +1 -0
  131. package/dist/cli/config.js +77 -0
  132. package/dist/cli/daemon.d.ts +82 -0
  133. package/dist/cli/daemon.d.ts.map +1 -0
  134. package/dist/cli/daemon.js +149 -0
  135. package/dist/cli/help.d.ts +85 -0
  136. package/dist/cli/help.d.ts.map +1 -0
  137. package/dist/cli/help.js +138 -0
  138. package/dist/cli/logger.d.ts +46 -0
  139. package/dist/cli/logger.d.ts.map +1 -0
  140. package/dist/cli/logger.js +48 -0
  141. package/dist/cli/util.d.ts +36 -0
  142. package/dist/cli/util.d.ts.map +1 -0
  143. package/dist/cli/util.js +50 -0
  144. package/dist/crypto.d.ts +13 -0
  145. package/dist/crypto.d.ts.map +1 -0
  146. package/dist/crypto.js +19 -0
  147. package/dist/db/assert_row.d.ts +18 -0
  148. package/dist/db/assert_row.d.ts.map +1 -0
  149. package/dist/db/assert_row.js +24 -0
  150. package/dist/db/create_db.d.ts +38 -0
  151. package/dist/db/create_db.d.ts.map +1 -0
  152. package/dist/db/create_db.js +57 -0
  153. package/dist/db/db.d.ts +97 -0
  154. package/dist/db/db.d.ts.map +1 -0
  155. package/dist/db/db.js +76 -0
  156. package/dist/db/db_pg.d.ts +21 -0
  157. package/dist/db/db_pg.d.ts.map +1 -0
  158. package/dist/db/db_pg.js +45 -0
  159. package/dist/db/db_pglite.d.ts +21 -0
  160. package/dist/db/db_pglite.d.ts.map +1 -0
  161. package/dist/db/db_pglite.js +28 -0
  162. package/dist/db/migrate.d.ts +67 -0
  163. package/dist/db/migrate.d.ts.map +1 -0
  164. package/dist/db/migrate.js +118 -0
  165. package/dist/db/pg_error.d.ts +16 -0
  166. package/dist/db/pg_error.d.ts.map +1 -0
  167. package/dist/db/pg_error.js +15 -0
  168. package/dist/db/query_deps.d.ts +14 -0
  169. package/dist/db/query_deps.d.ts.map +1 -0
  170. package/dist/db/query_deps.js +9 -0
  171. package/dist/db/sql_identifier.d.ts +27 -0
  172. package/dist/db/sql_identifier.d.ts.map +1 -0
  173. package/dist/db/sql_identifier.js +31 -0
  174. package/dist/db/status.d.ts +62 -0
  175. package/dist/db/status.d.ts.map +1 -0
  176. package/dist/db/status.js +116 -0
  177. package/dist/dev/setup.d.ts +159 -0
  178. package/dist/dev/setup.d.ts.map +1 -0
  179. package/dist/dev/setup.js +265 -0
  180. package/dist/env/dotenv.d.ts +25 -0
  181. package/dist/env/dotenv.d.ts.map +1 -0
  182. package/dist/env/dotenv.js +52 -0
  183. package/dist/env/load.d.ts +52 -0
  184. package/dist/env/load.d.ts.map +1 -0
  185. package/dist/env/load.js +79 -0
  186. package/dist/env/mask.d.ts +19 -0
  187. package/dist/env/mask.d.ts.map +1 -0
  188. package/dist/env/mask.js +26 -0
  189. package/dist/env/resolve.d.ts +126 -0
  190. package/dist/env/resolve.d.ts.map +1 -0
  191. package/dist/env/resolve.js +200 -0
  192. package/dist/hono_context.d.ts +48 -0
  193. package/dist/hono_context.d.ts.map +1 -0
  194. package/dist/hono_context.js +22 -0
  195. package/dist/http/common_routes.d.ts +52 -0
  196. package/dist/http/common_routes.d.ts.map +1 -0
  197. package/dist/http/common_routes.js +65 -0
  198. package/dist/http/db_routes.d.ts +57 -0
  199. package/dist/http/db_routes.d.ts.map +1 -0
  200. package/dist/http/db_routes.js +176 -0
  201. package/dist/http/error_schemas.d.ts +169 -0
  202. package/dist/http/error_schemas.d.ts.map +1 -0
  203. package/dist/http/error_schemas.js +178 -0
  204. package/dist/http/middleware_spec.d.ts +19 -0
  205. package/dist/http/middleware_spec.d.ts.map +1 -0
  206. package/dist/http/middleware_spec.js +9 -0
  207. package/dist/http/origin.d.ts +57 -0
  208. package/dist/http/origin.d.ts.map +1 -0
  209. package/dist/http/origin.js +207 -0
  210. package/dist/http/proxy.d.ts +112 -0
  211. package/dist/http/proxy.d.ts.map +1 -0
  212. package/dist/http/proxy.js +240 -0
  213. package/dist/http/route_spec.d.ts +197 -0
  214. package/dist/http/route_spec.d.ts.map +1 -0
  215. package/dist/http/route_spec.js +243 -0
  216. package/dist/http/schema_helpers.d.ts +64 -0
  217. package/dist/http/schema_helpers.d.ts.map +1 -0
  218. package/dist/http/schema_helpers.js +90 -0
  219. package/dist/http/surface.d.ts +132 -0
  220. package/dist/http/surface.d.ts.map +1 -0
  221. package/dist/http/surface.js +156 -0
  222. package/dist/http/surface_query.d.ts +77 -0
  223. package/dist/http/surface_query.d.ts.map +1 -0
  224. package/dist/http/surface_query.js +86 -0
  225. package/dist/rate_limiter.d.ts +94 -0
  226. package/dist/rate_limiter.d.ts.map +1 -0
  227. package/dist/rate_limiter.js +156 -0
  228. package/dist/realtime/sse.d.ts +80 -0
  229. package/dist/realtime/sse.d.ts.map +1 -0
  230. package/dist/realtime/sse.js +109 -0
  231. package/dist/realtime/sse_auth_guard.d.ts +93 -0
  232. package/dist/realtime/sse_auth_guard.d.ts.map +1 -0
  233. package/dist/realtime/sse_auth_guard.js +111 -0
  234. package/dist/realtime/subscriber_registry.d.ts +85 -0
  235. package/dist/realtime/subscriber_registry.d.ts.map +1 -0
  236. package/dist/realtime/subscriber_registry.js +108 -0
  237. package/dist/runtime/deno.d.ts +21 -0
  238. package/dist/runtime/deno.d.ts.map +1 -0
  239. package/dist/runtime/deno.js +83 -0
  240. package/dist/runtime/deps.d.ts +113 -0
  241. package/dist/runtime/deps.d.ts.map +1 -0
  242. package/dist/runtime/deps.js +10 -0
  243. package/dist/runtime/fs.d.ts +15 -0
  244. package/dist/runtime/fs.d.ts.map +1 -0
  245. package/dist/runtime/fs.js +17 -0
  246. package/dist/runtime/mock.d.ts +81 -0
  247. package/dist/runtime/mock.d.ts.map +1 -0
  248. package/dist/runtime/mock.js +195 -0
  249. package/dist/runtime/node.d.ts +17 -0
  250. package/dist/runtime/node.d.ts.map +1 -0
  251. package/dist/runtime/node.js +117 -0
  252. package/dist/schema_meta.d.ts +16 -0
  253. package/dist/schema_meta.d.ts.map +1 -0
  254. package/dist/schema_meta.js +9 -0
  255. package/dist/sensitivity.d.ts +15 -0
  256. package/dist/sensitivity.d.ts.map +1 -0
  257. package/dist/sensitivity.js +9 -0
  258. package/dist/server/app_backend.d.ts +74 -0
  259. package/dist/server/app_backend.d.ts.map +1 -0
  260. package/dist/server/app_backend.js +39 -0
  261. package/dist/server/app_server.d.ts +201 -0
  262. package/dist/server/app_server.d.ts.map +1 -0
  263. package/dist/server/app_server.js +266 -0
  264. package/dist/server/env.d.ts +68 -0
  265. package/dist/server/env.d.ts.map +1 -0
  266. package/dist/server/env.js +95 -0
  267. package/dist/server/startup.d.ts +22 -0
  268. package/dist/server/startup.d.ts.map +1 -0
  269. package/dist/server/startup.js +48 -0
  270. package/dist/server/static.d.ts +39 -0
  271. package/dist/server/static.d.ts.map +1 -0
  272. package/dist/server/static.js +38 -0
  273. package/dist/server/validate_nginx.d.ts +34 -0
  274. package/dist/server/validate_nginx.d.ts.map +1 -0
  275. package/dist/server/validate_nginx.js +118 -0
  276. package/dist/testing/CLAUDE.md +3 -0
  277. package/dist/testing/admin_integration.d.ts +45 -0
  278. package/dist/testing/admin_integration.d.ts.map +1 -0
  279. package/dist/testing/admin_integration.js +840 -0
  280. package/dist/testing/adversarial_404.d.ts +15 -0
  281. package/dist/testing/adversarial_404.d.ts.map +1 -0
  282. package/dist/testing/adversarial_404.js +118 -0
  283. package/dist/testing/adversarial_headers.d.ts +36 -0
  284. package/dist/testing/adversarial_headers.d.ts.map +1 -0
  285. package/dist/testing/adversarial_headers.js +128 -0
  286. package/dist/testing/adversarial_input.d.ts +56 -0
  287. package/dist/testing/adversarial_input.d.ts.map +1 -0
  288. package/dist/testing/adversarial_input.js +494 -0
  289. package/dist/testing/app_server.d.ts +169 -0
  290. package/dist/testing/app_server.d.ts.map +1 -0
  291. package/dist/testing/app_server.js +240 -0
  292. package/dist/testing/assert_dev_env.d.ts +10 -0
  293. package/dist/testing/assert_dev_env.d.ts.map +1 -0
  294. package/dist/testing/assert_dev_env.js +13 -0
  295. package/dist/testing/assertions.d.ts +61 -0
  296. package/dist/testing/assertions.d.ts.map +1 -0
  297. package/dist/testing/assertions.js +96 -0
  298. package/dist/testing/attack_surface.d.ts +63 -0
  299. package/dist/testing/attack_surface.d.ts.map +1 -0
  300. package/dist/testing/attack_surface.js +224 -0
  301. package/dist/testing/audit_completeness.d.ts +29 -0
  302. package/dist/testing/audit_completeness.d.ts.map +1 -0
  303. package/dist/testing/audit_completeness.js +410 -0
  304. package/dist/testing/auth_apps.d.ts +55 -0
  305. package/dist/testing/auth_apps.d.ts.map +1 -0
  306. package/dist/testing/auth_apps.js +122 -0
  307. package/dist/testing/data_exposure.d.ts +62 -0
  308. package/dist/testing/data_exposure.d.ts.map +1 -0
  309. package/dist/testing/data_exposure.js +297 -0
  310. package/dist/testing/db.d.ts +111 -0
  311. package/dist/testing/db.d.ts.map +1 -0
  312. package/dist/testing/db.js +258 -0
  313. package/dist/testing/entities.d.ts +21 -0
  314. package/dist/testing/entities.d.ts.map +1 -0
  315. package/dist/testing/entities.js +42 -0
  316. package/dist/testing/error_coverage.d.ts +78 -0
  317. package/dist/testing/error_coverage.d.ts.map +1 -0
  318. package/dist/testing/error_coverage.js +135 -0
  319. package/dist/testing/integration.d.ts +37 -0
  320. package/dist/testing/integration.d.ts.map +1 -0
  321. package/dist/testing/integration.js +1139 -0
  322. package/dist/testing/integration_helpers.d.ts +107 -0
  323. package/dist/testing/integration_helpers.d.ts.map +1 -0
  324. package/dist/testing/integration_helpers.js +246 -0
  325. package/dist/testing/middleware.d.ts +125 -0
  326. package/dist/testing/middleware.d.ts.map +1 -0
  327. package/dist/testing/middleware.js +210 -0
  328. package/dist/testing/rate_limiting.d.ts +43 -0
  329. package/dist/testing/rate_limiting.d.ts.map +1 -0
  330. package/dist/testing/rate_limiting.js +216 -0
  331. package/dist/testing/round_trip.d.ts +37 -0
  332. package/dist/testing/round_trip.d.ts.map +1 -0
  333. package/dist/testing/round_trip.js +128 -0
  334. package/dist/testing/schema_generators.d.ts +33 -0
  335. package/dist/testing/schema_generators.d.ts.map +1 -0
  336. package/dist/testing/schema_generators.js +137 -0
  337. package/dist/testing/standard.d.ts +49 -0
  338. package/dist/testing/standard.d.ts.map +1 -0
  339. package/dist/testing/standard.js +16 -0
  340. package/dist/testing/stubs.d.ts +96 -0
  341. package/dist/testing/stubs.d.ts.map +1 -0
  342. package/dist/testing/stubs.js +192 -0
  343. package/dist/testing/surface_invariants.d.ts +189 -0
  344. package/dist/testing/surface_invariants.d.ts.map +1 -0
  345. package/dist/testing/surface_invariants.js +450 -0
  346. package/dist/ui/AccountSessions.svelte +75 -0
  347. package/dist/ui/AccountSessions.svelte.d.ts +19 -0
  348. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -0
  349. package/dist/ui/AdminAccounts.svelte +107 -0
  350. package/dist/ui/AdminAccounts.svelte.d.ts +19 -0
  351. package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -0
  352. package/dist/ui/AdminAuditLog.svelte +144 -0
  353. package/dist/ui/AdminAuditLog.svelte.d.ts +4 -0
  354. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -0
  355. package/dist/ui/AdminInvites.svelte +142 -0
  356. package/dist/ui/AdminInvites.svelte.d.ts +4 -0
  357. package/dist/ui/AdminInvites.svelte.d.ts.map +1 -0
  358. package/dist/ui/AdminOverview.svelte +337 -0
  359. package/dist/ui/AdminOverview.svelte.d.ts +4 -0
  360. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -0
  361. package/dist/ui/AdminPermitHistory.svelte +61 -0
  362. package/dist/ui/AdminPermitHistory.svelte.d.ts +19 -0
  363. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -0
  364. package/dist/ui/AdminSessions.svelte +85 -0
  365. package/dist/ui/AdminSessions.svelte.d.ts +19 -0
  366. package/dist/ui/AdminSessions.svelte.d.ts.map +1 -0
  367. package/dist/ui/AdminSettings.svelte +32 -0
  368. package/dist/ui/AdminSettings.svelte.d.ts +19 -0
  369. package/dist/ui/AdminSettings.svelte.d.ts.map +1 -0
  370. package/dist/ui/AdminSurface.svelte +42 -0
  371. package/dist/ui/AdminSurface.svelte.d.ts +4 -0
  372. package/dist/ui/AdminSurface.svelte.d.ts.map +1 -0
  373. package/dist/ui/AppShell.svelte +93 -0
  374. package/dist/ui/AppShell.svelte.d.ts +20 -0
  375. package/dist/ui/AppShell.svelte.d.ts.map +1 -0
  376. package/dist/ui/BootstrapForm.svelte +105 -0
  377. package/dist/ui/BootstrapForm.svelte.d.ts +4 -0
  378. package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -0
  379. package/dist/ui/ColumnLayout.svelte +46 -0
  380. package/dist/ui/ColumnLayout.svelte.d.ts +11 -0
  381. package/dist/ui/ColumnLayout.svelte.d.ts.map +1 -0
  382. package/dist/ui/ConfirmButton.svelte +125 -0
  383. package/dist/ui/ConfirmButton.svelte.d.ts +54 -0
  384. package/dist/ui/ConfirmButton.svelte.d.ts.map +1 -0
  385. package/dist/ui/Datatable.svelte +185 -0
  386. package/dist/ui/Datatable.svelte.d.ts +35 -0
  387. package/dist/ui/Datatable.svelte.d.ts.map +1 -0
  388. package/dist/ui/LoginForm.svelte +82 -0
  389. package/dist/ui/LoginForm.svelte.d.ts +8 -0
  390. package/dist/ui/LoginForm.svelte.d.ts.map +1 -0
  391. package/dist/ui/LogoutButton.svelte +36 -0
  392. package/dist/ui/LogoutButton.svelte.d.ts +10 -0
  393. package/dist/ui/LogoutButton.svelte.d.ts.map +1 -0
  394. package/dist/ui/MenuLink.svelte +35 -0
  395. package/dist/ui/MenuLink.svelte.d.ts +12 -0
  396. package/dist/ui/MenuLink.svelte.d.ts.map +1 -0
  397. package/dist/ui/OpenSignupToggle.svelte +36 -0
  398. package/dist/ui/OpenSignupToggle.svelte.d.ts +19 -0
  399. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -0
  400. package/dist/ui/PopoverButton.svelte +136 -0
  401. package/dist/ui/PopoverButton.svelte.d.ts +63 -0
  402. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -0
  403. package/dist/ui/SignupForm.svelte +117 -0
  404. package/dist/ui/SignupForm.svelte.d.ts +7 -0
  405. package/dist/ui/SignupForm.svelte.d.ts.map +1 -0
  406. package/dist/ui/SurfaceExplorer.svelte +287 -0
  407. package/dist/ui/SurfaceExplorer.svelte.d.ts +8 -0
  408. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -0
  409. package/dist/ui/account_sessions_state.svelte.d.ts +15 -0
  410. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -0
  411. package/dist/ui/account_sessions_state.svelte.js +45 -0
  412. package/dist/ui/admin_accounts_state.svelte.d.ts +19 -0
  413. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -0
  414. package/dist/ui/admin_accounts_state.svelte.js +65 -0
  415. package/dist/ui/admin_invites_state.svelte.d.ts +19 -0
  416. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -0
  417. package/dist/ui/admin_invites_state.svelte.js +71 -0
  418. package/dist/ui/admin_sessions_state.svelte.d.ts +18 -0
  419. package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -0
  420. package/dist/ui/admin_sessions_state.svelte.js +62 -0
  421. package/dist/ui/app_settings_state.svelte.d.ts +14 -0
  422. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -0
  423. package/dist/ui/app_settings_state.svelte.js +44 -0
  424. package/dist/ui/audit_log_state.svelte.d.ts +40 -0
  425. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -0
  426. package/dist/ui/audit_log_state.svelte.js +153 -0
  427. package/dist/ui/auth_state.svelte.d.ts +85 -0
  428. package/dist/ui/auth_state.svelte.d.ts.map +1 -0
  429. package/dist/ui/auth_state.svelte.js +238 -0
  430. package/dist/ui/datatable.d.ts +25 -0
  431. package/dist/ui/datatable.d.ts.map +1 -0
  432. package/dist/ui/datatable.js +9 -0
  433. package/dist/ui/enter_advance.d.ts +13 -0
  434. package/dist/ui/enter_advance.d.ts.map +1 -0
  435. package/dist/ui/enter_advance.js +30 -0
  436. package/dist/ui/loadable.svelte.d.ts +55 -0
  437. package/dist/ui/loadable.svelte.d.ts.map +1 -0
  438. package/dist/ui/loadable.svelte.js +75 -0
  439. package/dist/ui/popover.svelte.d.ts +137 -0
  440. package/dist/ui/popover.svelte.d.ts.map +1 -0
  441. package/dist/ui/popover.svelte.js +288 -0
  442. package/dist/ui/position_helpers.d.ts +27 -0
  443. package/dist/ui/position_helpers.d.ts.map +1 -0
  444. package/dist/ui/position_helpers.js +81 -0
  445. package/dist/ui/sidebar_state.svelte.d.ts +30 -0
  446. package/dist/ui/sidebar_state.svelte.d.ts.map +1 -0
  447. package/dist/ui/sidebar_state.svelte.js +39 -0
  448. package/dist/ui/table_state.svelte.d.ts +63 -0
  449. package/dist/ui/table_state.svelte.d.ts.map +1 -0
  450. package/dist/ui/table_state.svelte.js +117 -0
  451. package/dist/ui/ui_fetch.d.ts +29 -0
  452. package/dist/ui/ui_fetch.d.ts.map +1 -0
  453. package/dist/ui/ui_fetch.js +37 -0
  454. package/dist/ui/ui_format.d.ts +63 -0
  455. package/dist/ui/ui_format.d.ts.map +1 -0
  456. package/dist/ui/ui_format.js +196 -0
  457. package/package.json +121 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Base reactive state class with loading/error management.
3
+ *
4
+ * Provides the common loading/error pattern shared by all state classes.
5
+ * Subclasses add domain-specific `$state` fields and methods that call
6
+ * the protected `run` helper for async operations.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * class ItemsState extends Loadable {
11
+ * items: Array<Item> = $state([]);
12
+ *
13
+ * async fetch(): Promise<void> {
14
+ * await this.run(async () => {
15
+ * const response = await fetch('/api/items');
16
+ * if (!response.ok) throw new Error('failed to fetch');
17
+ * this.items = await response.json();
18
+ * });
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * // structured errors via map_error
26
+ * class FormState extends Loadable<{field: string; message: string}> {
27
+ * async submit(data: FormData): Promise<void> {
28
+ * await this.run(
29
+ * () => post_form(data),
30
+ * (e) => ({field: 'form', message: e instanceof Error ? e.message : 'unknown'}),
31
+ * );
32
+ * }
33
+ * }
34
+ * ```
35
+ *
36
+ * @module
37
+ */
38
+ export declare class Loadable<TError = string> {
39
+ loading: boolean;
40
+ error: TError | null;
41
+ /** The raw caught value from the last failed `run()`, for programmatic inspection. */
42
+ error_data: unknown;
43
+ /**
44
+ * Run an async operation with loading/error handling.
45
+ *
46
+ * Sets `loading` to `true`, clears `error` and `error_data`, runs `fn`, catches errors.
47
+ * Pass `map_error` to produce structured errors instead of strings.
48
+ *
49
+ * @returns the result or `undefined` if the operation failed
50
+ */
51
+ protected run<T>(fn: () => Promise<T>, map_error?: (e: unknown) => TError): Promise<T | undefined>;
52
+ /** Reset loading and error state. Subclasses override to clear data. */
53
+ reset(): void;
54
+ }
55
+ //# sourceMappingURL=loadable.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadable.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/loadable.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,qBAAa,QAAQ,CAAC,MAAM,GAAG,MAAM;IACpC,OAAO,UAAiB;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAgB;IAEpC,sFAAsF;IACtF,UAAU,EAAE,OAAO,CAAgB;IAEnC;;;;;;;OAOG;cACa,GAAG,CAAC,CAAC,EACpB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,GAChC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAiBzB,wEAAwE;IACxE,KAAK,IAAI,IAAI;CAKb"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Base reactive state class with loading/error management.
3
+ *
4
+ * Provides the common loading/error pattern shared by all state classes.
5
+ * Subclasses add domain-specific `$state` fields and methods that call
6
+ * the protected `run` helper for async operations.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * class ItemsState extends Loadable {
11
+ * items: Array<Item> = $state([]);
12
+ *
13
+ * async fetch(): Promise<void> {
14
+ * await this.run(async () => {
15
+ * const response = await fetch('/api/items');
16
+ * if (!response.ok) throw new Error('failed to fetch');
17
+ * this.items = await response.json();
18
+ * });
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * // structured errors via map_error
26
+ * class FormState extends Loadable<{field: string; message: string}> {
27
+ * async submit(data: FormData): Promise<void> {
28
+ * await this.run(
29
+ * () => post_form(data),
30
+ * (e) => ({field: 'form', message: e instanceof Error ? e.message : 'unknown'}),
31
+ * );
32
+ * }
33
+ * }
34
+ * ```
35
+ *
36
+ * @module
37
+ */
38
+ export class Loadable {
39
+ loading = $state(false);
40
+ error = $state(null);
41
+ /** The raw caught value from the last failed `run()`, for programmatic inspection. */
42
+ error_data = $state(null);
43
+ /**
44
+ * Run an async operation with loading/error handling.
45
+ *
46
+ * Sets `loading` to `true`, clears `error` and `error_data`, runs `fn`, catches errors.
47
+ * Pass `map_error` to produce structured errors instead of strings.
48
+ *
49
+ * @returns the result or `undefined` if the operation failed
50
+ */
51
+ async run(fn, map_error) {
52
+ this.loading = true;
53
+ this.error = null;
54
+ this.error_data = null;
55
+ try {
56
+ return await fn();
57
+ }
58
+ catch (e) {
59
+ this.error = map_error
60
+ ? map_error(e)
61
+ : (e instanceof Error ? e.message : 'Request failed');
62
+ this.error_data = e;
63
+ return undefined;
64
+ }
65
+ finally {
66
+ this.loading = false;
67
+ }
68
+ }
69
+ /** Reset loading and error state. Subclasses override to clear data. */
70
+ reset() {
71
+ this.loading = false;
72
+ this.error = null;
73
+ this.error_data = null;
74
+ }
75
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Popover state class with trigger, content, and container attachments.
3
+ *
4
+ * `Popover` manages visibility, positioning, outside-click dismissal,
5
+ * and ARIA attributes. The `trigger`, `content`, and `container`
6
+ * attachments wire up the DOM via Svelte's `{@attach}` directive.
7
+ *
8
+ * For the common button + popover pattern, see `PopoverButton`.
9
+ *
10
+ * @example
11
+ * ```svelte
12
+ * <script lang="ts">
13
+ * import {Popover} from '@fuzdev/fuz_app/ui/popover.svelte.js';
14
+ *
15
+ * const popover = new Popover();
16
+ * </script>
17
+ *
18
+ * <div class="position:relative" {@attach popover.container}>
19
+ * <button type="button" {@attach popover.trigger({position: 'bottom', align: 'center'})}>
20
+ * toggle
21
+ * </button>
22
+ * {#if popover.visible}
23
+ * <div {@attach popover.content({position: 'bottom', align: 'center'})}>
24
+ * <button type="button" onclick={() => popover.hide()}>close</button>
25
+ * </div>
26
+ * {/if}
27
+ * </div>
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * // programmatic control with callbacks
33
+ * const popover = new Popover({
34
+ * position: 'right',
35
+ * align: 'start',
36
+ * offset: '8px',
37
+ * disable_outside_click: true,
38
+ * onshow: () => console.log('opened'),
39
+ * onhide: () => console.log('closed'),
40
+ * });
41
+ *
42
+ * popover.show();
43
+ * popover.toggle();
44
+ * popover.hide();
45
+ * ```
46
+ *
47
+ * @module
48
+ */
49
+ import type { Attachment } from 'svelte/attachments';
50
+ import type { Snippet } from 'svelte';
51
+ import type { TransitionConfig } from 'svelte/transition';
52
+ import { type Position, type Alignment } from './position_helpers.js';
53
+ /**
54
+ * Parameters for configuring the popover.
55
+ */
56
+ export interface PopoverParameters {
57
+ /** Position of the popover relative to its trigger. */
58
+ position?: Position;
59
+ /** Alignment along the position edge. */
60
+ align?: Alignment;
61
+ /** Distance from the position. */
62
+ offset?: string;
63
+ /** Whether to disable closing when clicking outside. */
64
+ disable_outside_click?: boolean;
65
+ /** Custom class for the popover content. */
66
+ popover_class?: string;
67
+ /** Optional callback when popover is shown. */
68
+ onshow?: () => void;
69
+ /** Optional callback when popover is hidden. */
70
+ onhide?: () => void;
71
+ }
72
+ /**
73
+ * Parameters for the popover trigger action.
74
+ */
75
+ export interface PopoverTriggerParameters extends PopoverParameters {
76
+ /** Content to render in the popover (as a snippet). */
77
+ content?: Snippet;
78
+ }
79
+ /**
80
+ * Support both Svelte transitions and custom transitions.
81
+ */
82
+ export type TransitionFunction = (node: HTMLElement) => TransitionConfig | {
83
+ destroy?: () => void;
84
+ };
85
+ /**
86
+ * Parameters for the popover content action.
87
+ */
88
+ export interface PopoverContentParameters extends PopoverParameters {
89
+ }
90
+ /**
91
+ * Class that manages state and provides actions for popovers.
92
+ */
93
+ export declare class Popover {
94
+ #private;
95
+ /** Whether the popover is currently visible. */
96
+ visible: boolean;
97
+ /** Position of the popover relative to its trigger. */
98
+ position: Position;
99
+ /** Alignment along the position edge. */
100
+ align: Alignment;
101
+ /** Distance from the position. */
102
+ offset: string;
103
+ /** Whether to disable closing when clicking outside. */
104
+ disable_outside_click: boolean;
105
+ /** Custom class for the popover. */
106
+ popover_class: string;
107
+ constructor(params?: PopoverParameters);
108
+ /**
109
+ * Updates the popover configuration.
110
+ */
111
+ update(params: PopoverParameters): void;
112
+ /**
113
+ * Shows the popover.
114
+ */
115
+ show(): void;
116
+ /**
117
+ * Hides the popover.
118
+ */
119
+ hide(): void;
120
+ /**
121
+ * Toggles the popover visibility.
122
+ */
123
+ toggle(visible?: boolean): void;
124
+ /**
125
+ * Attachment for the container element.
126
+ */
127
+ container: Attachment<HTMLElement>;
128
+ /**
129
+ * Attachment factory for the trigger element that shows/hides the popover.
130
+ */
131
+ trigger: (params?: PopoverTriggerParameters) => Attachment<HTMLElement>;
132
+ /**
133
+ * Attachment factory for the popover content element.
134
+ */
135
+ content: (params?: PopoverContentParameters) => Attachment<HTMLElement>;
136
+ }
137
+ //# sourceMappingURL=popover.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/popover.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,QAAQ,CAAC;AAGpC,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAC,KAAK,QAAQ,EAAE,KAAK,SAAS,EAA2B,MAAM,uBAAuB,CAAC;AAS9F;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,yCAAyC;IACzC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;IAClE,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,gBAAgB,GAAG;IAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAC,CAAC;AAElG;;GAEG;AAEH,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;CAElE;AAED;;GAEG;AACH,qBAAa,OAAO;;IACnB,gDAAgD;IAChD,OAAO,UAAiB;IAExB,uDAAuD;IACvD,QAAQ,EAAE,QAAQ,CAAoB;IAEtC,yCAAyC;IACzC,KAAK,EAAE,SAAS,CAAoB;IAEpC,kCAAkC;IAClC,MAAM,SAAe;IAErB,wDAAwD;IACxD,qBAAqB,UAAiB;IAEtC,oCAAoC;IACpC,aAAa,SAAc;gBAoBf,MAAM,CAAC,EAAE,iBAAiB;IAiCtC;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAgEvC;;OAEG;IACH,IAAI,IAAI,IAAI;IAWZ;;OAEG;IACH,IAAI,IAAI,IAAI;IAWZ;;OAEG;IACH,MAAM,CAAC,OAAO,UAAgB,GAAG,IAAI;IAQrC;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAQhC;IAEF;;OAEG;IACH,OAAO,GAAI,SAAS,wBAAwB,KAAG,UAAU,CAAC,WAAW,CAAC,CAsBpE;IAEF;;OAEG;IACH,OAAO,GAAI,SAAS,wBAAwB,KAAG,UAAU,CAAC,WAAW,CAAC,CA2DpE;CACF"}
@@ -0,0 +1,288 @@
1
+ /**
2
+ * Popover state class with trigger, content, and container attachments.
3
+ *
4
+ * `Popover` manages visibility, positioning, outside-click dismissal,
5
+ * and ARIA attributes. The `trigger`, `content`, and `container`
6
+ * attachments wire up the DOM via Svelte's `{@attach}` directive.
7
+ *
8
+ * For the common button + popover pattern, see `PopoverButton`.
9
+ *
10
+ * @example
11
+ * ```svelte
12
+ * <script lang="ts">
13
+ * import {Popover} from '@fuzdev/fuz_app/ui/popover.svelte.js';
14
+ *
15
+ * const popover = new Popover();
16
+ * </script>
17
+ *
18
+ * <div class="position:relative" {@attach popover.container}>
19
+ * <button type="button" {@attach popover.trigger({position: 'bottom', align: 'center'})}>
20
+ * toggle
21
+ * </button>
22
+ * {#if popover.visible}
23
+ * <div {@attach popover.content({position: 'bottom', align: 'center'})}>
24
+ * <button type="button" onclick={() => popover.hide()}>close</button>
25
+ * </div>
26
+ * {/if}
27
+ * </div>
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * // programmatic control with callbacks
33
+ * const popover = new Popover({
34
+ * position: 'right',
35
+ * align: 'start',
36
+ * offset: '8px',
37
+ * disable_outside_click: true,
38
+ * onshow: () => console.log('opened'),
39
+ * onhide: () => console.log('closed'),
40
+ * });
41
+ *
42
+ * popover.show();
43
+ * popover.toggle();
44
+ * popover.hide();
45
+ * ```
46
+ *
47
+ * @module
48
+ */
49
+ import { on } from 'svelte/events';
50
+ import { swallow } from '@fuzdev/fuz_util/dom.js';
51
+ import { generate_position_styles } from './position_helpers.js';
52
+ const create_client_id = () => Math.random().toString(36).substring(2);
53
+ /**
54
+ * Class that manages state and provides actions for popovers.
55
+ */
56
+ export class Popover {
57
+ /** Whether the popover is currently visible. */
58
+ visible = $state(false);
59
+ /** Position of the popover relative to its trigger. */
60
+ position = $state('bottom');
61
+ /** Alignment along the position edge. */
62
+ align = $state('center');
63
+ /** Distance from the position. */
64
+ offset = $state('0');
65
+ /** Whether to disable closing when clicking outside. */
66
+ disable_outside_click = $state(false);
67
+ /** Custom class for the popover. */
68
+ popover_class = $state('');
69
+ /** Reference to the trigger element. */
70
+ #trigger_element = null;
71
+ /** Reference to the content element. */
72
+ #content_element = null;
73
+ /** Reference to the container element. */
74
+ #container_element = null;
75
+ /** Onshow callback. */
76
+ #onshow = undefined;
77
+ /** Onhide callback. */
78
+ #onhide = undefined;
79
+ /** Cleanup function for document click handler. */
80
+ #document_click_cleanup = undefined;
81
+ constructor(params) {
82
+ if (params) {
83
+ this.update(params);
84
+ }
85
+ }
86
+ /**
87
+ * Sets up or removes the document click handler based on current state.
88
+ */
89
+ #manage_outside_click() {
90
+ // If we should have an outside click handler but don't, add one
91
+ if (this.visible && !this.disable_outside_click && !this.#document_click_cleanup) {
92
+ this.#document_click_cleanup = on(document, 'click', (event) => {
93
+ const target = event.target;
94
+ if (this.#content_element &&
95
+ this.#trigger_element &&
96
+ !this.#content_element.contains(target) &&
97
+ !this.#trigger_element.contains(target) &&
98
+ (!this.#container_element || !this.#container_element.contains(target))) {
99
+ this.hide();
100
+ }
101
+ });
102
+ }
103
+ // If we shouldn't have an outside click handler but do, remove it
104
+ else if ((!this.visible || this.disable_outside_click) && this.#document_click_cleanup) {
105
+ this.#document_click_cleanup();
106
+ this.#document_click_cleanup = undefined;
107
+ }
108
+ }
109
+ /**
110
+ * Updates the popover configuration.
111
+ */
112
+ update(params) {
113
+ // Store the old class before updating
114
+ const old_class = this.popover_class;
115
+ const old_disable_outside_click = this.disable_outside_click;
116
+ // Update properties
117
+ if (params.position !== undefined)
118
+ this.position = params.position;
119
+ if (params.align !== undefined)
120
+ this.align = params.align;
121
+ if (params.offset !== undefined)
122
+ this.offset = params.offset;
123
+ if (params.popover_class !== undefined)
124
+ this.popover_class = params.popover_class;
125
+ if (params.disable_outside_click !== undefined)
126
+ this.disable_outside_click = params.disable_outside_click;
127
+ // Update classes on content element if it exists and class changed
128
+ if (this.#content_element &&
129
+ params.popover_class !== undefined &&
130
+ old_class !== params.popover_class) {
131
+ // Remove old class if it exists
132
+ if (old_class) {
133
+ this.#content_element.classList.remove(old_class);
134
+ }
135
+ // Add new class if it exists
136
+ if (this.popover_class) {
137
+ this.#content_element.classList.add(this.popover_class);
138
+ }
139
+ }
140
+ // Update outside click handler if disable_outside_click changed
141
+ if (params.disable_outside_click !== undefined &&
142
+ old_disable_outside_click !== this.disable_outside_click) {
143
+ this.#manage_outside_click();
144
+ }
145
+ if (params.onshow !== undefined)
146
+ this.#onshow = params.onshow;
147
+ if (params.onhide !== undefined)
148
+ this.#onhide = params.onhide;
149
+ // Update ARIA attributes on trigger if it exists
150
+ this.#update_trigger_aria_attributes();
151
+ // Note: We don't directly manipulate visibility with style properties
152
+ // to allow Svelte transitions to work properly
153
+ }
154
+ /**
155
+ * Updates ARIA attributes and state for accessibility.
156
+ */
157
+ #update_trigger_aria_attributes() {
158
+ if (this.#trigger_element) {
159
+ this.#trigger_element.setAttribute('aria-expanded', this.visible ? 'true' : 'false');
160
+ // If we have a content element, establish the relationship
161
+ if (this.#content_element) {
162
+ const content_id = this.#content_element.id || `popover-content-${create_client_id()}`;
163
+ this.#content_element.id = content_id;
164
+ this.#trigger_element.setAttribute('aria-controls', content_id);
165
+ }
166
+ }
167
+ }
168
+ /**
169
+ * Shows the popover.
170
+ */
171
+ show() {
172
+ if (this.visible)
173
+ return;
174
+ this.visible = true;
175
+ this.#manage_outside_click();
176
+ this.#update_trigger_aria_attributes();
177
+ if (this.#onshow)
178
+ this.#onshow();
179
+ }
180
+ /**
181
+ * Hides the popover.
182
+ */
183
+ hide() {
184
+ if (!this.visible)
185
+ return;
186
+ this.visible = false;
187
+ this.#manage_outside_click();
188
+ this.#update_trigger_aria_attributes();
189
+ if (this.#onhide)
190
+ this.#onhide();
191
+ }
192
+ /**
193
+ * Toggles the popover visibility.
194
+ */
195
+ toggle(visible = !this.visible) {
196
+ if (visible) {
197
+ this.show();
198
+ }
199
+ else {
200
+ this.hide();
201
+ }
202
+ }
203
+ /**
204
+ * Attachment for the container element.
205
+ */
206
+ container = (node) => {
207
+ this.#container_element = node;
208
+ return () => {
209
+ if (this.#container_element === node) {
210
+ this.#container_element = null;
211
+ }
212
+ };
213
+ };
214
+ /**
215
+ * Attachment factory for the trigger element that shows/hides the popover.
216
+ */
217
+ trigger = (params) => {
218
+ return (node) => {
219
+ this.#trigger_element = node;
220
+ if (params) {
221
+ this.update(params);
222
+ }
223
+ this.#update_trigger_aria_attributes();
224
+ const click_handler = on(node, 'click', (e) => {
225
+ swallow(e);
226
+ this.toggle();
227
+ });
228
+ return () => {
229
+ click_handler();
230
+ if (this.#trigger_element === node) {
231
+ this.#trigger_element = null;
232
+ }
233
+ };
234
+ };
235
+ };
236
+ /**
237
+ * Attachment factory for the popover content element.
238
+ */
239
+ content = (params) => {
240
+ return (node) => {
241
+ this.#content_element = node;
242
+ if (params) {
243
+ this.update(params);
244
+ }
245
+ if (this.popover_class) {
246
+ node.classList.add(this.popover_class);
247
+ }
248
+ node.style.position = 'absolute';
249
+ node.style.zIndex = '10';
250
+ const update_node_position = () => {
251
+ const styles = generate_position_styles(this.position, this.align, this.offset);
252
+ const position_props = [
253
+ 'top',
254
+ 'bottom',
255
+ 'left',
256
+ 'right',
257
+ 'transform',
258
+ 'transform-origin',
259
+ 'width',
260
+ 'height',
261
+ ];
262
+ for (const prop of position_props) {
263
+ node.style.removeProperty(prop);
264
+ }
265
+ for (const key in styles) {
266
+ node.style.setProperty(key, styles[key]);
267
+ }
268
+ };
269
+ update_node_position();
270
+ this.#manage_outside_click();
271
+ if (!node.hasAttribute('role')) {
272
+ node.setAttribute('role', 'dialog');
273
+ }
274
+ return () => {
275
+ if (this.#document_click_cleanup) {
276
+ this.#document_click_cleanup();
277
+ this.#document_click_cleanup = undefined;
278
+ }
279
+ if (this.popover_class) {
280
+ node.classList.remove(this.popover_class);
281
+ }
282
+ if (this.#content_element === node) {
283
+ this.#content_element = null;
284
+ }
285
+ };
286
+ };
287
+ };
288
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * CSS position calculation helpers for popovers and floating UI elements.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Basic position options for UI elements (cardinal directions).
8
+ */
9
+ export type CardinalPosition = 'left' | 'right' | 'top' | 'bottom';
10
+ /**
11
+ * Extended position options including overlay and center.
12
+ */
13
+ export type Position = CardinalPosition | 'overlay' | 'center';
14
+ /**
15
+ * Alignment options for positioned elements.
16
+ */
17
+ export type Alignment = 'start' | 'center' | 'end';
18
+ /**
19
+ * Generates CSS positioning styles for UI elements.
20
+ *
21
+ * @param position - where to position the element ('left', 'right', etc.)
22
+ * @param align - alignment along the position edge ('start', 'center', 'end')
23
+ * @param offset - distance from the position (CSS value)
24
+ * @returns CSS styles as a Record
25
+ */
26
+ export declare const generate_position_styles: (position?: Position, align?: Alignment, offset?: string) => Record<string, string>;
27
+ //# sourceMappingURL=position_helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/position_helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,gBAAgB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACpC,WAAU,QAAmB,EAC7B,QAAO,SAAoB,EAC3B,eAAY,KACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAiEvB,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * CSS position calculation helpers for popovers and floating UI elements.
3
+ *
4
+ * @module
5
+ */
6
+ import { UnreachableError } from '@fuzdev/fuz_util/error.js';
7
+ /**
8
+ * Generates CSS positioning styles for UI elements.
9
+ *
10
+ * @param position - where to position the element ('left', 'right', etc.)
11
+ * @param align - alignment along the position edge ('start', 'center', 'end')
12
+ * @param offset - distance from the position (CSS value)
13
+ * @returns CSS styles as a Record
14
+ */
15
+ export const generate_position_styles = (position = 'center', align = 'center', offset = '0') => {
16
+ const styles = {
17
+ position: 'absolute',
18
+ 'z-index': '10',
19
+ };
20
+ // Check if there's an offset to apply
21
+ const has_offset = offset !== '0';
22
+ // Set transform-origin based on position for proper animation direction
23
+ switch (position) {
24
+ case 'left':
25
+ styles.right = has_offset ? `calc(100% + ${offset})` : '100%';
26
+ styles.left = 'auto';
27
+ styles.transform = '';
28
+ styles.top = align === 'center' ? '50%' : align === 'start' ? '0' : 'auto';
29
+ styles.bottom = align === 'end' ? '0' : 'auto';
30
+ styles['transform-origin'] = 'right';
31
+ if (align === 'center')
32
+ styles.transform = 'translateY(-50%)';
33
+ break;
34
+ case 'right':
35
+ styles.left = has_offset ? `calc(100% + ${offset})` : '100%';
36
+ styles.right = 'auto';
37
+ styles.transform = '';
38
+ styles.top = align === 'center' ? '50%' : align === 'start' ? '0' : 'auto';
39
+ styles.bottom = align === 'end' ? '0' : 'auto';
40
+ styles['transform-origin'] = 'left';
41
+ if (align === 'center')
42
+ styles.transform = 'translateY(-50%)';
43
+ break;
44
+ case 'top':
45
+ styles.bottom = has_offset ? `calc(100% + ${offset})` : '100%';
46
+ styles.top = 'auto';
47
+ styles.transform = '';
48
+ styles.left = align === 'center' ? '50%' : align === 'start' ? '0' : 'auto';
49
+ styles.right = align === 'end' ? '0' : 'auto';
50
+ styles['transform-origin'] = 'bottom';
51
+ if (align === 'center')
52
+ styles.transform = 'translateX(-50%)';
53
+ break;
54
+ case 'bottom':
55
+ styles.top = has_offset ? `calc(100% + ${offset})` : '100%';
56
+ styles.bottom = 'auto';
57
+ styles.transform = '';
58
+ styles.left = align === 'center' ? '50%' : align === 'start' ? '0' : 'auto';
59
+ styles.right = align === 'end' ? '0' : 'auto';
60
+ styles['transform-origin'] = 'top';
61
+ if (align === 'center')
62
+ styles.transform = 'translateX(-50%)';
63
+ break;
64
+ case 'center':
65
+ styles.top = '50%';
66
+ styles.left = '50%';
67
+ styles.transform = 'translate(-50%, -50%)';
68
+ styles['transform-origin'] = 'center';
69
+ break;
70
+ case 'overlay':
71
+ styles.top = '0';
72
+ styles.left = '0';
73
+ styles.width = '100%';
74
+ styles.height = '100%';
75
+ styles['transform-origin'] = 'center';
76
+ break;
77
+ default:
78
+ throw new UnreachableError(position);
79
+ }
80
+ return styles;
81
+ };