@leverege/imaginarium-ui 1.8.1 → 1.9.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 (232) hide show
  1. package/README.md +124 -1
  2. package/lib/Card-DbOhP3-w.js +161 -0
  3. package/lib/Card-DbOhP3-w.js.map +1 -0
  4. package/lib/Card-Nm5kfgOa.cjs +2 -0
  5. package/lib/Card-Nm5kfgOa.cjs.map +1 -0
  6. package/lib/ImaginariumApiContext-CbcURxdX.cjs +2 -0
  7. package/lib/ImaginariumApiContext-CbcURxdX.cjs.map +1 -0
  8. package/lib/ImaginariumApiContext-CfXagMC6.js +35 -0
  9. package/lib/ImaginariumApiContext-CfXagMC6.js.map +1 -0
  10. package/lib/ImaginariumApp-DAu-61PK.js +550 -0
  11. package/lib/ImaginariumApp-DAu-61PK.js.map +1 -0
  12. package/lib/ImaginariumApp-DUtoZlIK.cjs +2 -0
  13. package/lib/ImaginariumApp-DUtoZlIK.cjs.map +1 -0
  14. package/lib/{Label-v0wUXs4O.js → Label-DAcriHxc.js} +2 -2
  15. package/lib/{Label-v0wUXs4O.js.map → Label-DAcriHxc.js.map} +1 -1
  16. package/lib/{Label-BhnvyUcc.cjs → Label-g8NR_hZT.cjs} +2 -2
  17. package/lib/{Label-BhnvyUcc.cjs.map → Label-g8NR_hZT.cjs.map} +1 -1
  18. package/lib/{MarkdownPageDoc-D-4LY8Fg.js → MarkdownPageDoc-Dql3rHp7.js} +9 -9
  19. package/lib/{MarkdownPageDoc-D-4LY8Fg.js.map → MarkdownPageDoc-Dql3rHp7.js.map} +1 -1
  20. package/lib/MarkdownPageDoc-OJ0KuYet.cjs +2 -0
  21. package/lib/{MarkdownPageDoc-D7NUqgYZ.cjs.map → MarkdownPageDoc-OJ0KuYet.cjs.map} +1 -1
  22. package/lib/{PluginSetup-CPoiSkhg.js → PluginSetup-BqHhcqJa.js} +17 -16
  23. package/lib/{PluginSetup-CPoiSkhg.js.map → PluginSetup-BqHhcqJa.js.map} +1 -1
  24. package/lib/{PluginSetup-CuSRbqiM.js → PluginSetup-CJ_fpQHi.js} +17 -16
  25. package/lib/{PluginSetup-CuSRbqiM.js.map → PluginSetup-CJ_fpQHi.js.map} +1 -1
  26. package/lib/PluginSetup-CPDTDrac.cjs +2 -0
  27. package/lib/{PluginSetup-B1eP6a5H.cjs.map → PluginSetup-CPDTDrac.cjs.map} +1 -1
  28. package/lib/{PluginSetup-CBFwSR1s.js → PluginSetup-CSyysKPV.js} +11 -10
  29. package/lib/{PluginSetup-CBFwSR1s.js.map → PluginSetup-CSyysKPV.js.map} +1 -1
  30. package/lib/PluginSetup-TdtTCNoq.cjs +45 -0
  31. package/lib/{PluginSetup-D190IxpH.cjs.map → PluginSetup-TdtTCNoq.cjs.map} +1 -1
  32. package/lib/PluginSetup-mMZxLg08.cjs +116 -0
  33. package/lib/{PluginSetup-bDYZGAaC.cjs.map → PluginSetup-mMZxLg08.cjs.map} +1 -1
  34. package/lib/PluginTypes-D14LkV6u.js +10 -0
  35. package/lib/PluginTypes-D14LkV6u.js.map +1 -0
  36. package/lib/PluginTypes-DhbiP0_3.cjs +2 -0
  37. package/lib/PluginTypes-DhbiP0_3.cjs.map +1 -0
  38. package/lib/{Tooltip-CIwKmgzA.js → Tooltip-B1T4_ZuM.js} +5 -5
  39. package/lib/{Tooltip-CIwKmgzA.js.map → Tooltip-B1T4_ZuM.js.map} +1 -1
  40. package/lib/{Tooltip-DQn1fHhM.cjs → Tooltip-DsFlfeZ1.cjs} +2 -2
  41. package/lib/{Tooltip-DQn1fHhM.cjs.map → Tooltip-DsFlfeZ1.cjs.map} +1 -1
  42. package/lib/api/useInterface.d.ts +23 -0
  43. package/lib/api/useInterface.d.ts.map +1 -0
  44. package/lib/api/useInterface.test.d.ts +2 -0
  45. package/lib/api/useInterface.test.d.ts.map +1 -0
  46. package/lib/examples/index.d.ts +4 -0
  47. package/lib/examples/index.d.ts.map +1 -0
  48. package/lib/examples/locationsByMonth/HoverCard.d.ts +5 -0
  49. package/lib/examples/locationsByMonth/HoverCard.d.ts.map +1 -0
  50. package/lib/examples/locationsByMonth/HoverPreview.d.ts +2 -0
  51. package/lib/examples/locationsByMonth/HoverPreview.d.ts.map +1 -0
  52. package/lib/examples/locationsByMonth/LocationsByMonth.d.ts +5 -0
  53. package/lib/examples/locationsByMonth/LocationsByMonth.d.ts.map +1 -0
  54. package/lib/examples/locationsByMonth/LocationsByMonth.prototype.d.ts +4 -0
  55. package/lib/examples/locationsByMonth/LocationsByMonth.prototype.d.ts.map +1 -0
  56. package/lib/examples/locationsByMonth/LocationsByMonthView.d.ts +20 -0
  57. package/lib/examples/locationsByMonth/LocationsByMonthView.d.ts.map +1 -0
  58. package/lib/examples/locationsByMonth/monthlyBuckets.d.ts +12 -0
  59. package/lib/examples/locationsByMonth/monthlyBuckets.d.ts.map +1 -0
  60. package/lib/examples/locationsKpi/LocationsKpi.d.ts +5 -0
  61. package/lib/examples/locationsKpi/LocationsKpi.d.ts.map +1 -0
  62. package/lib/examples/locationsKpi/LocationsKpi.prototype.d.ts +4 -0
  63. package/lib/examples/locationsKpi/LocationsKpi.prototype.d.ts.map +1 -0
  64. package/lib/examples/locationsKpi/LocationsKpiView.d.ts +6 -0
  65. package/lib/examples/locationsKpi/LocationsKpiView.d.ts.map +1 -0
  66. package/lib/examples/locationsKpi/rollup.d.ts +8 -0
  67. package/lib/examples/locationsKpi/rollup.d.ts.map +1 -0
  68. package/lib/examples.cjs +105 -0
  69. package/lib/examples.cjs.map +1 -0
  70. package/lib/examples.js +365 -0
  71. package/lib/examples.js.map +1 -0
  72. package/lib/index.cjs +67 -1
  73. package/lib/index.cjs.map +1 -1
  74. package/lib/index.d.ts +5 -0
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js +925 -258
  77. package/lib/index.js.map +1 -1
  78. package/lib/plugins/PluginTypes.d.ts +1 -0
  79. package/lib/plugins/PluginTypes.d.ts.map +1 -1
  80. package/lib/plugins/registry.d.ts +4 -1
  81. package/lib/plugins/registry.d.ts.map +1 -1
  82. package/lib/plugins/registry.test.d.ts +2 -0
  83. package/lib/plugins/registry.test.d.ts.map +1 -0
  84. package/lib/plugins/types.d.ts +33 -0
  85. package/lib/plugins/types.d.ts.map +1 -1
  86. package/lib/plugins.cjs +1 -1
  87. package/lib/plugins.js +2 -2
  88. package/lib/prototypes/CodeBlock.d.ts +8 -0
  89. package/lib/prototypes/CodeBlock.d.ts.map +1 -0
  90. package/lib/prototypes/DevicePicker.d.ts +11 -0
  91. package/lib/prototypes/DevicePicker.d.ts.map +1 -0
  92. package/lib/prototypes/PluginSetup.d.ts +7 -0
  93. package/lib/prototypes/PluginSetup.d.ts.map +1 -0
  94. package/lib/prototypes/PrototypeCodePanel.d.ts +5 -0
  95. package/lib/prototypes/PrototypeCodePanel.d.ts.map +1 -0
  96. package/lib/prototypes/PrototypeDetailPage.d.ts +8 -0
  97. package/lib/prototypes/PrototypeDetailPage.d.ts.map +1 -0
  98. package/lib/prototypes/PrototypeDetailView.d.ts +2 -0
  99. package/lib/prototypes/PrototypeDetailView.d.ts.map +1 -0
  100. package/lib/prototypes/PrototypeInspector.d.ts +6 -0
  101. package/lib/prototypes/PrototypeInspector.d.ts.map +1 -0
  102. package/lib/prototypes/PrototypeNavItem.d.ts +9 -0
  103. package/lib/prototypes/PrototypeNavItem.d.ts.map +1 -0
  104. package/lib/prototypes/PrototypePreviewBoundary.d.ts +16 -0
  105. package/lib/prototypes/PrototypePreviewBoundary.d.ts.map +1 -0
  106. package/lib/prototypes/PrototypeTable.d.ts +5 -0
  107. package/lib/prototypes/PrototypeTable.d.ts.map +1 -0
  108. package/lib/prototypes/PrototypeThemeBoundary.d.ts +8 -0
  109. package/lib/prototypes/PrototypeThemeBoundary.d.ts.map +1 -0
  110. package/lib/prototypes/PrototypesGalleryView.d.ts +2 -0
  111. package/lib/prototypes/PrototypesGalleryView.d.ts.map +1 -0
  112. package/lib/prototypes/PrototypesPage.d.ts +8 -0
  113. package/lib/prototypes/PrototypesPage.d.ts.map +1 -0
  114. package/lib/prototypes/SystemPicker.d.ts +9 -0
  115. package/lib/prototypes/SystemPicker.d.ts.map +1 -0
  116. package/lib/prototypes/appearanceTheme.d.ts +5 -0
  117. package/lib/prototypes/appearanceTheme.d.ts.map +1 -0
  118. package/lib/prototypes/index.d.ts +4 -0
  119. package/lib/prototypes/index.d.ts.map +1 -0
  120. package/lib/prototypes/moltenScaffold.d.ts +4 -0
  121. package/lib/prototypes/moltenScaffold.d.ts.map +1 -0
  122. package/lib/prototypes/moltenScaffold.test.d.ts +2 -0
  123. package/lib/prototypes/moltenScaffold.test.d.ts.map +1 -0
  124. package/lib/prototypes/prototypeFilter.d.ts +4 -0
  125. package/lib/prototypes/prototypeFilter.d.ts.map +1 -0
  126. package/lib/prototypes/prototypeFilter.test.d.ts +2 -0
  127. package/lib/prototypes/prototypeFilter.test.d.ts.map +1 -0
  128. package/lib/prototypes/prototypeSource.d.ts +12 -0
  129. package/lib/prototypes/prototypeSource.d.ts.map +1 -0
  130. package/lib/prototypes/prototypeSource.test.d.ts +2 -0
  131. package/lib/prototypes/prototypeSource.test.d.ts.map +1 -0
  132. package/lib/registry-B-v6KDJY.js +59 -0
  133. package/lib/registry-B-v6KDJY.js.map +1 -0
  134. package/lib/registry-BlO1Ih6G.cjs +2 -0
  135. package/lib/registry-BlO1Ih6G.cjs.map +1 -0
  136. package/lib/release.cjs +1 -1
  137. package/lib/release.cjs.map +1 -1
  138. package/lib/release.js +46 -45
  139. package/lib/release.js.map +1 -1
  140. package/lib/secret.cjs +1 -1
  141. package/lib/secret.js +1 -1
  142. package/lib/shell/ImaginariumApp.d.ts.map +1 -1
  143. package/lib/shell.cjs +1 -1
  144. package/lib/shell.js +1 -1
  145. package/lib/system.cjs +1 -1
  146. package/lib/system.js +2 -2
  147. package/lib/theme/activeAppearance.d.ts +14 -0
  148. package/lib/theme/activeAppearance.d.ts.map +1 -0
  149. package/lib/ui-elements/index.d.ts +3 -0
  150. package/lib/ui-elements/index.d.ts.map +1 -0
  151. package/lib/ui-elements.cjs +2 -0
  152. package/lib/ui-elements.cjs.map +1 -0
  153. package/lib/ui-elements.js +6 -0
  154. package/lib/ui-elements.js.map +1 -0
  155. package/lib/useInterface-CcZNJ7Q3.js +31 -0
  156. package/lib/useInterface-CcZNJ7Q3.js.map +1 -0
  157. package/lib/useInterface-DjBiEihv.cjs +2 -0
  158. package/lib/useInterface-DjBiEihv.cjs.map +1 -0
  159. package/lib/vite/index.d.ts +45 -0
  160. package/lib/vite/index.d.ts.map +1 -0
  161. package/lib/vite.cjs +2 -0
  162. package/lib/vite.cjs.map +1 -0
  163. package/lib/vite.js +48 -0
  164. package/lib/vite.js.map +1 -0
  165. package/package.json +27 -1
  166. package/src/api/useInterface.test.ts +25 -0
  167. package/src/api/useInterface.ts +57 -0
  168. package/src/examples/index.ts +19 -0
  169. package/src/examples/locationsByMonth/HoverCard.tsx +26 -0
  170. package/src/examples/locationsByMonth/HoverPreview.tsx +7 -0
  171. package/src/examples/locationsByMonth/LocationsByMonth.prototype.ts +21 -0
  172. package/src/examples/locationsByMonth/LocationsByMonth.tsx +37 -0
  173. package/src/examples/locationsByMonth/LocationsByMonthView.tsx +160 -0
  174. package/src/examples/locationsByMonth/monthlyBuckets.ts +50 -0
  175. package/src/examples/locationsByMonth/notes.md +16 -0
  176. package/src/examples/locationsKpi/LocationsKpi.prototype.ts +19 -0
  177. package/src/examples/locationsKpi/LocationsKpi.tsx +34 -0
  178. package/src/examples/locationsKpi/LocationsKpiView.tsx +40 -0
  179. package/src/examples/locationsKpi/notes.md +16 -0
  180. package/src/examples/locationsKpi/rollup.ts +35 -0
  181. package/src/examples/raw-modules.d.ts +5 -0
  182. package/src/index.ts +6 -0
  183. package/src/plugins/PluginTypes.ts +1 -0
  184. package/src/plugins/registry.test.ts +24 -0
  185. package/src/plugins/registry.ts +17 -2
  186. package/src/plugins/types.ts +62 -0
  187. package/src/prototypes/CodeBlock.tsx +91 -0
  188. package/src/prototypes/DevicePicker.tsx +49 -0
  189. package/src/prototypes/PluginSetup.ts +15 -0
  190. package/src/prototypes/PrototypeCodePanel.tsx +77 -0
  191. package/src/prototypes/PrototypeDetailPage.tsx +7 -0
  192. package/src/prototypes/PrototypeDetailView.tsx +177 -0
  193. package/src/prototypes/PrototypeInspector.tsx +263 -0
  194. package/src/prototypes/PrototypeNavItem.ts +9 -0
  195. package/src/prototypes/PrototypePreviewBoundary.tsx +20 -0
  196. package/src/prototypes/PrototypeTable.tsx +57 -0
  197. package/src/prototypes/PrototypeThemeBoundary.tsx +30 -0
  198. package/src/prototypes/PrototypesGalleryView.tsx +115 -0
  199. package/src/prototypes/PrototypesPage.tsx +7 -0
  200. package/src/prototypes/SystemPicker.tsx +23 -0
  201. package/src/prototypes/appearanceTheme.ts +27 -0
  202. package/src/prototypes/index.ts +3 -0
  203. package/src/prototypes/moltenScaffold.test.ts +41 -0
  204. package/src/prototypes/moltenScaffold.ts +70 -0
  205. package/src/prototypes/prototypeFilter.test.ts +47 -0
  206. package/src/prototypes/prototypeFilter.ts +31 -0
  207. package/src/prototypes/prototypeSource.test.ts +56 -0
  208. package/src/prototypes/prototypeSource.ts +39 -0
  209. package/src/shell/ImaginariumApp.tsx +26 -9
  210. package/src/theme/activeAppearance.ts +51 -0
  211. package/src/ui-elements/index.ts +8 -0
  212. package/src/vite/index.ts +96 -0
  213. package/lib/Card-CHVaz_7u.cjs +0 -2
  214. package/lib/Card-CHVaz_7u.cjs.map +0 -1
  215. package/lib/Card-D2LdIJwJ.js +0 -192
  216. package/lib/Card-D2LdIJwJ.js.map +0 -1
  217. package/lib/ImaginariumApp-B49YDrRj.cjs +0 -2
  218. package/lib/ImaginariumApp-B49YDrRj.cjs.map +0 -1
  219. package/lib/ImaginariumApp-Bnnv8Kjb.js +0 -514
  220. package/lib/ImaginariumApp-Bnnv8Kjb.js.map +0 -1
  221. package/lib/MarkdownPageDoc-D7NUqgYZ.cjs +0 -2
  222. package/lib/PluginSetup-B1eP6a5H.cjs +0 -2
  223. package/lib/PluginSetup-D190IxpH.cjs +0 -45
  224. package/lib/PluginSetup-bDYZGAaC.cjs +0 -116
  225. package/lib/PluginTypes-BmYA5_B9.cjs +0 -2
  226. package/lib/PluginTypes-BmYA5_B9.cjs.map +0 -1
  227. package/lib/PluginTypes-mZ4TjxPV.js +0 -9
  228. package/lib/PluginTypes-mZ4TjxPV.js.map +0 -1
  229. package/lib/registry-Bq42i86Q.cjs +0 -2
  230. package/lib/registry-Bq42i86Q.cjs.map +0 -1
  231. package/lib/registry-CMZCG8pH.js +0 -44
  232. package/lib/registry-CMZCG8pH.js.map +0 -1
package/README.md CHANGED
@@ -1,4 +1,127 @@
1
+ # @leverege/imaginarium-ui
1
2
 
3
+ Reusable UI library and plugin framework for Imaginarium apps: the app shell,
4
+ nav/page/provider registration, the Imagine Systems + Secrets + IMP (release)
5
+ screens, the read-only interface client, and an opt-in Prototypes gallery.
2
6
 
3
- # Imaginarium UI
7
+ It pairs with the backend package [`@leverege/imaginarium`](../imaginarium),
8
+ which serves the `/api` routes this UI calls (configs, secrets, IMP, and the
9
+ read-only Imagine interface proxy).
4
10
 
11
+ ## Install
12
+
13
+ ```bash
14
+ npm i @leverege/imaginarium-ui @leverege/imaginarium
15
+ ```
16
+
17
+ `@leverege/ui-elements`, `@leverege/ui-active-theme`, the `@visx/*` chart
18
+ packages, `prismjs`, and `react-markdown` are regular dependencies — npm pulls
19
+ them for you. You provide these **peer** deps:
20
+
21
+ | Peer | Range |
22
+ |---|---|
23
+ | `react` / `react-dom` | `^19.0.0` |
24
+ | `wouter` | `^3.3.5` |
25
+ | `@tanstack/react-query` | `^5.60.0` |
26
+ | `@leverege/plugin` | `^4.2.0` |
27
+
28
+ ## Vite setup (one call)
29
+
30
+ ```ts
31
+ // vite.config.ts
32
+ import { defineConfig } from 'vite'
33
+ import react from '@vitejs/plugin-react'
34
+ import { imaginarium } from '@leverege/imaginarium-ui/vite'
35
+
36
+ export default defineConfig( {
37
+ plugins : [ imaginarium(), react() ],
38
+ // …your root / server / build config
39
+ } )
40
+ ```
41
+
42
+ `imaginarium()` wires the three coupled pieces this library needs, so you don't
43
+ hand-roll them (and silently drift) in every repo:
44
+
45
+ 1. a transform so `@leverege/ui-elements`' `import S from './Foo.css'` resolves
46
+ (without it the app white-screens with "no default export");
47
+ 2. `css.modules` scoped-name config matching `@leverege/webpack-config`, so
48
+ styles render identically to molten/pitcrew-ui;
49
+ 3. `resolve.dedupe` for React/wouter/react-query (avoids "invalid hook call").
50
+
51
+ Your own explicit `css.modules` config still wins on conflict. The lower-level
52
+ `uiElementsCssModules()` plugin is also exported if you need just the transform.
53
+
54
+ ## Bootstrap
55
+
56
+ ```ts
57
+ // src/ui/main.tsx
58
+ import { ImaginariumUI } from '@leverege/imaginarium-ui'
59
+ import '@leverege/imaginarium-ui/theme/index.css'
60
+
61
+ import Config from './Config'
62
+ import PluginSetup from './PluginSetup'
63
+
64
+ ImaginariumUI.init( Config.create(), PluginSetup )
65
+ ImaginariumUI.create()
66
+ ```
67
+
68
+ ## Register your app (PluginSetup)
69
+
70
+ ```ts
71
+ import {
72
+ addProvider, addNavItem, addPage, SecretSetup,
73
+ } from '@leverege/imaginarium-ui'
74
+
75
+ export default {
76
+ install( plg ) {
77
+ addProvider( { component : QueryProvider, sort : 10 } )
78
+ addNavItem( { path : '/overview', label : 'Overview', icon : LayoutDashboard, sort : 10 } )
79
+ addPage( { path : '/overview', element : OverviewPage } )
80
+ SecretSetup.install( plg ) // built-in screens are opt-in installs
81
+ },
82
+ }
83
+ ```
84
+
85
+ The built-in Imagine Systems, Secrets, and IMP screens register themselves; add
86
+ their nav items where you want them (see each `*Setup`).
87
+
88
+ ## Opt in to the Prototypes gallery
89
+
90
+ The prototype gallery (and the shipped example prototypes — a visx bar chart and
91
+ a KPI card) are opt-in:
92
+
93
+ ```ts
94
+ import { PrototypesSetup, addPrototype } from '@leverege/imaginarium-ui'
95
+ import { registerExamplePrototypes } from '@leverege/imaginarium-ui/examples'
96
+
97
+ // inside install( plg ):
98
+ PrototypesSetup.install( plg )
99
+ registerExamplePrototypes( addPrototype )
100
+ ```
101
+
102
+ The example prototypes read **real cluster data** through the read-only
103
+ interface proxy, which is served by the backend (next section) — so they need a
104
+ paired `@leverege/imaginarium` that has the proxy route.
105
+
106
+ ## Backend pairing
107
+
108
+ Bump `@leverege/imaginarium` alongside this package and ensure its `PluginSetup`
109
+ is installed — the backend's read-only Imagine interface proxy
110
+ (`POST /api/imagine/:configId/interface/:type/search`) is wired in automatically.
111
+ **Restart the backend after a version bump.**
112
+
113
+ > To use the Prototypes example charts you need **both**
114
+ > `@leverege/imaginarium-ui` and `@leverege/imaginarium` at the version that
115
+ > ships the interface proxy. A UI-only bump renders the gallery but the
116
+ > data-backed prototypes 404 until the backend has the proxy route.
117
+
118
+ ## Exports
119
+
120
+ | Entry | Purpose |
121
+ |---|---|
122
+ | `.` | shell, registration (`addNavItem`/`addPage`/`addProvider`), `ImaginariumUI`, built-in `*Setup`s, `PrototypesSetup`/`addPrototype` |
123
+ | `./vite` | `imaginarium()` preset + `uiElementsCssModules()` |
124
+ | `./examples` | `registerExamplePrototypes()` |
125
+ | `./theme/index.css` | base theme stylesheet |
126
+ | `./theme/tailwind-preset` | Tailwind preset |
127
+ | `./shell`, `./plugins`, `./system`, `./secret`, `./release`, `./ui-elements` | focused subpath entries |
@@ -0,0 +1,161 @@
1
+ import * as o from "react";
2
+ import { jsx as a } from "react/jsx-runtime";
3
+ import { Slot as T } from "@radix-ui/react-slot";
4
+ import { cva as b } from "class-variance-authority";
5
+ import { clsx as v } from "clsx";
6
+ import { twMerge as g } from "tailwind-merge";
7
+ function n(...e) {
8
+ return g(v(e));
9
+ }
10
+ const S = 1, x = 1e6;
11
+ let f = 0;
12
+ function y() {
13
+ return f = (f + 1) % Number.MAX_SAFE_INTEGER, f.toString();
14
+ }
15
+ const m = /* @__PURE__ */ new Map(), l = (e) => {
16
+ if (m.has(e))
17
+ return;
18
+ const t = setTimeout(() => {
19
+ m.delete(e), i({ type: "REMOVE_TOAST", toastId: e });
20
+ }, x);
21
+ m.set(e, t);
22
+ }, h = (e, t) => {
23
+ switch (t.type) {
24
+ case "ADD_TOAST":
25
+ return {
26
+ ...e,
27
+ toasts: [t.toast, ...e.toasts].slice(0, S)
28
+ };
29
+ case "UPDATE_TOAST":
30
+ return {
31
+ ...e,
32
+ toasts: e.toasts.map((r) => r.id === t.toast.id ? { ...r, ...t.toast } : r)
33
+ };
34
+ case "DISMISS_TOAST": {
35
+ const { toastId: r } = t;
36
+ return r ? l(r) : e.toasts.forEach((s) => l(s.id)), {
37
+ ...e,
38
+ toasts: e.toasts.map(
39
+ (s) => s.id === r || r === void 0 ? { ...s, open: !1 } : s
40
+ )
41
+ };
42
+ }
43
+ case "REMOVE_TOAST":
44
+ return t.toastId === void 0 ? { ...e, toasts: [] } : { ...e, toasts: e.toasts.filter((r) => r.id !== t.toastId) };
45
+ }
46
+ }, c = [];
47
+ let u = { toasts: [] };
48
+ function i(e) {
49
+ u = h(u, e), c.forEach((t) => t(u));
50
+ }
51
+ function A({ ...e }) {
52
+ const t = y(), r = (d) => i({ type: "UPDATE_TOAST", toast: { ...d, id: t } }), s = () => i({ type: "DISMISS_TOAST", toastId: t });
53
+ return i({
54
+ type: "ADD_TOAST",
55
+ toast: {
56
+ ...e,
57
+ id: t,
58
+ open: !0,
59
+ onOpenChange: (d) => {
60
+ d || s();
61
+ }
62
+ }
63
+ }), { id: t, dismiss: s, update: r };
64
+ }
65
+ function j() {
66
+ const [e, t] = o.useState(u);
67
+ return o.useEffect(() => (c.push(t), () => {
68
+ const r = c.indexOf(t);
69
+ r > -1 && c.splice(r, 1);
70
+ }), [e]), {
71
+ ...e,
72
+ toast: A,
73
+ dismiss: (r) => i({ type: "DISMISS_TOAST", toastId: r })
74
+ };
75
+ }
76
+ const C = b(
77
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover-elevate active-elevate-2",
78
+ {
79
+ variants: {
80
+ variant: {
81
+ default: "bg-primary text-primary-foreground border border-primary-border",
82
+ destructive: "bg-destructive text-destructive-foreground border border-destructive-border",
83
+ outline: "border [border-color:var(--button-outline)] shadow-xs active:shadow-none",
84
+ secondary: "border bg-secondary text-secondary-foreground border-secondary-border",
85
+ ghost: "border border-transparent"
86
+ },
87
+ size: {
88
+ default: "min-h-9 px-4 py-2",
89
+ sm: "min-h-8 rounded-md px-3 text-xs",
90
+ lg: "min-h-10 rounded-md px-8",
91
+ icon: "h-9 w-9"
92
+ }
93
+ },
94
+ defaultVariants: { variant: "default", size: "default" }
95
+ }
96
+ ), _ = o.forwardRef(
97
+ ({ className: e, variant: t, size: r, asChild: s = !1, ...d }, p) => /* @__PURE__ */ a(
98
+ s ? T : "button",
99
+ {
100
+ className: n(C({ variant: t, size: r, className: e })),
101
+ ref: p,
102
+ ...d
103
+ }
104
+ )
105
+ );
106
+ _.displayName = "Button";
107
+ const w = o.forwardRef(
108
+ ({ className: e, ...t }, r) => /* @__PURE__ */ a(
109
+ "div",
110
+ {
111
+ ref: r,
112
+ className: n(
113
+ "shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm",
114
+ e
115
+ ),
116
+ ...t
117
+ }
118
+ )
119
+ );
120
+ w.displayName = "Card";
121
+ const N = o.forwardRef(
122
+ ({ className: e, ...t }, r) => /* @__PURE__ */ a("div", { ref: r, className: n("flex flex-col space-y-1.5 p-6", e), ...t })
123
+ );
124
+ N.displayName = "CardHeader";
125
+ const O = o.forwardRef(
126
+ ({ className: e, ...t }, r) => /* @__PURE__ */ a(
127
+ "div",
128
+ {
129
+ ref: r,
130
+ className: n("text-2xl font-semibold leading-none tracking-tight", e),
131
+ ...t
132
+ }
133
+ )
134
+ );
135
+ O.displayName = "CardTitle";
136
+ const E = o.forwardRef(
137
+ ({ className: e, ...t }, r) => /* @__PURE__ */ a("div", { ref: r, className: n("text-sm text-muted-foreground", e), ...t })
138
+ );
139
+ E.displayName = "CardDescription";
140
+ const R = o.forwardRef(
141
+ ({ className: e, ...t }, r) => /* @__PURE__ */ a("div", { ref: r, className: n("p-6 pt-0", e), ...t })
142
+ );
143
+ R.displayName = "CardContent";
144
+ const D = o.forwardRef(
145
+ ({ className: e, ...t }, r) => /* @__PURE__ */ a("div", { ref: r, className: n("flex items-center p-6 pt-0", e), ...t })
146
+ );
147
+ D.displayName = "CardFooter";
148
+ export {
149
+ _ as B,
150
+ w as C,
151
+ N as a,
152
+ O as b,
153
+ n as c,
154
+ E as d,
155
+ R as e,
156
+ D as f,
157
+ C as g,
158
+ A as t,
159
+ j as u
160
+ };
161
+ //# sourceMappingURL=Card-DbOhP3-w.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-DbOhP3-w.js","sources":["../src/lib/utils.ts","../src/hooks/useToast.ts","../src/components/ui/Button.tsx","../src/components/ui/Card.tsx"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn( ...inputs: ClassValue[] ) {\n return twMerge( clsx( inputs ) )\n}\n","import * as React from 'react'\n\nimport type { ToastActionElement, ToastProps } from '../components/ui/Toast'\n\nconst TOAST_LIMIT = 1\nconst TOAST_REMOVE_DELAY = 1_000_000\n\ntype ToasterToast = ToastProps & {\n id: string\n title?: React.ReactNode\n description?: React.ReactNode\n action?: ToastActionElement\n}\n\nconst actionTypes = {\n ADD_TOAST: 'ADD_TOAST',\n UPDATE_TOAST: 'UPDATE_TOAST',\n DISMISS_TOAST: 'DISMISS_TOAST',\n REMOVE_TOAST: 'REMOVE_TOAST',\n} as const\n\nlet count = 0\nfunction genId() {\n count = ( count + 1 ) % Number.MAX_SAFE_INTEGER\n return count.toString()\n}\n\ntype ActionType = typeof actionTypes\ntype Action =\n | { type: ActionType['ADD_TOAST']; toast: ToasterToast }\n | { type: ActionType['UPDATE_TOAST']; toast: Partial<ToasterToast> }\n | { type: ActionType['DISMISS_TOAST']; toastId?: ToasterToast['id'] }\n | { type: ActionType['REMOVE_TOAST']; toastId?: ToasterToast['id'] }\n\ninterface State {\n toasts: ToasterToast[]\n}\n\nconst toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()\n\nconst addToRemoveQueue = ( toastId: string ) => {\n if ( toastTimeouts.has( toastId ) ) { return }\n const timeout = setTimeout( () => {\n toastTimeouts.delete( toastId )\n dispatch( { type: 'REMOVE_TOAST', toastId } )\n }, TOAST_REMOVE_DELAY )\n toastTimeouts.set( toastId, timeout )\n}\n\nexport const reducer = ( state: State, action: Action ): State => {\n switch ( action.type ) {\n case 'ADD_TOAST':\n return {\n ...state,\n toasts: [ action.toast, ...state.toasts ].slice( 0, TOAST_LIMIT ),\n }\n case 'UPDATE_TOAST':\n return {\n ...state,\n toasts: state.toasts.map( t => ( t.id === action.toast.id ? { ...t, ...action.toast } : t ) ),\n }\n case 'DISMISS_TOAST': {\n const { toastId } = action\n if ( toastId ) {\n addToRemoveQueue( toastId )\n } else {\n state.toasts.forEach( t => addToRemoveQueue( t.id ) )\n }\n return {\n ...state,\n toasts: state.toasts.map( t =>\n t.id === toastId || toastId === undefined ? { ...t, open: false } : t,\n ),\n }\n }\n case 'REMOVE_TOAST':\n if ( action.toastId === undefined ) {\n return { ...state, toasts: [] }\n }\n return { ...state, toasts: state.toasts.filter( t => t.id !== action.toastId ) }\n }\n}\n\nconst listeners: Array<( state: State ) => void> = []\nlet memoryState: State = { toasts: [] }\n\nfunction dispatch( action: Action ) {\n memoryState = reducer( memoryState, action )\n listeners.forEach( l => l( memoryState ) )\n}\n\ntype Toast = Omit<ToasterToast, 'id'>\n\nfunction toast( { ...props }: Toast ) {\n const id = genId()\n const update = ( p: ToasterToast ) =>\n dispatch( { type: 'UPDATE_TOAST', toast: { ...p, id } } )\n const dismiss = () => dispatch( { type: 'DISMISS_TOAST', toastId: id } )\n\n dispatch( {\n type: 'ADD_TOAST',\n toast: {\n ...props,\n id,\n open: true,\n onOpenChange: ( open ) => {\n if ( !open ) { dismiss() }\n },\n },\n } )\n return { id, dismiss, update }\n}\n\nfunction useToast() {\n const [ state, setState ] = React.useState<State>( memoryState )\n React.useEffect( () => {\n listeners.push( setState )\n return () => {\n const index = listeners.indexOf( setState )\n if ( index > -1 ) { listeners.splice( index, 1 ) }\n }\n }, [ state ] )\n return {\n ...state,\n toast,\n dismiss: ( toastId?: string ) => dispatch( { type: 'DISMISS_TOAST', toastId } ),\n }\n}\n\nexport { useToast, toast }\n","import * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../../lib/utils'\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover-elevate active-elevate-2',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground border border-primary-border',\n destructive: 'bg-destructive text-destructive-foreground border border-destructive-border',\n outline: 'border [border-color:var(--button-outline)] shadow-xs active:shadow-none',\n secondary: 'border bg-secondary text-secondary-foreground border-secondary-border',\n ghost: 'border border-transparent',\n },\n size: {\n default: 'min-h-9 px-4 py-2',\n sm: 'min-h-8 rounded-md px-3 text-xs',\n lg: 'min-h-10 rounded-md px-8',\n icon: 'h-9 w-9',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ( { className, variant, size, asChild = false, ...props }, ref ) => {\n const Comp = asChild ? Slot : 'button'\n return (\n <Comp\n className={cn( buttonVariants( { variant, size, className } ) )}\n ref={ref}\n {...props}\n />\n )\n },\n)\nButton.displayName = 'Button'\n\nexport { Button, buttonVariants }\n","import * as React from 'react'\n\nimport { cn } from '../../lib/utils'\n\nconst Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div\n ref={ref}\n className={cn(\n 'shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm',\n className,\n )}\n {...props}\n />\n ),\n)\nCard.displayName = 'Card'\n\nconst CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div ref={ref} className={cn( 'flex flex-col space-y-1.5 p-6', className )} {...props} />\n ),\n)\nCardHeader.displayName = 'CardHeader'\n\nconst CardTitle = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div\n ref={ref}\n className={cn( 'text-2xl font-semibold leading-none tracking-tight', className )}\n {...props}\n />\n ),\n)\nCardTitle.displayName = 'CardTitle'\n\nconst CardDescription = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div ref={ref} className={cn( 'text-sm text-muted-foreground', className )} {...props} />\n ),\n)\nCardDescription.displayName = 'CardDescription'\n\nconst CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div ref={ref} className={cn( 'p-6 pt-0', className )} {...props} />\n ),\n)\nCardContent.displayName = 'CardContent'\n\nconst CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div ref={ref} className={cn( 'flex items-center p-6 pt-0', className )} {...props} />\n ),\n)\nCardFooter.displayName = 'CardFooter'\n\nexport { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }\n"],"names":["cn","inputs","twMerge","clsx","TOAST_LIMIT","TOAST_REMOVE_DELAY","count","genId","toastTimeouts","addToRemoveQueue","toastId","timeout","dispatch","reducer","state","action","t","listeners","memoryState","l","toast","props","id","update","p","dismiss","open","useToast","setState","React","index","buttonVariants","cva","Button","className","variant","size","asChild","ref","jsx","Slot","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter"],"mappings":";;;;;;AAGO,SAASA,KAAOC,GAAuB;AAC5C,SAAOC,EAASC,EAAMF,CAAO,CAAE;AACjC;ACDA,MAAMG,IAAc,GACdC,IAAqB;AAgB3B,IAAIC,IAAQ;AACZ,SAASC,IAAQ;AACf,SAAAD,KAAUA,IAAQ,KAAM,OAAO,kBACxBA,EAAM,SAAA;AACf;AAaA,MAAME,wBAAoB,IAAA,GAEpBC,IAAmB,CAAEC,MAAqB;AAC9C,MAAKF,EAAc,IAAKE,CAAQ;AAAM;AACtC,QAAMC,IAAU,WAAY,MAAM;AAChC,IAAAH,EAAc,OAAQE,CAAQ,GAC9BE,EAAU,EAAE,MAAM,gBAAgB,SAAAF,EAAA,CAAU;AAAA,EAC9C,GAAGL,CAAmB;AACtB,EAAAG,EAAc,IAAKE,GAASC,CAAQ;AACtC,GAEaE,IAAU,CAAEC,GAAcC,MAA2B;AAChE,UAASA,EAAO,MAAA;AAAA,IACd,KAAK;AACH,aAAO;AAAA,QACL,GAAGD;AAAA,QACH,QAAQ,CAAEC,EAAO,OAAO,GAAGD,EAAM,MAAO,EAAE,MAAO,GAAGV,CAAY;AAAA,MAAA;AAAA,IAEpE,KAAK;AACH,aAAO;AAAA,QACL,GAAGU;AAAA,QACH,QAAQA,EAAM,OAAO,IAAK,CAAAE,MAAOA,EAAE,OAAOD,EAAO,MAAM,KAAK,EAAE,GAAGC,GAAG,GAAGD,EAAO,MAAA,IAAUC,CAAI;AAAA,MAAA;AAAA,IAEhG,KAAK,iBAAiB;AACpB,YAAM,EAAE,SAAAN,MAAYK;AACpB,aAAKL,IACHD,EAAkBC,CAAQ,IAE1BI,EAAM,OAAO,QAAS,CAAAE,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,EAAK,cAAc;AAEnB,MAAMC,IAAab,EAAM;AAAA,EACvB,CAAE,EAAE,WAAAK,GAAW,GAAGb,EAAA,GAASiB,MACzB,gBAAAC,EAAC,OAAA,EAAI,KAAAD,GAAU,WAAWtC,EAAI,iCAAiCkC,CAAU,GAAI,GAAGb,EAAA,CAAO;AAE3F;AACAqB,EAAW,cAAc;AAEzB,MAAMC,IAAYd,EAAM;AAAA,EACtB,CAAE,EAAE,WAAAK,GAAW,GAAGb,EAAA,GAASiB,MACzB,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAD;AAAA,MACA,WAAWtC,EAAI,sDAAsDkC,CAAU;AAAA,MAC9E,GAAGb;AAAA,IAAA;AAAA,EAAA;AAGV;AACAsB,EAAU,cAAc;AAExB,MAAMC,IAAkBf,EAAM;AAAA,EAC5B,CAAE,EAAE,WAAAK,GAAW,GAAGb,EAAA,GAASiB,MACzB,gBAAAC,EAAC,OAAA,EAAI,KAAAD,GAAU,WAAWtC,EAAI,iCAAiCkC,CAAU,GAAI,GAAGb,EAAA,CAAO;AAE3F;AACAuB,EAAgB,cAAc;AAE9B,MAAMC,IAAchB,EAAM;AAAA,EACxB,CAAE,EAAE,WAAAK,GAAW,GAAGb,EAAA,GAASiB,MACzB,gBAAAC,EAAC,OAAA,EAAI,KAAAD,GAAU,WAAWtC,EAAI,YAAYkC,CAAU,GAAI,GAAGb,EAAA,CAAO;AAEtE;AACAwB,EAAY,cAAc;AAE1B,MAAMC,IAAajB,EAAM;AAAA,EACvB,CAAE,EAAE,WAAAK,GAAW,GAAGb,EAAA,GAASiB,MACzB,gBAAAC,EAAC,OAAA,EAAI,KAAAD,GAAU,WAAWtC,EAAI,8BAA8BkC,CAAU,GAAI,GAAGb,EAAA,CAAO;AAExF;AACAyB,EAAW,cAAc;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const _=require("react"),n=require("react/jsx-runtime"),A=require("@radix-ui/react-slot"),w=require("class-variance-authority"),N=require("clsx"),D=require("tailwind-merge");function E(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const o=E(_);function a(...e){return D.twMerge(N.clsx(e))}const R=1,j=1e6;let l=0;function M(){return l=(l+1)%Number.MAX_SAFE_INTEGER,l.toString()}const f=new Map,p=e=>{if(f.has(e))return;const t=setTimeout(()=>{f.delete(e),i({type:"REMOVE_TOAST",toastId:e})},j);f.set(e,t)},I=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,R)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(r=>r.id===t.toast.id?{...r,...t.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=t;return r?p(r):e.toasts.forEach(s=>p(s.id)),{...e,toasts:e.toasts.map(s=>s.id===r||r===void 0?{...s,open:!1}:s)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(r=>r.id!==t.toastId)}}},c=[];let u={toasts:[]};function i(e){u=I(u,e),c.forEach(t=>t(u))}function m({...e}){const t=M(),r=d=>i({type:"UPDATE_TOAST",toast:{...d,id:t}}),s=()=>i({type:"DISMISS_TOAST",toastId:t});return i({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:d=>{d||s()}}}),{id:t,dismiss:s,update:r}}function V(){const[e,t]=o.useState(u);return o.useEffect(()=>(c.push(t),()=>{const r=c.indexOf(t);r>-1&&c.splice(r,1)}),[e]),{...e,toast:m,dismiss:r=>i({type:"DISMISS_TOAST",toastId:r})}}const b=w.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover-elevate active-elevate-2",{variants:{variant:{default:"bg-primary text-primary-foreground border border-primary-border",destructive:"bg-destructive text-destructive-foreground border border-destructive-border",outline:"border [border-color:var(--button-outline)] shadow-xs active:shadow-none",secondary:"border bg-secondary text-secondary-foreground border-secondary-border",ghost:"border border-transparent"},size:{default:"min-h-9 px-4 py-2",sm:"min-h-8 rounded-md px-3 text-xs",lg:"min-h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),T=o.forwardRef(({className:e,variant:t,size:r,asChild:s=!1,...d},h)=>{const O=s?A.Slot:"button";return n.jsx(O,{className:a(b({variant:t,size:r,className:e})),ref:h,...d})});T.displayName="Button";const v=o.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:a("shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm",e),...t}));v.displayName="Card";const x=o.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:a("flex flex-col space-y-1.5 p-6",e),...t}));x.displayName="CardHeader";const g=o.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:a("text-2xl font-semibold leading-none tracking-tight",e),...t}));g.displayName="CardTitle";const y=o.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:a("text-sm text-muted-foreground",e),...t}));y.displayName="CardDescription";const S=o.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:a("p-6 pt-0",e),...t}));S.displayName="CardContent";const C=o.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:a("flex items-center p-6 pt-0",e),...t}));C.displayName="CardFooter";exports.Button=T;exports.Card=v;exports.CardContent=S;exports.CardDescription=y;exports.CardFooter=C;exports.CardHeader=x;exports.CardTitle=g;exports.buttonVariants=b;exports.cn=a;exports.toast=m;exports.useToast=V;
2
+ //# sourceMappingURL=Card-Nm5kfgOa.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-Nm5kfgOa.cjs","sources":["../src/lib/utils.ts","../src/hooks/useToast.ts","../src/components/ui/Button.tsx","../src/components/ui/Card.tsx"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn( ...inputs: ClassValue[] ) {\n return twMerge( clsx( inputs ) )\n}\n","import * as React from 'react'\n\nimport type { ToastActionElement, ToastProps } from '../components/ui/Toast'\n\nconst TOAST_LIMIT = 1\nconst TOAST_REMOVE_DELAY = 1_000_000\n\ntype ToasterToast = ToastProps & {\n id: string\n title?: React.ReactNode\n description?: React.ReactNode\n action?: ToastActionElement\n}\n\nconst actionTypes = {\n ADD_TOAST: 'ADD_TOAST',\n UPDATE_TOAST: 'UPDATE_TOAST',\n DISMISS_TOAST: 'DISMISS_TOAST',\n REMOVE_TOAST: 'REMOVE_TOAST',\n} as const\n\nlet count = 0\nfunction genId() {\n count = ( count + 1 ) % Number.MAX_SAFE_INTEGER\n return count.toString()\n}\n\ntype ActionType = typeof actionTypes\ntype Action =\n | { type: ActionType['ADD_TOAST']; toast: ToasterToast }\n | { type: ActionType['UPDATE_TOAST']; toast: Partial<ToasterToast> }\n | { type: ActionType['DISMISS_TOAST']; toastId?: ToasterToast['id'] }\n | { type: ActionType['REMOVE_TOAST']; toastId?: ToasterToast['id'] }\n\ninterface State {\n toasts: ToasterToast[]\n}\n\nconst toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()\n\nconst addToRemoveQueue = ( toastId: string ) => {\n if ( toastTimeouts.has( toastId ) ) { return }\n const timeout = setTimeout( () => {\n toastTimeouts.delete( toastId )\n dispatch( { type: 'REMOVE_TOAST', toastId } )\n }, TOAST_REMOVE_DELAY )\n toastTimeouts.set( toastId, timeout )\n}\n\nexport const reducer = ( state: State, action: Action ): State => {\n switch ( action.type ) {\n case 'ADD_TOAST':\n return {\n ...state,\n toasts: [ action.toast, ...state.toasts ].slice( 0, TOAST_LIMIT ),\n }\n case 'UPDATE_TOAST':\n return {\n ...state,\n toasts: state.toasts.map( t => ( t.id === action.toast.id ? { ...t, ...action.toast } : t ) ),\n }\n case 'DISMISS_TOAST': {\n const { toastId } = action\n if ( toastId ) {\n addToRemoveQueue( toastId )\n } else {\n state.toasts.forEach( t => addToRemoveQueue( t.id ) )\n }\n return {\n ...state,\n toasts: state.toasts.map( t =>\n t.id === toastId || toastId === undefined ? { ...t, open: false } : t,\n ),\n }\n }\n case 'REMOVE_TOAST':\n if ( action.toastId === undefined ) {\n return { ...state, toasts: [] }\n }\n return { ...state, toasts: state.toasts.filter( t => t.id !== action.toastId ) }\n }\n}\n\nconst listeners: Array<( state: State ) => void> = []\nlet memoryState: State = { toasts: [] }\n\nfunction dispatch( action: Action ) {\n memoryState = reducer( memoryState, action )\n listeners.forEach( l => l( memoryState ) )\n}\n\ntype Toast = Omit<ToasterToast, 'id'>\n\nfunction toast( { ...props }: Toast ) {\n const id = genId()\n const update = ( p: ToasterToast ) =>\n dispatch( { type: 'UPDATE_TOAST', toast: { ...p, id } } )\n const dismiss = () => dispatch( { type: 'DISMISS_TOAST', toastId: id } )\n\n dispatch( {\n type: 'ADD_TOAST',\n toast: {\n ...props,\n id,\n open: true,\n onOpenChange: ( open ) => {\n if ( !open ) { dismiss() }\n },\n },\n } )\n return { id, dismiss, update }\n}\n\nfunction useToast() {\n const [ state, setState ] = React.useState<State>( memoryState )\n React.useEffect( () => {\n listeners.push( setState )\n return () => {\n const index = listeners.indexOf( setState )\n if ( index > -1 ) { listeners.splice( index, 1 ) }\n }\n }, [ state ] )\n return {\n ...state,\n toast,\n dismiss: ( toastId?: string ) => dispatch( { type: 'DISMISS_TOAST', toastId } ),\n }\n}\n\nexport { useToast, toast }\n","import * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../../lib/utils'\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover-elevate active-elevate-2',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground border border-primary-border',\n destructive: 'bg-destructive text-destructive-foreground border border-destructive-border',\n outline: 'border [border-color:var(--button-outline)] shadow-xs active:shadow-none',\n secondary: 'border bg-secondary text-secondary-foreground border-secondary-border',\n ghost: 'border border-transparent',\n },\n size: {\n default: 'min-h-9 px-4 py-2',\n sm: 'min-h-8 rounded-md px-3 text-xs',\n lg: 'min-h-10 rounded-md px-8',\n icon: 'h-9 w-9',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ( { className, variant, size, asChild = false, ...props }, ref ) => {\n const Comp = asChild ? Slot : 'button'\n return (\n <Comp\n className={cn( buttonVariants( { variant, size, className } ) )}\n ref={ref}\n {...props}\n />\n )\n },\n)\nButton.displayName = 'Button'\n\nexport { Button, buttonVariants }\n","import * as React from 'react'\n\nimport { cn } from '../../lib/utils'\n\nconst Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div\n ref={ref}\n className={cn(\n 'shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm',\n className,\n )}\n {...props}\n />\n ),\n)\nCard.displayName = 'Card'\n\nconst CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div ref={ref} className={cn( 'flex flex-col space-y-1.5 p-6', className )} {...props} />\n ),\n)\nCardHeader.displayName = 'CardHeader'\n\nconst CardTitle = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div\n ref={ref}\n className={cn( 'text-2xl font-semibold leading-none tracking-tight', className )}\n {...props}\n />\n ),\n)\nCardTitle.displayName = 'CardTitle'\n\nconst CardDescription = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div ref={ref} className={cn( 'text-sm text-muted-foreground', className )} {...props} />\n ),\n)\nCardDescription.displayName = 'CardDescription'\n\nconst CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div ref={ref} className={cn( 'p-6 pt-0', className )} {...props} />\n ),\n)\nCardContent.displayName = 'CardContent'\n\nconst CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ( { className, ...props }, ref ) => (\n <div ref={ref} className={cn( 'flex items-center p-6 pt-0', className )} {...props} />\n ),\n)\nCardFooter.displayName = 'CardFooter'\n\nexport { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }\n"],"names":["cn","inputs","twMerge","clsx","TOAST_LIMIT","TOAST_REMOVE_DELAY","count","genId","toastTimeouts","addToRemoveQueue","toastId","timeout","dispatch","reducer","state","action","t","listeners","memoryState","l","toast","props","id","update","p","dismiss","open","useToast","setState","React","index","buttonVariants","cva","Button","className","variant","size","asChild","ref","Comp","Slot","jsx","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter"],"mappings":"qdAGO,SAASA,KAAOC,EAAuB,CAC5C,OAAOC,EAAAA,QAASC,OAAMF,CAAO,CAAE,CACjC,CCDA,MAAMG,EAAc,EACdC,EAAqB,IAgB3B,IAAIC,EAAQ,EACZ,SAASC,GAAQ,CACf,OAAAD,GAAUA,EAAQ,GAAM,OAAO,iBACxBA,EAAM,SAAA,CACf,CAaA,MAAME,MAAoB,IAEpBC,EAAqBC,GAAqB,CAC9C,GAAKF,EAAc,IAAKE,CAAQ,EAAM,OACtC,MAAMC,EAAU,WAAY,IAAM,CAChCH,EAAc,OAAQE,CAAQ,EAC9BE,EAAU,CAAE,KA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AAc"}
@@ -0,0 +1,2 @@
1
+ "use strict";const g=require("react/jsx-runtime"),a=require("react"),m=a.createContext(null);function h({apiBaseUrl:r="/api",children:p}){const d=a.useMemo(()=>{const c=r.replace(/\/$/,""),u=t=>`${c}${t.startsWith("/")?t:`/${t}`}`;return{apiBaseUrl:c,buildUrl:u,fetchJson:async(t,e)=>{var i;const o=new Headers(e==null?void 0:e.headers);e!=null&&e.body&&!o.has("Content-Type")&&o.set("Content-Type","application/json");const n=await fetch(u(t),{credentials:"include",...e,headers:o}),s=((i=n.headers.get("content-type"))==null?void 0:i.includes("application/json"))&&n.status!==204?await n.json():void 0;if(!n.ok){const l=(s==null?void 0:s.error)||(s==null?void 0:s.message)||n.statusText;throw new Error(l)}return s}}},[r]);return g.jsx(m.Provider,{value:d,children:p})}function f(){const r=a.useContext(m);if(!r)throw new Error("useImaginariumApi must be used within an ImaginariumApiProvider");return r}exports.ImaginariumApiProvider=h;exports.useImaginariumApi=f;
2
+ //# sourceMappingURL=ImaginariumApiContext-CbcURxdX.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImaginariumApiContext-CbcURxdX.cjs","sources":["../src/api/ImaginariumApiContext.tsx"],"sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\n\nexport interface ImaginariumApiContextValue {\n apiBaseUrl: string\n fetchJson: <T = unknown>( path: string, init?: RequestInit ) => Promise<T>\n buildUrl: ( path: string ) => string\n}\n\nconst Context = createContext<ImaginariumApiContextValue | null>( null )\n\nexport interface ImaginariumApiProviderProps {\n apiBaseUrl?: string\n children: ReactNode\n}\n\nexport function ImaginariumApiProvider( { apiBaseUrl = '/api', children }: ImaginariumApiProviderProps ) {\n const value = useMemo<ImaginariumApiContextValue>( () => {\n const base = apiBaseUrl.replace( /\\/$/, '' )\n const buildUrl = ( path: string ) => `${base}${path.startsWith( '/' ) ? path : `/${path}`}`\n\n const fetchJson = async <T = unknown>( path: string, init?: RequestInit ): Promise<T> => {\n const headers = new Headers( init?.headers )\n if ( init?.body && !headers.has( 'Content-Type' ) ) {\n headers.set( 'Content-Type', 'application/json' )\n }\n const res = await fetch( buildUrl( path ), {\n credentials: 'include',\n ...init,\n headers,\n } )\n const isJson = res.headers.get( 'content-type' )?.includes( 'application/json' )\n const body = isJson && res.status !== 204 ? await res.json() : undefined\n if ( !res.ok ) {\n const msg = ( body as { error?: string; message?: string } | undefined )?.error\n || ( body as { message?: string } | undefined )?.message\n || res.statusText\n throw new Error( msg )\n }\n return body as T\n }\n\n return { apiBaseUrl: base, buildUrl, fetchJson }\n }, [ apiBaseUrl ] )\n\n return <Context.Provider value={value}>{children}</Context.Provider>\n}\n\nexport function useImaginariumApi() {\n const ctx = useContext( Context )\n if ( !ctx ) {\n throw new Error( 'useImaginariumApi must be used within an ImaginariumApiProvider' )\n }\n return ctx\n}\n"],"names":["Context","createContext","ImaginariumApiProvider","apiBaseUrl","children","value","useMemo","base","buildUrl","path","init","headers","res","body","_a","msg","jsx","useImaginariumApi","ctx","useContext"],"mappings":"qEAQMA,EAAUC,EAAAA,cAAkD,IAAK,EAOhE,SAASC,EAAwB,CAAE,WAAAC,EAAa,OAAQ,SAAAC,GAA0C,CACvG,MAAMC,EAAQC,EAAAA,QAAqC,IAAM,CACvD,MAAMC,EAAOJ,EAAW,QAAS,MAAO,EAAG,EACrCK,EAAaC,GAAkB,GAAGF,CAAI,GAAGE,EAAK,WAAY,GAAI,EAAIA,EAAO,IAAIA,CAAI,EAAE,GAuBzF,MAAO,CAAE,WAAYF,EAAM,SAAAC,EAAU,UArBnB,MAAqBC,EAAcC,IAAoC,OACvF,MAAMC,EAAU,IAAI,QAASD,GAAA,YAAAA,EAAM,OAAQ,EACtCA,GAAA,MAAAA,EAAM,MAAQ,CAACC,EAAQ,IAAK,cAAe,GAC9CA,EAAQ,IAAK,eAAgB,kBAAmB,EAElD,MAAMC,EAAM,MAAM,MAAOJ,EAAUC,CAAK,EAAG,CACzC,YAAa,UACb,GAAGC,EACH,QAAAC,CAAA,CACA,EAEIE,IADSC,EAAAF,EAAI,QAAQ,IAAK,cAAe,IAAhC,YAAAE,EAAmC,SAAU,sBACrCF,EAAI,SAAW,IAAM,MAAMA,EAAI,OAAS,OAC/D,GAAK,CAACA,EAAI,GAAK,CACb,MAAMG,GAAQF,GAAA,YAAAA,EAA4D,SACnEA,GAAA,YAAAA,EAA4C,UAC9CD,EAAI,WACT,MAAM,IAAI,MAAOG,CAAI,CACvB,CACA,OAAOF,CACT,CAEqC,CACvC,EAAG,CAAEV,CAAW,CAAE,EAElB,OAAOa,EAAAA,IAAChB,EAAQ,SAAR,CAAiB,MAAAK,EAAe,SAAAD,CAAA,CAAS,CACnD,CAEO,SAASa,GAAoB,CAClC,MAAMC,EAAMC,EAAAA,WAAYnB,CAAQ,EAChC,GAAK,CAACkB,EACJ,MAAM,IAAI,MAAO,iEAAkE,EAErF,OAAOA,CACT"}
@@ -0,0 +1,35 @@
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { createContext as f, useMemo as h, useContext as w } from "react";
3
+ const i = f(null);
4
+ function I({ apiBaseUrl: t = "/api", children: m }) {
5
+ const p = h(() => {
6
+ const a = t.replace(/\/$/, ""), c = (r) => `${a}${r.startsWith("/") ? r : `/${r}`}`;
7
+ return { apiBaseUrl: a, buildUrl: c, fetchJson: async (r, e) => {
8
+ var u;
9
+ const n = new Headers(e == null ? void 0 : e.headers);
10
+ e != null && e.body && !n.has("Content-Type") && n.set("Content-Type", "application/json");
11
+ const o = await fetch(c(r), {
12
+ credentials: "include",
13
+ ...e,
14
+ headers: n
15
+ }), s = ((u = o.headers.get("content-type")) == null ? void 0 : u.includes("application/json")) && o.status !== 204 ? await o.json() : void 0;
16
+ if (!o.ok) {
17
+ const d = (s == null ? void 0 : s.error) || (s == null ? void 0 : s.message) || o.statusText;
18
+ throw new Error(d);
19
+ }
20
+ return s;
21
+ } };
22
+ }, [t]);
23
+ return /* @__PURE__ */ l(i.Provider, { value: p, children: m });
24
+ }
25
+ function j() {
26
+ const t = w(i);
27
+ if (!t)
28
+ throw new Error("useImaginariumApi must be used within an ImaginariumApiProvider");
29
+ return t;
30
+ }
31
+ export {
32
+ I,
33
+ j as u
34
+ };
35
+ //# sourceMappingURL=ImaginariumApiContext-CfXagMC6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImaginariumApiContext-CfXagMC6.js","sources":["../src/api/ImaginariumApiContext.tsx"],"sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\n\nexport interface ImaginariumApiContextValue {\n apiBaseUrl: string\n fetchJson: <T = unknown>( path: string, init?: RequestInit ) => Promise<T>\n buildUrl: ( path: string ) => string\n}\n\nconst Context = createContext<ImaginariumApiContextValue | null>( null )\n\nexport interface ImaginariumApiProviderProps {\n apiBaseUrl?: string\n children: ReactNode\n}\n\nexport function ImaginariumApiProvider( { apiBaseUrl = '/api', children }: ImaginariumApiProviderProps ) {\n const value = useMemo<ImaginariumApiContextValue>( () => {\n const base = apiBaseUrl.replace( /\\/$/, '' )\n const buildUrl = ( path: string ) => `${base}${path.startsWith( '/' ) ? path : `/${path}`}`\n\n const fetchJson = async <T = unknown>( path: string, init?: RequestInit ): Promise<T> => {\n const headers = new Headers( init?.headers )\n if ( init?.body && !headers.has( 'Content-Type' ) ) {\n headers.set( 'Content-Type', 'application/json' )\n }\n const res = await fetch( buildUrl( path ), {\n credentials: 'include',\n ...init,\n headers,\n } )\n const isJson = res.headers.get( 'content-type' )?.includes( 'application/json' )\n const body = isJson && res.status !== 204 ? await res.json() : undefined\n if ( !res.ok ) {\n const msg = ( body as { error?: string; message?: string } | undefined )?.error\n || ( body as { message?: string } | undefined )?.message\n || res.statusText\n throw new Error( msg )\n }\n return body as T\n }\n\n return { apiBaseUrl: base, buildUrl, fetchJson }\n }, [ apiBaseUrl ] )\n\n return <Context.Provider value={value}>{children}</Context.Provider>\n}\n\nexport function useImaginariumApi() {\n const ctx = useContext( Context )\n if ( !ctx ) {\n throw new Error( 'useImaginariumApi must be used within an ImaginariumApiProvider' )\n }\n return ctx\n}\n"],"names":["Context","createContext","ImaginariumApiProvider","apiBaseUrl","children","value","useMemo","base","buildUrl","path","init","headers","res","body","_a","msg","jsx","useImaginariumApi","ctx","useContext"],"mappings":";;AAQA,MAAMA,IAAUC,EAAkD,IAAK;AAOhE,SAASC,EAAwB,EAAE,YAAAC,IAAa,QAAQ,UAAAC,KAA0C;AACvG,QAAMC,IAAQC,EAAqC,MAAM;AACvD,UAAMC,IAAOJ,EAAW,QAAS,OAAO,EAAG,GACrCK,IAAW,CAAEC,MAAkB,GAAGF,CAAI,GAAGE,EAAK,WAAY,GAAI,IAAIA,IAAO,IAAIA,CAAI,EAAE;AAuBzF,WAAO,EAAE,YAAYF,GAAM,UAAAC,GAAU,WArBnB,OAAqBC,GAAcC,MAAoC;;AACvF,YAAMC,IAAU,IAAI,QAASD,KAAA,gBAAAA,EAAM,OAAQ;AAC3C,MAAKA,KAAA,QAAAA,EAAM,QAAQ,CAACC,EAAQ,IAAK,cAAe,KAC9CA,EAAQ,IAAK,gBAAgB,kBAAmB;AAElD,YAAMC,IAAM,MAAM,MAAOJ,EAAUC,CAAK,GAAG;AAAA,QACzC,aAAa;AAAA,QACb,GAAGC;AAAA,QACH,SAAAC;AAAA,MAAA,CACA,GAEIE,MADSC,IAAAF,EAAI,QAAQ,IAAK,cAAe,MAAhC,gBAAAE,EAAmC,SAAU,wBACrCF,EAAI,WAAW,MAAM,MAAMA,EAAI,SAAS;AAC/D,UAAK,CAACA,EAAI,IAAK;AACb,cAAMG,KAAQF,KAAA,gBAAAA,EAA4D,WACnEA,KAAA,gBAAAA,EAA4C,YAC9CD,EAAI;AACT,cAAM,IAAI,MAAOG,CAAI;AAAA,MACvB;AACA,aAAOF;AAAA,IACT,EAEqC;AAAA,EACvC,GAAG,CAAEV,CAAW,CAAE;AAElB,SAAO,gBAAAa,EAAChB,EAAQ,UAAR,EAAiB,OAAAK,GAAe,UAAAD,EAAA,CAAS;AACnD;AAEO,SAASa,I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