@frontmcp/ui 0.6.1 → 0.6.2

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 (292) hide show
  1. package/bridge/core/bridge-factory.d.ts +1 -0
  2. package/bridge/core/bridge-factory.d.ts.map +1 -1
  3. package/bridge/index.d.ts +1 -1
  4. package/bridge/index.d.ts.map +1 -1
  5. package/bridge/index.js +39 -881
  6. package/bundler/browser-components.d.ts +42 -0
  7. package/bundler/browser-components.d.ts.map +1 -0
  8. package/bundler/bundler.d.ts +78 -4
  9. package/bundler/bundler.d.ts.map +1 -1
  10. package/bundler/index.d.ts +8 -8
  11. package/bundler/index.d.ts.map +1 -1
  12. package/bundler/index.js +1315 -1854
  13. package/bundler/types.d.ts +188 -7
  14. package/bundler/types.d.ts.map +1 -1
  15. package/esm/bridge/{index.js → index.mjs} +40 -877
  16. package/esm/bundler/{index.js → index.mjs} +1391 -1895
  17. package/esm/{index.js → index.mjs} +215 -3091
  18. package/esm/layouts/{index.js → index.mjs} +3 -3
  19. package/esm/package.json +9 -8
  20. package/esm/react/index.mjs +1183 -0
  21. package/esm/renderers/index.mjs +611 -0
  22. package/esm/universal/{index.js → index.mjs} +266 -70
  23. package/index.d.ts +1 -4
  24. package/index.d.ts.map +1 -1
  25. package/index.js +208 -3113
  26. package/layouts/base.d.ts.map +1 -1
  27. package/layouts/index.js +3 -3
  28. package/layouts/presets.d.ts.map +1 -1
  29. package/package.json +9 -8
  30. package/react/Badge.d.ts.map +1 -1
  31. package/react/hooks/context.d.ts.map +1 -1
  32. package/react/index.d.ts +0 -1
  33. package/react/index.d.ts.map +1 -1
  34. package/react/index.js +57 -2001
  35. package/react/types.d.ts.map +1 -1
  36. package/renderers/index.d.ts +9 -4
  37. package/renderers/index.d.ts.map +1 -1
  38. package/renderers/index.js +328 -88
  39. package/renderers/mdx.renderer.d.ts +99 -0
  40. package/renderers/mdx.renderer.d.ts.map +1 -0
  41. package/renderers/react.renderer.d.ts +22 -13
  42. package/renderers/react.renderer.d.ts.map +1 -1
  43. package/renderers/transpiler.d.ts +49 -0
  44. package/renderers/transpiler.d.ts.map +1 -0
  45. package/universal/cached-runtime.d.ts +25 -1
  46. package/universal/cached-runtime.d.ts.map +1 -1
  47. package/universal/index.js +266 -70
  48. package/universal/runtime-builder.d.ts.map +1 -1
  49. package/universal/types.d.ts.map +1 -1
  50. package/web-components/elements/fmcp-input.d.ts.map +1 -1
  51. package/web-components/elements/fmcp-select.d.ts.map +1 -1
  52. package/web-components/index.d.ts +0 -1
  53. package/web-components/index.d.ts.map +1 -1
  54. package/bundler/cache.d.ts +0 -173
  55. package/bundler/cache.d.ts.map +0 -1
  56. package/bundler/file-cache/component-builder.d.ts +0 -167
  57. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  58. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  59. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  60. package/bundler/file-cache/index.d.ts +0 -12
  61. package/bundler/file-cache/index.d.ts.map +0 -1
  62. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  63. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  64. package/bundler/file-cache/storage/index.d.ts +0 -11
  65. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  66. package/bundler/file-cache/storage/interface.d.ts +0 -152
  67. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  68. package/bundler/file-cache/storage/redis.d.ts +0 -139
  69. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  70. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  71. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  72. package/bundler/sandbox/executor.d.ts +0 -14
  73. package/bundler/sandbox/executor.d.ts.map +0 -1
  74. package/bundler/sandbox/policy.d.ts +0 -62
  75. package/bundler/sandbox/policy.d.ts.map +0 -1
  76. package/esm/bridge/adapters/base-adapter.d.ts +0 -104
  77. package/esm/bridge/adapters/base-adapter.d.ts.map +0 -1
  78. package/esm/bridge/adapters/claude.adapter.d.ts +0 -67
  79. package/esm/bridge/adapters/claude.adapter.d.ts.map +0 -1
  80. package/esm/bridge/adapters/ext-apps.adapter.d.ts +0 -143
  81. package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +0 -1
  82. package/esm/bridge/adapters/gemini.adapter.d.ts +0 -64
  83. package/esm/bridge/adapters/gemini.adapter.d.ts.map +0 -1
  84. package/esm/bridge/adapters/generic.adapter.d.ts +0 -56
  85. package/esm/bridge/adapters/generic.adapter.d.ts.map +0 -1
  86. package/esm/bridge/adapters/index.d.ts +0 -26
  87. package/esm/bridge/adapters/index.d.ts.map +0 -1
  88. package/esm/bridge/adapters/openai.adapter.d.ts +0 -65
  89. package/esm/bridge/adapters/openai.adapter.d.ts.map +0 -1
  90. package/esm/bridge/core/adapter-registry.d.ts +0 -122
  91. package/esm/bridge/core/adapter-registry.d.ts.map +0 -1
  92. package/esm/bridge/core/bridge-factory.d.ts +0 -199
  93. package/esm/bridge/core/bridge-factory.d.ts.map +0 -1
  94. package/esm/bridge/core/index.d.ts +0 -10
  95. package/esm/bridge/core/index.d.ts.map +0 -1
  96. package/esm/bridge/index.d.ts +0 -62
  97. package/esm/bridge/index.d.ts.map +0 -1
  98. package/esm/bridge/runtime/iife-generator.d.ts +0 -62
  99. package/esm/bridge/runtime/iife-generator.d.ts.map +0 -1
  100. package/esm/bridge/runtime/index.d.ts +0 -10
  101. package/esm/bridge/runtime/index.d.ts.map +0 -1
  102. package/esm/bridge/types.d.ts +0 -386
  103. package/esm/bridge/types.d.ts.map +0 -1
  104. package/esm/bundler/bundler.d.ts +0 -208
  105. package/esm/bundler/bundler.d.ts.map +0 -1
  106. package/esm/bundler/cache.d.ts +0 -173
  107. package/esm/bundler/cache.d.ts.map +0 -1
  108. package/esm/bundler/file-cache/component-builder.d.ts +0 -167
  109. package/esm/bundler/file-cache/component-builder.d.ts.map +0 -1
  110. package/esm/bundler/file-cache/hash-calculator.d.ts +0 -155
  111. package/esm/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  112. package/esm/bundler/file-cache/index.d.ts +0 -12
  113. package/esm/bundler/file-cache/index.d.ts.map +0 -1
  114. package/esm/bundler/file-cache/storage/filesystem.d.ts +0 -149
  115. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  116. package/esm/bundler/file-cache/storage/index.d.ts +0 -11
  117. package/esm/bundler/file-cache/storage/index.d.ts.map +0 -1
  118. package/esm/bundler/file-cache/storage/interface.d.ts +0 -152
  119. package/esm/bundler/file-cache/storage/interface.d.ts.map +0 -1
  120. package/esm/bundler/file-cache/storage/redis.d.ts +0 -139
  121. package/esm/bundler/file-cache/storage/redis.d.ts.map +0 -1
  122. package/esm/bundler/index.d.ts +0 -43
  123. package/esm/bundler/index.d.ts.map +0 -1
  124. package/esm/bundler/sandbox/enclave-adapter.d.ts +0 -121
  125. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  126. package/esm/bundler/sandbox/executor.d.ts +0 -14
  127. package/esm/bundler/sandbox/executor.d.ts.map +0 -1
  128. package/esm/bundler/sandbox/policy.d.ts +0 -62
  129. package/esm/bundler/sandbox/policy.d.ts.map +0 -1
  130. package/esm/bundler/types.d.ts +0 -702
  131. package/esm/bundler/types.d.ts.map +0 -1
  132. package/esm/components/alert.d.ts +0 -66
  133. package/esm/components/alert.d.ts.map +0 -1
  134. package/esm/components/alert.schema.d.ts +0 -98
  135. package/esm/components/alert.schema.d.ts.map +0 -1
  136. package/esm/components/avatar.d.ts +0 -77
  137. package/esm/components/avatar.d.ts.map +0 -1
  138. package/esm/components/avatar.schema.d.ts +0 -170
  139. package/esm/components/avatar.schema.d.ts.map +0 -1
  140. package/esm/components/badge.d.ts +0 -64
  141. package/esm/components/badge.d.ts.map +0 -1
  142. package/esm/components/badge.schema.d.ts +0 -91
  143. package/esm/components/badge.schema.d.ts.map +0 -1
  144. package/esm/components/button.d.ts +0 -100
  145. package/esm/components/button.d.ts.map +0 -1
  146. package/esm/components/button.schema.d.ts +0 -120
  147. package/esm/components/button.schema.d.ts.map +0 -1
  148. package/esm/components/card.d.ts +0 -53
  149. package/esm/components/card.d.ts.map +0 -1
  150. package/esm/components/card.schema.d.ts +0 -93
  151. package/esm/components/card.schema.d.ts.map +0 -1
  152. package/esm/components/form.d.ts +0 -212
  153. package/esm/components/form.d.ts.map +0 -1
  154. package/esm/components/form.schema.d.ts +0 -365
  155. package/esm/components/form.schema.d.ts.map +0 -1
  156. package/esm/components/index.d.ts +0 -29
  157. package/esm/components/index.d.ts.map +0 -1
  158. package/esm/components/list.d.ts +0 -121
  159. package/esm/components/list.d.ts.map +0 -1
  160. package/esm/components/list.schema.d.ts +0 -129
  161. package/esm/components/list.schema.d.ts.map +0 -1
  162. package/esm/components/modal.d.ts +0 -100
  163. package/esm/components/modal.d.ts.map +0 -1
  164. package/esm/components/modal.schema.d.ts +0 -151
  165. package/esm/components/modal.schema.d.ts.map +0 -1
  166. package/esm/components/table.d.ts +0 -91
  167. package/esm/components/table.d.ts.map +0 -1
  168. package/esm/components/table.schema.d.ts +0 -123
  169. package/esm/components/table.schema.d.ts.map +0 -1
  170. package/esm/index.d.ts +0 -40
  171. package/esm/index.d.ts.map +0 -1
  172. package/esm/layouts/base.d.ts +0 -86
  173. package/esm/layouts/base.d.ts.map +0 -1
  174. package/esm/layouts/index.d.ts +0 -8
  175. package/esm/layouts/index.d.ts.map +0 -1
  176. package/esm/layouts/presets.d.ts +0 -134
  177. package/esm/layouts/presets.d.ts.map +0 -1
  178. package/esm/pages/consent.d.ts +0 -117
  179. package/esm/pages/consent.d.ts.map +0 -1
  180. package/esm/pages/error.d.ts +0 -101
  181. package/esm/pages/error.d.ts.map +0 -1
  182. package/esm/pages/index.d.ts +0 -9
  183. package/esm/pages/index.d.ts.map +0 -1
  184. package/esm/pages/index.js +0 -1036
  185. package/esm/react/Alert.d.ts +0 -101
  186. package/esm/react/Alert.d.ts.map +0 -1
  187. package/esm/react/Badge.d.ts +0 -100
  188. package/esm/react/Badge.d.ts.map +0 -1
  189. package/esm/react/Button.d.ts +0 -108
  190. package/esm/react/Button.d.ts.map +0 -1
  191. package/esm/react/Card.d.ts +0 -103
  192. package/esm/react/Card.d.ts.map +0 -1
  193. package/esm/react/hooks/context.d.ts +0 -179
  194. package/esm/react/hooks/context.d.ts.map +0 -1
  195. package/esm/react/hooks/index.d.ts +0 -42
  196. package/esm/react/hooks/index.d.ts.map +0 -1
  197. package/esm/react/hooks/tools.d.ts +0 -284
  198. package/esm/react/hooks/tools.d.ts.map +0 -1
  199. package/esm/react/index.d.ts +0 -80
  200. package/esm/react/index.d.ts.map +0 -1
  201. package/esm/react/index.js +0 -3124
  202. package/esm/react/types.d.ts +0 -105
  203. package/esm/react/types.d.ts.map +0 -1
  204. package/esm/react/utils.d.ts +0 -43
  205. package/esm/react/utils.d.ts.map +0 -1
  206. package/esm/render/index.d.ts +0 -8
  207. package/esm/render/index.d.ts.map +0 -1
  208. package/esm/render/prerender.d.ts +0 -57
  209. package/esm/render/prerender.d.ts.map +0 -1
  210. package/esm/renderers/index.d.ts +0 -21
  211. package/esm/renderers/index.d.ts.map +0 -1
  212. package/esm/renderers/index.js +0 -381
  213. package/esm/renderers/react.adapter.d.ts +0 -70
  214. package/esm/renderers/react.adapter.d.ts.map +0 -1
  215. package/esm/renderers/react.renderer.d.ts +0 -96
  216. package/esm/renderers/react.renderer.d.ts.map +0 -1
  217. package/esm/universal/UniversalApp.d.ts +0 -108
  218. package/esm/universal/UniversalApp.d.ts.map +0 -1
  219. package/esm/universal/cached-runtime.d.ts +0 -115
  220. package/esm/universal/cached-runtime.d.ts.map +0 -1
  221. package/esm/universal/context.d.ts +0 -122
  222. package/esm/universal/context.d.ts.map +0 -1
  223. package/esm/universal/index.d.ts +0 -57
  224. package/esm/universal/index.d.ts.map +0 -1
  225. package/esm/universal/renderers/html.renderer.d.ts +0 -37
  226. package/esm/universal/renderers/html.renderer.d.ts.map +0 -1
  227. package/esm/universal/renderers/index.d.ts +0 -112
  228. package/esm/universal/renderers/index.d.ts.map +0 -1
  229. package/esm/universal/renderers/markdown.renderer.d.ts +0 -33
  230. package/esm/universal/renderers/markdown.renderer.d.ts.map +0 -1
  231. package/esm/universal/renderers/mdx.renderer.d.ts +0 -38
  232. package/esm/universal/renderers/mdx.renderer.d.ts.map +0 -1
  233. package/esm/universal/renderers/react.renderer.d.ts +0 -46
  234. package/esm/universal/renderers/react.renderer.d.ts.map +0 -1
  235. package/esm/universal/runtime-builder.d.ts +0 -33
  236. package/esm/universal/runtime-builder.d.ts.map +0 -1
  237. package/esm/universal/store.d.ts +0 -135
  238. package/esm/universal/store.d.ts.map +0 -1
  239. package/esm/universal/types.d.ts +0 -199
  240. package/esm/universal/types.d.ts.map +0 -1
  241. package/esm/web-components/core/attribute-parser.d.ts +0 -82
  242. package/esm/web-components/core/attribute-parser.d.ts.map +0 -1
  243. package/esm/web-components/core/base-element.d.ts +0 -197
  244. package/esm/web-components/core/base-element.d.ts.map +0 -1
  245. package/esm/web-components/core/index.d.ts +0 -9
  246. package/esm/web-components/core/index.d.ts.map +0 -1
  247. package/esm/web-components/elements/fmcp-alert.d.ts +0 -46
  248. package/esm/web-components/elements/fmcp-alert.d.ts.map +0 -1
  249. package/esm/web-components/elements/fmcp-badge.d.ts +0 -47
  250. package/esm/web-components/elements/fmcp-badge.d.ts.map +0 -1
  251. package/esm/web-components/elements/fmcp-button.d.ts +0 -117
  252. package/esm/web-components/elements/fmcp-button.d.ts.map +0 -1
  253. package/esm/web-components/elements/fmcp-card.d.ts +0 -53
  254. package/esm/web-components/elements/fmcp-card.d.ts.map +0 -1
  255. package/esm/web-components/elements/fmcp-input.d.ts +0 -96
  256. package/esm/web-components/elements/fmcp-input.d.ts.map +0 -1
  257. package/esm/web-components/elements/fmcp-select.d.ts +0 -100
  258. package/esm/web-components/elements/fmcp-select.d.ts.map +0 -1
  259. package/esm/web-components/elements/index.d.ts +0 -13
  260. package/esm/web-components/elements/index.d.ts.map +0 -1
  261. package/esm/web-components/index.d.ts +0 -50
  262. package/esm/web-components/index.d.ts.map +0 -1
  263. package/esm/web-components/register.d.ts +0 -57
  264. package/esm/web-components/register.d.ts.map +0 -1
  265. package/esm/web-components/types.d.ts +0 -122
  266. package/esm/web-components/types.d.ts.map +0 -1
  267. package/esm/widgets/index.d.ts +0 -8
  268. package/esm/widgets/index.d.ts.map +0 -1
  269. package/esm/widgets/index.js +0 -883
  270. package/esm/widgets/progress.d.ts +0 -133
  271. package/esm/widgets/progress.d.ts.map +0 -1
  272. package/esm/widgets/resource.d.ts +0 -163
  273. package/esm/widgets/resource.d.ts.map +0 -1
  274. package/pages/consent.d.ts +0 -117
  275. package/pages/consent.d.ts.map +0 -1
  276. package/pages/error.d.ts +0 -101
  277. package/pages/error.d.ts.map +0 -1
  278. package/pages/index.d.ts +0 -9
  279. package/pages/index.d.ts.map +0 -1
  280. package/pages/index.js +0 -1065
  281. package/react/utils.d.ts +0 -43
  282. package/react/utils.d.ts.map +0 -1
  283. package/widgets/index.d.ts +0 -8
  284. package/widgets/index.d.ts.map +0 -1
  285. package/widgets/index.js +0 -910
  286. package/widgets/progress.d.ts +0 -133
  287. package/widgets/progress.d.ts.map +0 -1
  288. package/widgets/resource.d.ts +0 -163
  289. package/widgets/resource.d.ts.map +0 -1
  290. /package/esm/components/{index.js → index.mjs} +0 -0
  291. /package/esm/render/{index.js → index.mjs} +0 -0
  292. /package/esm/web-components/{index.js → index.mjs} +0 -0
@@ -1,1036 +0,0 @@
1
- // libs/ui/src/layouts/base.ts
2
- import {
3
- OPENAI_PLATFORM,
4
- canUseCdn,
5
- needsInlineScripts,
6
- DEFAULT_THEME,
7
- buildThemeCss,
8
- mergeThemes,
9
- buildFontPreconnect,
10
- buildFontStylesheets,
11
- buildCdnScripts
12
- } from "@frontmcp/uipack/theme";
13
- import { escapeHtml } from "@frontmcp/uipack/utils";
14
- import { escapeHtml as escapeHtml2 } from "@frontmcp/uipack/utils";
15
- function getSizeClass(size) {
16
- const sizeMap = {
17
- xs: "max-w-sm",
18
- sm: "max-w-md",
19
- md: "max-w-lg",
20
- lg: "max-w-xl",
21
- xl: "max-w-2xl",
22
- "2xl": "max-w-3xl",
23
- "3xl": "max-w-4xl",
24
- full: "max-w-full"
25
- };
26
- return sizeMap[size];
27
- }
28
- function getAlignmentClasses(alignment) {
29
- const alignMap = {
30
- center: "min-h-screen flex items-center justify-center",
31
- top: "min-h-screen flex flex-col items-center pt-12",
32
- start: "min-h-screen"
33
- };
34
- return alignMap[alignment];
35
- }
36
- function getBackgroundClasses(background, theme) {
37
- switch (background) {
38
- case "gradient":
39
- return "bg-gradient-to-br from-primary to-secondary";
40
- case "pattern":
41
- return 'bg-surface bg-[url("data:image/svg+xml,...")]';
42
- // Pattern would be defined
43
- case "solid":
44
- return "bg-background";
45
- case "none":
46
- default:
47
- return "";
48
- }
49
- }
50
- function buildMetaTags(options) {
51
- const tags = [];
52
- if (options.description) {
53
- tags.push(`<meta name="description" content="${escapeHtml(options.description)}">`);
54
- }
55
- if (options.og) {
56
- if (options.og.title) {
57
- tags.push(`<meta property="og:title" content="${escapeHtml(options.og.title)}">`);
58
- }
59
- if (options.og.description) {
60
- tags.push(`<meta property="og:description" content="${escapeHtml(options.og.description)}">`);
61
- }
62
- if (options.og.image) {
63
- tags.push(`<meta property="og:image" content="${escapeHtml(options.og.image)}">`);
64
- }
65
- if (options.og.type) {
66
- tags.push(`<meta property="og:type" content="${escapeHtml(options.og.type)}">`);
67
- }
68
- }
69
- if (options.favicon) {
70
- tags.push(`<link rel="icon" href="${escapeHtml(options.favicon)}">`);
71
- }
72
- return tags.join("\n ");
73
- }
74
- function buildBodyAttrs(attrs) {
75
- if (!attrs) return "";
76
- return Object.entries(attrs).map(([key, value]) => `${key}="${escapeHtml(value)}"`).join(" ");
77
- }
78
- function baseLayout(content, options) {
79
- const {
80
- title,
81
- pageType = "custom",
82
- size = "md",
83
- alignment = "center",
84
- background = "solid",
85
- platform = OPENAI_PLATFORM,
86
- theme: themeOverrides,
87
- includeHtmx,
88
- includeAlpine = false,
89
- includeIcons = false,
90
- headExtra = "",
91
- bodyAttrs,
92
- bodyClass = "",
93
- titleSuffix = "FrontMCP"
94
- } = options;
95
- const theme = themeOverrides ? mergeThemes(DEFAULT_THEME, themeOverrides) : DEFAULT_THEME;
96
- const shouldIncludeHtmx = includeHtmx ?? platform.supportsHtmx;
97
- const useCdn = canUseCdn(platform);
98
- const useInline = needsInlineScripts(platform);
99
- const fontPreconnect = useCdn ? buildFontPreconnect() : "";
100
- const fontStylesheets = useCdn ? buildFontStylesheets({ inter: true }) : "";
101
- const scripts = buildCdnScripts({
102
- tailwind: platform.supportsTailwind,
103
- htmx: shouldIncludeHtmx,
104
- alpine: includeAlpine,
105
- icons: includeIcons,
106
- inline: useInline
107
- });
108
- const themeCss = buildThemeCss(theme);
109
- const customCss = theme.customCss || "";
110
- const styleBlock = platform.supportsTailwind ? `<style type="text/tailwindcss">
111
- @theme {
112
- ${themeCss}
113
- }
114
- ${customCss}
115
- </style>` : "";
116
- const sizeClass = getSizeClass(size);
117
- const alignmentClasses = getAlignmentClasses(alignment);
118
- const backgroundClasses = getBackgroundClasses(background, theme);
119
- const allBodyClasses = [backgroundClasses, "font-sans antialiased", bodyClass].filter(Boolean).join(" ");
120
- const metaTags = buildMetaTags(options);
121
- const bodyAttrStr = buildBodyAttrs(bodyAttrs);
122
- const wrappedContent = alignment === "center" ? `<div class="${alignmentClasses} p-4">
123
- <div class="w-full ${sizeClass}">
124
- ${content}
125
- </div>
126
- </div>` : `<div class="${alignmentClasses}">
127
- <div class="w-full ${sizeClass} mx-auto px-4 py-8">
128
- ${content}
129
- </div>
130
- </div>`;
131
- return `<!DOCTYPE html>
132
- <html lang="en">
133
- <head>
134
- <meta charset="UTF-8">
135
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
136
- <title>${escapeHtml(title)}${titleSuffix ? ` - ${escapeHtml(titleSuffix)}` : ""}</title>
137
- ${metaTags}
138
-
139
- <!-- Fonts -->
140
- ${fontPreconnect}
141
- ${fontStylesheets}
142
-
143
- <!-- Tailwind CSS -->
144
- ${scripts}
145
- ${styleBlock}
146
-
147
- ${headExtra}
148
- </head>
149
- <body class="${escapeHtml(allBodyClasses)}"${bodyAttrStr ? ` ${bodyAttrStr}` : ""}>
150
- ${wrappedContent}
151
- </body>
152
- </html>`;
153
- }
154
- function createLayoutBuilder(defaults) {
155
- return (content, options = {}) => {
156
- let mergedTheme = DEFAULT_THEME;
157
- if (defaults.theme) {
158
- mergedTheme = mergeThemes(mergedTheme, defaults.theme);
159
- }
160
- if (options.theme) {
161
- mergedTheme = mergeThemes(mergedTheme, options.theme);
162
- }
163
- const merged = {
164
- ...defaults,
165
- ...options,
166
- theme: mergedTheme
167
- };
168
- if (!merged.title) {
169
- throw new Error("createLayoutBuilder: title is required either in defaults or options");
170
- }
171
- return baseLayout(content, merged);
172
- };
173
- }
174
-
175
- // libs/ui/src/layouts/presets.ts
176
- function consentLayout(content, options) {
177
- const { clientName, clientIcon, userInfo, ...baseOptions } = options;
178
- const headerHtml = clientName ? `<div class="text-center mb-6">
179
- ${clientIcon ? `<img src="${escapeHtml2(clientIcon)}" alt="${escapeHtml2(
180
- clientName
181
- )}" class="w-16 h-16 rounded-xl mx-auto mb-4">` : `<div class="inline-flex items-center justify-center w-16 h-16 rounded-xl bg-gradient-to-br from-primary to-secondary text-white font-bold text-2xl mx-auto mb-4">
182
- ${escapeHtml2(clientName.charAt(0).toUpperCase())}
183
- </div>`}
184
- <h1 class="text-2xl font-bold text-text-primary">${escapeHtml2(clientName)}</h1>
185
- </div>` : "";
186
- const userInfoHtml = userInfo ? `<div class="flex items-center gap-3 p-3 bg-gray-50 rounded-lg mb-6">
187
- ${userInfo.avatar ? `<img src="${escapeHtml2(userInfo.avatar)}" class="w-10 h-10 rounded-full">` : `<div class="w-10 h-10 rounded-full bg-primary text-white flex items-center justify-center font-medium">
188
- ${escapeHtml2((userInfo.name || userInfo.email || "U").charAt(0).toUpperCase())}
189
- </div>`}
190
- <div>
191
- ${userInfo.name ? `<div class="font-medium text-text-primary">${escapeHtml2(userInfo.name)}</div>` : ""}
192
- ${userInfo.email ? `<div class="text-sm text-text-secondary">${escapeHtml2(userInfo.email)}</div>` : ""}
193
- </div>
194
- </div>` : "";
195
- const wrappedContent = `
196
- ${headerHtml}
197
- ${userInfoHtml}
198
- ${content}
199
- `;
200
- return baseLayout(wrappedContent, {
201
- ...baseOptions,
202
- pageType: "consent",
203
- size: baseOptions.size ?? "lg",
204
- alignment: "top",
205
- background: "solid"
206
- });
207
- }
208
- function errorLayout(content, options) {
209
- const {
210
- errorCode,
211
- errorTitle = "Something went wrong",
212
- errorMessage,
213
- showRetry = true,
214
- retryUrl,
215
- showHome = true,
216
- homeUrl = "/",
217
- ...baseOptions
218
- } = options;
219
- const errorHtml = `
220
- <div class="text-center">
221
- <!-- Error icon -->
222
- <div class="inline-flex items-center justify-center w-20 h-20 rounded-full bg-danger/10 mb-6">
223
- <svg class="w-10 h-10 text-danger" fill="none" stroke="currentColor" viewBox="0 0 24 24">
224
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
225
- </svg>
226
- </div>
227
-
228
- ${errorCode ? `<p class="text-6xl font-bold text-danger mb-2">${escapeHtml2(errorCode)}</p>` : ""}
229
- <h1 class="text-2xl font-bold text-text-primary mb-4">${escapeHtml2(errorTitle)}</h1>
230
- ${errorMessage ? `<p class="text-text-secondary mb-8">${escapeHtml2(errorMessage)}</p>` : ""}
231
-
232
- ${content}
233
-
234
- <div class="flex gap-4 justify-center mt-8">
235
- ${showRetry ? `<button onclick="${retryUrl ? `window.location.href='${escapeHtml2(retryUrl)}'` : "window.location.reload()"}" class="px-6 py-3 bg-primary hover:bg-primary/90 text-white font-medium rounded-lg transition-colors">Try Again</button>` : ""}
236
- ${showHome ? `<a href="${escapeHtml2(
237
- homeUrl
238
- )}" class="px-6 py-3 bg-gray-100 hover:bg-gray-200 text-text-primary font-medium rounded-lg transition-colors">Go Home</a>` : ""}
239
- </div>
240
- </div>
241
- `;
242
- return baseLayout(errorHtml, {
243
- ...baseOptions,
244
- pageType: "error",
245
- size: "sm",
246
- alignment: "center",
247
- background: "solid",
248
- title: baseOptions.title ?? errorTitle
249
- });
250
- }
251
- var authLayoutBuilder = createLayoutBuilder({
252
- pageType: "auth",
253
- size: "sm",
254
- alignment: "center",
255
- background: "gradient"
256
- });
257
- var consentLayoutBuilder = createLayoutBuilder({
258
- pageType: "consent",
259
- size: "lg",
260
- alignment: "top",
261
- background: "solid"
262
- });
263
- var errorLayoutBuilder = createLayoutBuilder({
264
- pageType: "error",
265
- size: "sm",
266
- alignment: "center",
267
- background: "solid"
268
- });
269
-
270
- // libs/ui/src/components/button.ts
271
- import { validateOptions } from "@frontmcp/uipack/validation";
272
-
273
- // libs/ui/src/components/button.schema.ts
274
- import { z } from "zod";
275
- var ButtonVariantSchema = z.enum(["primary", "secondary", "outline", "ghost", "danger", "success", "link"]);
276
- var ButtonSizeSchema = z.enum(["xs", "sm", "md", "lg", "xl"]);
277
- var ButtonOptionsSchema = z.object({
278
- /** Button variant */
279
- variant: ButtonVariantSchema.optional(),
280
- /** Button size */
281
- size: ButtonSizeSchema.optional(),
282
- /** Button type attribute */
283
- type: z.enum(["button", "submit", "reset"]).optional(),
284
- /** Disabled state */
285
- disabled: z.boolean().optional(),
286
- /** Loading state */
287
- loading: z.boolean().optional(),
288
- /** Full width */
289
- fullWidth: z.boolean().optional(),
290
- /** Icon before text (HTML string) */
291
- iconBefore: z.string().optional(),
292
- /** Icon after text (HTML string) */
293
- iconAfter: z.string().optional(),
294
- /** Icon only (no text) */
295
- iconOnly: z.boolean().optional(),
296
- /** Additional CSS classes */
297
- className: z.string().optional(),
298
- /** Button ID */
299
- id: z.string().optional(),
300
- /** Name attribute */
301
- name: z.string().optional(),
302
- /** Value attribute */
303
- value: z.string().optional(),
304
- /** Click handler (URL for links) */
305
- href: z.string().optional(),
306
- /** Open in new tab */
307
- target: z.enum(["_blank", "_self"]).optional(),
308
- /** Data attributes */
309
- data: z.record(z.string(), z.string()).optional(),
310
- /** ARIA label */
311
- ariaLabel: z.string().optional()
312
- }).strict();
313
- var ButtonGroupOptionsSchema = z.object({
314
- /** Attach buttons visually */
315
- attached: z.boolean().optional(),
316
- /** Direction */
317
- direction: z.enum(["horizontal", "vertical"]).optional(),
318
- /** Gap between buttons */
319
- gap: z.enum(["sm", "md", "lg"]).optional(),
320
- /** Additional CSS classes */
321
- className: z.string().optional()
322
- }).strict();
323
-
324
- // libs/ui/src/components/button.ts
325
- function getVariantClasses(variant) {
326
- const variants = {
327
- primary: "bg-primary hover:bg-primary/90 text-white shadow-sm",
328
- secondary: "bg-secondary hover:bg-secondary/90 text-white shadow-sm",
329
- outline: "border-2 border-primary text-primary hover:bg-primary/10",
330
- ghost: "text-text-primary hover:bg-gray-100",
331
- danger: "bg-danger hover:bg-danger/90 text-white shadow-sm",
332
- success: "bg-success hover:bg-success/90 text-white shadow-sm",
333
- link: "text-primary hover:text-primary/80 hover:underline"
334
- };
335
- return variants[variant];
336
- }
337
- function getSizeClasses(size, iconOnly) {
338
- if (iconOnly) {
339
- const iconSizes = {
340
- xs: "p-1.5",
341
- sm: "p-2",
342
- md: "p-2.5",
343
- lg: "p-3",
344
- xl: "p-4"
345
- };
346
- return iconSizes[size];
347
- }
348
- const sizes = {
349
- xs: "px-2.5 py-1.5 text-xs",
350
- sm: "px-3 py-2 text-sm",
351
- md: "px-4 py-2.5 text-sm",
352
- lg: "px-5 py-3 text-base",
353
- xl: "px-6 py-3.5 text-lg"
354
- };
355
- return sizes[size];
356
- }
357
- function sanitizeDataKey(key) {
358
- const sanitized = key.toLowerCase().replace(/[^a-z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
359
- if (!sanitized) {
360
- console.warn(`[frontmcp/ui] Dropping invalid data-* key: "${key}"`);
361
- return null;
362
- }
363
- return sanitized;
364
- }
365
- var loadingSpinner = `<svg class="animate-spin -ml-1 mr-2 h-4 w-4" fill="none" viewBox="0 0 24 24">
366
- <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
367
- <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
368
- </svg>`;
369
- function isValidHrefProtocol(href) {
370
- const trimmed = href.trim().toLowerCase();
371
- return trimmed.startsWith("http://") || trimmed.startsWith("https://") || trimmed.startsWith("/") || trimmed.startsWith("#") || trimmed.startsWith("mailto:") || trimmed.startsWith("tel:");
372
- }
373
- function button(text, options = {}) {
374
- const validation = validateOptions(options, {
375
- schema: ButtonOptionsSchema,
376
- componentName: "button"
377
- });
378
- if (!validation.success) {
379
- return validation.error;
380
- }
381
- const validatedOptions = validation.data;
382
- const {
383
- variant = "primary",
384
- size = "md",
385
- type = "button",
386
- disabled = false,
387
- loading = false,
388
- fullWidth = false,
389
- iconBefore,
390
- iconAfter,
391
- iconOnly = false,
392
- className = "",
393
- id,
394
- name,
395
- value,
396
- href,
397
- target,
398
- data,
399
- ariaLabel
400
- } = validatedOptions;
401
- if (!iconOnly && !text.trim()) {
402
- console.warn("[frontmcp/ui] Button has empty text. Consider providing text or using iconOnly with ariaLabel.");
403
- }
404
- if (iconOnly && !ariaLabel && !text.trim()) {
405
- console.warn(
406
- "[frontmcp/ui] iconOnly button requires non-empty text or ariaLabel for accessibility; control will have no label."
407
- );
408
- }
409
- if (href && !isValidHrefProtocol(href)) {
410
- console.warn(`[frontmcp/ui] Button href contains potentially dangerous protocol: "${href.slice(0, 20)}..."`);
411
- }
412
- const variantClasses = getVariantClasses(variant);
413
- const sizeClasses = getSizeClasses(size, iconOnly);
414
- const safeClassName = className ? escapeHtml2(className) : "";
415
- const baseClasses = [
416
- "inline-flex items-center justify-center",
417
- "font-medium",
418
- "rounded-lg",
419
- "transition-colors duration-200",
420
- "focus:outline-none focus:ring-2 focus:ring-primary/50 focus:ring-offset-2",
421
- disabled || loading ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
422
- fullWidth ? "w-full" : "",
423
- variantClasses,
424
- sizeClasses,
425
- safeClassName
426
- ].filter(Boolean).join(" ");
427
- const dataAttrs = data ? Object.entries(data).map(([key, val]) => {
428
- const safeKey = sanitizeDataKey(key);
429
- return safeKey ? `data-${safeKey}="${escapeHtml2(val)}"` : "";
430
- }).filter(Boolean).join(" ") : "";
431
- const idAttr = id ? `id="${escapeHtml2(id)}"` : "";
432
- const nameAttr = name ? `name="${escapeHtml2(name)}"` : "";
433
- const valueAttr = value ? `value="${escapeHtml2(value)}"` : "";
434
- const disabledAttr = disabled || loading ? "disabled" : "";
435
- const targetAttr = target ? `target="${escapeHtml2(target)}"` : "";
436
- const relAttr = target === "_blank" ? 'rel="noopener noreferrer"' : "";
437
- const trimmedText = text.trim();
438
- const effectiveAriaLabel = ariaLabel ?? (iconOnly && trimmedText ? trimmedText : void 0);
439
- const ariaLabelAttr = effectiveAriaLabel ? `aria-label="${escapeHtml2(effectiveAriaLabel)}"` : "";
440
- const iconBeforeHtml = iconBefore && !loading ? `<span class="${iconOnly ? "" : "mr-2"}">${iconBefore}</span>` : "";
441
- const iconAfterHtml = iconAfter && !loading ? `<span class="${iconOnly ? "" : "ml-2"}">${iconAfter}</span>` : "";
442
- const loadingHtml = loading ? loadingSpinner : "";
443
- const textHtml = iconOnly ? "" : escapeHtml2(text);
444
- const contentHtml = `${loadingHtml}${iconBeforeHtml}${textHtml}${iconAfterHtml}`;
445
- if (href && !disabled && !loading && isValidHrefProtocol(href)) {
446
- return `<a href="${escapeHtml2(
447
- href
448
- )}" class="${baseClasses}" ${idAttr} ${dataAttrs} ${ariaLabelAttr} ${targetAttr} ${relAttr}>
449
- ${contentHtml}
450
- </a>`;
451
- }
452
- return `<button type="${type}" class="${baseClasses}" ${idAttr} ${nameAttr} ${valueAttr} ${disabledAttr} ${dataAttrs} ${ariaLabelAttr}>
453
- ${contentHtml}
454
- </button>`;
455
- }
456
- var primaryButton = (text, opts) => button(text, { ...opts, variant: "primary" });
457
- var outlineButton = (text, opts) => button(text, { ...opts, variant: "outline" });
458
-
459
- // libs/ui/src/components/list.ts
460
- var permissionIcons = {
461
- read: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
462
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
463
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
464
- </svg>`,
465
- write: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
466
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
467
- </svg>`,
468
- delete: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
469
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
470
- </svg>`,
471
- profile: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
472
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
473
- </svg>`,
474
- email: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
475
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
476
- </svg>`,
477
- settings: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
478
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
479
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
480
- </svg>`,
481
- default: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
482
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/>
483
- </svg>`
484
- };
485
- function getPermissionIcon(scope, customIcon) {
486
- if (customIcon) return customIcon;
487
- const scopeLower = scope.toLowerCase();
488
- if (scopeLower.includes("read")) return permissionIcons["read"];
489
- if (scopeLower.includes("write") || scopeLower.includes("create") || scopeLower.includes("update"))
490
- return permissionIcons["write"];
491
- if (scopeLower.includes("delete")) return permissionIcons["delete"];
492
- if (scopeLower.includes("profile")) return permissionIcons["profile"];
493
- if (scopeLower.includes("email")) return permissionIcons["email"];
494
- if (scopeLower.includes("settings") || scopeLower.includes("config")) return permissionIcons["settings"];
495
- return permissionIcons["default"];
496
- }
497
- function permissionList(permissions, options = {}) {
498
- const { id, checkable = false, inputName = "scopes", title, className = "" } = options;
499
- const titleHtml = title ? `<h4 class="font-medium text-text-primary mb-3">${escapeHtml2(title)}</h4>` : "";
500
- const itemsHtml = permissions.map((perm, index) => {
501
- const icon = getPermissionIcon(perm.scope, perm.icon);
502
- const sensitiveClasses = perm.sensitive ? "border-warning/30 bg-warning/5" : "border-border";
503
- const sensitiveLabel = perm.sensitive ? '<span class="text-xs text-warning font-medium ml-2">Sensitive</span>' : "";
504
- const checkboxHtml = checkable ? `<input
505
- type="checkbox"
506
- name="${escapeHtml2(inputName)}[]"
507
- value="${escapeHtml2(perm.scope)}"
508
- class="w-4 h-4 rounded border-border text-primary focus:ring-primary/20"
509
- ${perm.checked || perm.required ? "checked" : ""}
510
- ${perm.required ? "disabled" : ""}
511
- id="${id ? escapeHtml2(id) : "perm"}-${index}"
512
- >` : `<div class="w-5 h-5 rounded-full bg-success/10 text-success flex items-center justify-center">
513
- <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
514
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M5 13l4 4L19 7"/>
515
- </svg>
516
- </div>`;
517
- return `<div class="flex items-start gap-3 p-3 border ${sensitiveClasses} rounded-lg">
518
- <div class="flex-shrink-0 mt-0.5 text-text-secondary">
519
- ${icon}
520
- </div>
521
- <div class="flex-1 min-w-0">
522
- <div class="flex items-center">
523
- <span class="font-medium text-text-primary">${escapeHtml2(perm.name)}</span>
524
- ${perm.required ? '<span class="text-xs text-text-secondary ml-2">(Required)</span>' : ""}
525
- ${sensitiveLabel}
526
- </div>
527
- ${perm.description ? `<p class="text-sm text-text-secondary mt-0.5">${escapeHtml2(perm.description)}</p>` : ""}
528
- </div>
529
- <div class="flex-shrink-0">
530
- ${checkboxHtml}
531
- </div>
532
- </div>`;
533
- }).join("\n");
534
- const idAttr = id ? `id="${escapeHtml2(id)}"` : "";
535
- return `<div class="permission-list ${className}" ${idAttr}>
536
- ${titleHtml}
537
- <div class="space-y-2">
538
- ${itemsHtml}
539
- </div>
540
- </div>`;
541
- }
542
-
543
- // libs/ui/src/components/form.ts
544
- function hiddenInput(name, value) {
545
- return `<input type="hidden" name="${escapeHtml2(name)}" value="${escapeHtml2(value)}">`;
546
- }
547
- function csrfInput(token) {
548
- return hiddenInput("_csrf", token);
549
- }
550
-
551
- // libs/ui/src/components/alert.ts
552
- var alertIcons = {
553
- info: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
554
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
555
- </svg>`,
556
- success: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
557
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
558
- </svg>`,
559
- warning: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
560
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
561
- </svg>`,
562
- danger: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
563
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"/>
564
- </svg>`,
565
- neutral: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
566
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
567
- </svg>`
568
- };
569
- function getVariantClasses2(variant) {
570
- const variants = {
571
- info: {
572
- container: "bg-blue-50 border-blue-200 text-blue-800",
573
- icon: "text-blue-500"
574
- },
575
- success: {
576
- container: "bg-success/10 border-success/30 text-success",
577
- icon: "text-success"
578
- },
579
- warning: {
580
- container: "bg-warning/10 border-warning/30 text-warning",
581
- icon: "text-warning"
582
- },
583
- danger: {
584
- container: "bg-danger/10 border-danger/30 text-danger",
585
- icon: "text-danger"
586
- },
587
- neutral: {
588
- container: "bg-gray-50 border-gray-200 text-gray-800",
589
- icon: "text-gray-500"
590
- }
591
- };
592
- return variants[variant];
593
- }
594
- function alert(message, options = {}) {
595
- const { variant = "info", title, showIcon = true, icon, dismissible = false, className = "", id, actions } = options;
596
- const variantClasses = getVariantClasses2(variant);
597
- const baseClasses = ["rounded-lg border p-4", variantClasses.container, className].filter(Boolean).join(" ");
598
- const iconHtml = showIcon ? `<div class="flex-shrink-0 ${variantClasses.icon}">
599
- ${icon || alertIcons[variant]}
600
- </div>` : "";
601
- const titleHtml = title ? `<h3 class="font-semibold">${escapeHtml2(title)}</h3>` : "";
602
- const dismissHtml = dismissible ? `<button
603
- type="button"
604
- class="flex-shrink-0 ml-auto -mr-1 -mt-1 p-1 rounded hover:bg-black/5 transition-colors"
605
- onclick="this.closest('.alert').remove()"
606
- aria-label="Dismiss"
607
- >
608
- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
609
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
610
- </svg>
611
- </button>` : "";
612
- const actionsHtml = actions ? `<div class="mt-3">${actions}</div>` : "";
613
- const idAttr = id ? `id="${escapeHtml2(id)}"` : "";
614
- return `<div class="alert ${baseClasses}" role="alert" ${idAttr}>
615
- <div class="flex gap-3">
616
- ${iconHtml}
617
- <div class="flex-1">
618
- ${titleHtml}
619
- <div class="${title ? "mt-1" : ""}">${escapeHtml2(message)}</div>
620
- ${actionsHtml}
621
- </div>
622
- ${dismissHtml}
623
- </div>
624
- </div>`;
625
- }
626
-
627
- // libs/ui/src/pages/consent.ts
628
- function consentPage(options) {
629
- const {
630
- client,
631
- user,
632
- permissions,
633
- approveUrl,
634
- denyUrl,
635
- csrfToken,
636
- state,
637
- redirectUri,
638
- responseType,
639
- nonce,
640
- codeChallenge,
641
- codeChallengeMethod,
642
- error,
643
- layout = {},
644
- warningMessage,
645
- allowScopeSelection = false,
646
- approveText = "Allow",
647
- denyText = "Deny"
648
- } = options;
649
- const errorAlert = error ? alert(error, { variant: "danger", dismissible: true }) : "";
650
- const unverifiedWarning = !client.verified ? alert(warningMessage || "This application has not been verified. Only authorize applications you trust.", {
651
- variant: "warning",
652
- title: "Unverified Application"
653
- }) : "";
654
- const clientHeader = `
655
- <div class="text-center mb-6">
656
- ${client.icon ? `<img src="${escapeHtml2(client.icon)}" alt="${escapeHtml2(
657
- client.name
658
- )}" class="w-16 h-16 rounded-xl mx-auto mb-4 shadow-md">` : `<div class="inline-flex items-center justify-center w-16 h-16 rounded-xl bg-gradient-to-br from-primary to-secondary text-white font-bold text-2xl mx-auto mb-4 shadow-md">
659
- ${escapeHtml2(client.name.charAt(0).toUpperCase())}
660
- </div>`}
661
- <h1 class="text-xl font-bold text-text-primary">
662
- ${client.verified ? `<span class="inline-flex items-center gap-1">
663
- ${escapeHtml2(client.name)}
664
- <svg class="w-5 h-5 text-primary" fill="currentColor" viewBox="0 0 20 20">
665
- <path fill-rule="evenodd" d="M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44 5.252a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
666
- </svg>
667
- </span>` : escapeHtml2(client.name)}
668
- </h1>
669
- <p class="text-text-secondary mt-1">wants to access your account</p>
670
- </div>
671
- `;
672
- const userSection = user ? `
673
- <div class="flex items-center gap-3 p-4 bg-gray-50 rounded-lg mb-6">
674
- ${user.avatar ? `<img src="${escapeHtml2(user.avatar)}" class="w-12 h-12 rounded-full">` : `<div class="w-12 h-12 rounded-full bg-primary text-white flex items-center justify-center font-semibold text-lg">
675
- ${escapeHtml2((user.name || user.email || "U").charAt(0).toUpperCase())}
676
- </div>`}
677
- <div class="flex-1 min-w-0">
678
- ${user.name ? `<div class="font-medium text-text-primary truncate">${escapeHtml2(user.name)}</div>` : ""}
679
- ${user.email ? `<div class="text-sm text-text-secondary truncate">${escapeHtml2(user.email)}</div>` : ""}
680
- </div>
681
- <a href="/login?prompt=select_account" class="text-sm text-primary hover:text-primary/80">
682
- Switch account
683
- </a>
684
- </div>
685
- ` : "";
686
- const permissionsSection = `
687
- <div class="mb-6">
688
- <h3 class="font-medium text-text-primary mb-3">This will allow ${escapeHtml2(client.name)} to:</h3>
689
- ${permissionList(permissions, {
690
- checkable: allowScopeSelection,
691
- inputName: "scope"
692
- })}
693
- </div>
694
- `;
695
- const hiddenFields = [
696
- csrfToken ? csrfInput(csrfToken) : "",
697
- state ? hiddenInput("state", state) : "",
698
- redirectUri ? hiddenInput("redirect_uri", redirectUri) : "",
699
- responseType ? hiddenInput("response_type", responseType) : "",
700
- nonce ? hiddenInput("nonce", nonce) : "",
701
- codeChallenge ? hiddenInput("code_challenge", codeChallenge) : "",
702
- codeChallengeMethod ? hiddenInput("code_challenge_method", codeChallengeMethod) : "",
703
- hiddenInput("client_id", client.clientId),
704
- // Include all scopes if not selectable
705
- !allowScopeSelection ? permissions.map((p) => hiddenInput("scope[]", p.scope)).join("\n") : ""
706
- ].filter(Boolean).join("\n");
707
- const actionsHtml = `
708
- <div class="flex gap-3 pt-4">
709
- <form action="${escapeHtml2(denyUrl || approveUrl)}" method="post" class="flex-1">
710
- ${hiddenFields}
711
- <input type="hidden" name="action" value="deny">
712
- ${outlineButton(denyText, { type: "submit", fullWidth: true })}
713
- </form>
714
- <form action="${escapeHtml2(approveUrl)}" method="post" class="flex-1">
715
- ${hiddenFields}
716
- <input type="hidden" name="action" value="approve">
717
- ${primaryButton(approveText, { type: "submit", fullWidth: true })}
718
- </form>
719
- </div>
720
- `;
721
- const linksHtml = client.privacyUrl || client.termsUrl || client.websiteUrl ? `
722
- <div class="text-center text-xs text-text-secondary mt-6 space-x-3">
723
- ${client.websiteUrl ? `<a href="${escapeHtml2(
724
- client.websiteUrl
725
- )}" target="_blank" rel="noopener" class="hover:text-primary">Website</a>` : ""}
726
- ${client.privacyUrl ? `<a href="${escapeHtml2(
727
- client.privacyUrl
728
- )}" target="_blank" rel="noopener" class="hover:text-primary">Privacy Policy</a>` : ""}
729
- ${client.termsUrl ? `<a href="${escapeHtml2(
730
- client.termsUrl
731
- )}" target="_blank" rel="noopener" class="hover:text-primary">Terms of Service</a>` : ""}
732
- </div>
733
- ` : "";
734
- const content = `
735
- ${errorAlert}
736
- ${unverifiedWarning}
737
- ${clientHeader}
738
- ${userSection}
739
- ${permissionsSection}
740
- ${actionsHtml}
741
- ${linksHtml}
742
- `;
743
- return consentLayout(content, {
744
- title: `Authorize ${client.name}`,
745
- clientName: client.name,
746
- clientIcon: client.icon,
747
- userInfo: user,
748
- ...layout
749
- });
750
- }
751
- function consentSuccessPage(options) {
752
- const { client, redirectUrl, autoRedirectDelay = 3e3, layout = {} } = options;
753
- const redirectScript = redirectUrl && autoRedirectDelay > 0 ? `
754
- <script>
755
- setTimeout(() => {
756
- window.location.href = '${escapeHtml2(redirectUrl)}';
757
- }, ${autoRedirectDelay});
758
- </script>
759
- ` : "";
760
- const content = `
761
- <div class="text-center">
762
- <div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-success/10 mb-6">
763
- <svg class="w-8 h-8 text-success" fill="none" stroke="currentColor" viewBox="0 0 24 24">
764
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
765
- </svg>
766
- </div>
767
- <h1 class="text-2xl font-bold text-text-primary mb-2">Authorization Successful</h1>
768
- <p class="text-text-secondary mb-4">
769
- You have authorized <strong>${escapeHtml2(client.name)}</strong> to access your account.
770
- </p>
771
- ${redirectUrl ? `<p class="text-sm text-text-secondary">Redirecting you back to ${escapeHtml2(client.name)}...</p>` : ""}
772
- </div>
773
- ${redirectScript}
774
- `;
775
- return consentLayout(content, {
776
- title: "Authorization Successful",
777
- clientName: client.name,
778
- clientIcon: client.icon,
779
- ...layout
780
- });
781
- }
782
- function consentDeniedPage(options) {
783
- const { client, redirectUrl, layout = {} } = options;
784
- const content = `
785
- <div class="text-center">
786
- <div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-gray-100 mb-6">
787
- <svg class="w-8 h-8 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
788
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
789
- </svg>
790
- </div>
791
- <h1 class="text-2xl font-bold text-text-primary mb-2">Authorization Denied</h1>
792
- <p class="text-text-secondary mb-6">
793
- You denied <strong>${escapeHtml2(client.name)}</strong> access to your account.
794
- </p>
795
- ${redirectUrl ? `
796
- <a href="${escapeHtml2(
797
- redirectUrl
798
- )}" class="inline-block px-6 py-3 bg-primary hover:bg-primary/90 text-white font-medium rounded-lg transition-colors">
799
- Return to ${escapeHtml2(client.name)}
800
- </a>
801
- ` : ""}
802
- </div>
803
- `;
804
- return consentLayout(content, {
805
- title: "Authorization Denied",
806
- clientName: client.name,
807
- clientIcon: client.icon,
808
- ...layout
809
- });
810
- }
811
-
812
- // libs/ui/src/pages/error.ts
813
- function errorPage(options) {
814
- const {
815
- code,
816
- title = "Something went wrong",
817
- message,
818
- details,
819
- showStack = false,
820
- stack,
821
- showRetry = true,
822
- retryUrl,
823
- showHome = true,
824
- homeUrl = "/",
825
- showBack = false,
826
- actions,
827
- layout = {},
828
- requestId
829
- } = options;
830
- const detailsHtml = details || showStack && stack ? `
831
- <div class="mt-8 text-left">
832
- ${details ? `
833
- <div class="p-4 bg-gray-50 rounded-lg text-sm text-text-secondary mb-4">
834
- <strong class="text-text-primary">Details:</strong>
835
- <p class="mt-1">${escapeHtml2(details)}</p>
836
- </div>
837
- ` : ""}
838
- ${showStack && stack ? `
839
- <details class="p-4 bg-gray-900 rounded-lg text-sm">
840
- <summary class="text-gray-300 cursor-pointer hover:text-white">Stack Trace</summary>
841
- <pre class="mt-2 text-xs text-gray-400 overflow-x-auto whitespace-pre-wrap">${escapeHtml2(stack)}</pre>
842
- </details>
843
- ` : ""}
844
- </div>
845
- ` : "";
846
- const requestIdHtml = requestId ? `
847
- <p class="text-xs text-text-secondary mt-6">
848
- Request ID: <code class="px-1.5 py-0.5 bg-gray-100 rounded text-xs">${escapeHtml2(requestId)}</code>
849
- </p>
850
- ` : "";
851
- const content = `
852
- ${detailsHtml}
853
- ${actions || ""}
854
- ${requestIdHtml}
855
- `;
856
- return errorLayout(content, {
857
- title: `${code ? `Error ${code} - ` : ""}${title}`,
858
- errorCode: code?.toString(),
859
- errorTitle: title,
860
- errorMessage: message,
861
- showRetry,
862
- retryUrl,
863
- showHome,
864
- homeUrl,
865
- ...layout
866
- });
867
- }
868
- function notFoundPage(options = {}) {
869
- return errorPage({
870
- code: 404,
871
- title: "Page Not Found",
872
- message: "The page you're looking for doesn't exist or has been moved.",
873
- showRetry: false,
874
- ...options
875
- });
876
- }
877
- function forbiddenPage(options = {}) {
878
- return errorPage({
879
- code: 403,
880
- title: "Access Denied",
881
- message: "You don't have permission to access this resource.",
882
- showRetry: false,
883
- ...options
884
- });
885
- }
886
- function unauthorizedPage(options = {}) {
887
- const { loginUrl = "/login", ...rest } = options;
888
- return errorPage({
889
- code: 401,
890
- title: "Authentication Required",
891
- message: "Please sign in to access this resource.",
892
- showRetry: false,
893
- showHome: false,
894
- actions: `
895
- <div class="flex justify-center mt-8">
896
- <a href="${escapeHtml2(
897
- loginUrl
898
- )}" class="px-6 py-3 bg-primary hover:bg-primary/90 text-white font-medium rounded-lg transition-colors">
899
- Sign In
900
- </a>
901
- </div>
902
- `,
903
- ...rest
904
- });
905
- }
906
- function serverErrorPage(options = {}) {
907
- return errorPage({
908
- code: 500,
909
- title: "Server Error",
910
- message: "We're having trouble processing your request. Please try again later.",
911
- showRetry: true,
912
- ...options
913
- });
914
- }
915
- function maintenancePage(options = {}) {
916
- const { estimatedTime, ...rest } = options;
917
- const timeMessage = estimatedTime ? `We expect to be back by ${escapeHtml2(estimatedTime)}.` : "We'll be back shortly.";
918
- return errorPage({
919
- code: 503,
920
- title: "Under Maintenance",
921
- message: `We're currently performing scheduled maintenance. ${timeMessage}`,
922
- showRetry: true,
923
- showHome: false,
924
- ...rest
925
- });
926
- }
927
- function rateLimitPage(options = {}) {
928
- const { retryAfter, ...rest } = options;
929
- const retryMessage = retryAfter ? `Please wait ${retryAfter} seconds before trying again.` : "Please wait a moment before trying again.";
930
- return errorPage({
931
- code: 429,
932
- title: "Too Many Requests",
933
- message: `You've made too many requests. ${retryMessage}`,
934
- showRetry: true,
935
- showHome: true,
936
- ...rest
937
- });
938
- }
939
- function offlinePage(options = {}) {
940
- return errorPage({
941
- title: "You're Offline",
942
- message: "Please check your internet connection and try again.",
943
- showRetry: true,
944
- showHome: false,
945
- ...options,
946
- layout: {
947
- ...options.layout
948
- }
949
- });
950
- }
951
- function sessionExpiredPage(options = {}) {
952
- const { loginUrl = "/login", ...rest } = options;
953
- return errorPage({
954
- title: "Session Expired",
955
- message: "Your session has expired. Please sign in again to continue.",
956
- showRetry: false,
957
- showHome: false,
958
- actions: `
959
- <div class="flex justify-center mt-8">
960
- <a href="${escapeHtml2(
961
- loginUrl
962
- )}" class="px-6 py-3 bg-primary hover:bg-primary/90 text-white font-medium rounded-lg transition-colors">
963
- Sign In Again
964
- </a>
965
- </div>
966
- `,
967
- ...rest
968
- });
969
- }
970
- function oauthErrorPage(options) {
971
- const { errorCode, errorDescription, redirectUri, clientName, ...rest } = options;
972
- const errorMessages = {
973
- invalid_request: {
974
- title: "Invalid Request",
975
- message: "The authorization request is missing required parameters or is malformed."
976
- },
977
- unauthorized_client: {
978
- title: "Unauthorized Client",
979
- message: "The client is not authorized to request an authorization code."
980
- },
981
- access_denied: {
982
- title: "Access Denied",
983
- message: "The resource owner denied the authorization request."
984
- },
985
- unsupported_response_type: {
986
- title: "Unsupported Response Type",
987
- message: "The authorization server does not support the requested response type."
988
- },
989
- invalid_scope: {
990
- title: "Invalid Scope",
991
- message: "The requested scope is invalid, unknown, or malformed."
992
- },
993
- server_error: {
994
- title: "Server Error",
995
- message: "The authorization server encountered an unexpected error."
996
- },
997
- temporarily_unavailable: {
998
- title: "Temporarily Unavailable",
999
- message: "The authorization server is temporarily unavailable. Please try again later."
1000
- }
1001
- };
1002
- const errorInfo = errorCode && errorMessages[errorCode] ? errorMessages[errorCode] : { title: "Authorization Error", message: errorDescription || "An error occurred during authorization." };
1003
- const clientMessage = clientName ? ` while connecting to ${escapeHtml2(clientName)}` : "";
1004
- const redirectAction = redirectUri ? `
1005
- <a href="${escapeHtml2(
1006
- redirectUri
1007
- )}" class="px-6 py-3 bg-gray-100 hover:bg-gray-200 text-text-primary font-medium rounded-lg transition-colors">
1008
- Return to ${clientName ? escapeHtml2(clientName) : "Application"}
1009
- </a>
1010
- ` : "";
1011
- return errorPage({
1012
- title: errorInfo.title,
1013
- message: `${errorInfo.message}${clientMessage}`,
1014
- details: errorCode && errorDescription ? `Error: ${errorCode}
1015
- ${errorDescription}` : void 0,
1016
- showRetry: errorCode === "server_error" || errorCode === "temporarily_unavailable",
1017
- showHome: true,
1018
- actions: redirectAction ? `<div class="flex justify-center gap-4 mt-8">${redirectAction}</div>` : void 0,
1019
- ...rest
1020
- });
1021
- }
1022
- export {
1023
- consentDeniedPage,
1024
- consentPage,
1025
- consentSuccessPage,
1026
- errorPage,
1027
- forbiddenPage,
1028
- maintenancePage,
1029
- notFoundPage,
1030
- oauthErrorPage,
1031
- offlinePage,
1032
- rateLimitPage,
1033
- serverErrorPage,
1034
- sessionExpiredPage,
1035
- unauthorizedPage
1036
- };