@meldgrove/ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +204 -2
  3. package/dist/components/alert-dialog.d.ts +18 -0
  4. package/dist/components/alert-dialog.js +44 -0
  5. package/dist/components/alert.d.ts +9 -0
  6. package/dist/components/alert.js +25 -0
  7. package/dist/components/avatar.d.ts +11 -0
  8. package/dist/components/avatar.js +24 -0
  9. package/dist/components/badge.d.ts +9 -0
  10. package/dist/components/badge.js +25 -0
  11. package/dist/components/breadcrumb.d.ts +11 -0
  12. package/dist/components/breadcrumb.js +28 -0
  13. package/dist/components/button-group.d.ts +11 -0
  14. package/dist/components/button-group.js +27 -0
  15. package/dist/components/button.d.ts +10 -0
  16. package/dist/components/button.js +36 -0
  17. package/dist/components/calendar.d.ts +8 -0
  18. package/dist/components/calendar.js +73 -0
  19. package/dist/components/card.d.ts +9 -0
  20. package/dist/components/card.js +25 -0
  21. package/dist/components/chart.d.ts +44 -0
  22. package/dist/components/chart.js +117 -0
  23. package/dist/components/checkbox.d.ts +4 -0
  24. package/dist/components/checkbox.js +10 -0
  25. package/dist/components/collapsible.d.ts +5 -0
  26. package/dist/components/collapsible.js +13 -0
  27. package/dist/components/command.d.ts +18 -0
  28. package/dist/components/command.js +35 -0
  29. package/dist/components/confirm-dialog.d.ts +15 -0
  30. package/dist/components/confirm-dialog.js +26 -0
  31. package/dist/components/copy-button.d.ts +6 -0
  32. package/dist/components/copy-button.js +23 -0
  33. package/dist/components/dialog.d.ts +17 -0
  34. package/dist/components/dialog.js +39 -0
  35. package/dist/components/dropdown-menu.d.ts +25 -0
  36. package/dist/components/dropdown-menu.js +53 -0
  37. package/dist/components/empty.d.ts +11 -0
  38. package/dist/components/empty.js +33 -0
  39. package/dist/components/field.d.ts +24 -0
  40. package/dist/components/field.js +74 -0
  41. package/dist/components/hover-card.d.ts +6 -0
  42. package/dist/components/hover-card.js +16 -0
  43. package/dist/components/input-group.d.ts +16 -0
  44. package/dist/components/input-group.js +64 -0
  45. package/dist/components/input.d.ts +3 -0
  46. package/dist/components/input.js +7 -0
  47. package/dist/components/item.d.ts +23 -0
  48. package/dist/components/item.js +67 -0
  49. package/dist/components/kbd.d.ts +3 -0
  50. package/dist/components/kbd.js +11 -0
  51. package/dist/components/label.d.ts +4 -0
  52. package/dist/components/label.js +9 -0
  53. package/dist/components/native-select.d.ts +8 -0
  54. package/dist/components/native-select.js +14 -0
  55. package/dist/components/pager.d.ts +7 -0
  56. package/dist/components/pager.js +11 -0
  57. package/dist/components/pagination.d.ts +13 -0
  58. package/dist/components/pagination.js +30 -0
  59. package/dist/components/popover.d.ts +10 -0
  60. package/dist/components/popover.js +28 -0
  61. package/dist/components/progress.d.ts +4 -0
  62. package/dist/components/progress.js +9 -0
  63. package/dist/components/radio-group.d.ts +5 -0
  64. package/dist/components/radio-group.js +13 -0
  65. package/dist/components/scroll-area.d.ts +5 -0
  66. package/dist/components/scroll-area.js +12 -0
  67. package/dist/components/secret-field.d.ts +23 -0
  68. package/dist/components/secret-field.js +47 -0
  69. package/dist/components/select.d.ts +15 -0
  70. package/dist/components/select.js +40 -0
  71. package/dist/components/separator.d.ts +4 -0
  72. package/dist/components/separator.js +9 -0
  73. package/dist/components/sheet.d.ts +14 -0
  74. package/dist/components/sheet.js +42 -0
  75. package/dist/components/sidebar.d.ts +70 -0
  76. package/dist/components/sidebar.js +212 -0
  77. package/dist/components/skeleton.d.ts +2 -0
  78. package/dist/components/skeleton.js +6 -0
  79. package/dist/components/sonner.d.ts +5 -0
  80. package/dist/components/sonner.js +14 -0
  81. package/dist/components/spinner.d.ts +2 -0
  82. package/dist/components/spinner.js +7 -0
  83. package/dist/components/states.d.ts +14 -0
  84. package/dist/components/states.js +18 -0
  85. package/dist/components/switch.d.ts +6 -0
  86. package/dist/components/switch.js +9 -0
  87. package/dist/components/table.d.ts +17 -0
  88. package/dist/components/table.js +34 -0
  89. package/dist/components/tabs.d.ts +11 -0
  90. package/dist/components/tabs.js +30 -0
  91. package/dist/components/textarea.d.ts +3 -0
  92. package/dist/components/textarea.js +7 -0
  93. package/dist/components/toggle-group.d.ts +9 -0
  94. package/dist/components/toggle-group.js +23 -0
  95. package/dist/components/toggle.d.ts +9 -0
  96. package/dist/components/toggle.js +27 -0
  97. package/dist/components/tooltip.d.ts +7 -0
  98. package/dist/components/tooltip.js +19 -0
  99. package/dist/hooks/use-mobile.d.ts +2 -0
  100. package/dist/hooks/use-mobile.js +13 -0
  101. package/dist/lib/format.d.ts +8 -0
  102. package/dist/lib/format.js +38 -0
  103. package/dist/lib/i18n-core.d.ts +38 -0
  104. package/dist/lib/i18n-core.js +61 -0
  105. package/dist/lib/i18n.d.ts +11 -0
  106. package/dist/lib/i18n.js +19 -0
  107. package/dist/lib/portal.d.ts +13 -0
  108. package/dist/lib/portal.js +17 -0
  109. package/dist/lib/theme.d.ts +5 -0
  110. package/dist/lib/theme.js +17 -0
  111. package/dist/lib/utils.d.ts +2 -0
  112. package/dist/lib/utils.js +5 -0
  113. package/dist/standalone/meldgrove-updates.js +57 -0
  114. package/dist/styles.css +11 -0
  115. package/dist/theme.css +62 -0
  116. package/dist/tokens.css +94 -0
  117. package/dist/updates/controller.d.ts +210 -0
  118. package/dist/updates/controller.js +592 -0
  119. package/dist/updates/core.d.ts +10 -0
  120. package/dist/updates/core.js +10 -0
  121. package/dist/updates/index.d.ts +15 -0
  122. package/dist/updates/index.js +15 -0
  123. package/dist/updates/messages.d.ts +92 -0
  124. package/dist/updates/messages.js +182 -0
  125. package/dist/updates/notice.d.ts +3 -0
  126. package/dist/updates/notice.js +6 -0
  127. package/dist/updates/react.d.ts +56 -0
  128. package/dist/updates/react.js +72 -0
  129. package/dist/updates/state.d.ts +214 -0
  130. package/dist/updates/state.js +396 -0
  131. package/dist/updates/transport.d.ts +50 -0
  132. package/dist/updates/transport.js +76 -0
  133. package/dist/updates/types.d.ts +77 -0
  134. package/dist/updates/types.js +68 -0
  135. package/dist/updates/update-button.d.ts +9 -0
  136. package/dist/updates/update-button.js +161 -0
  137. package/dist/updates/updates-settings.d.ts +17 -0
  138. package/dist/updates/updates-settings.js +97 -0
  139. package/package.json +159 -4
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,205 @@
1
- # Temporary Holding Version
1
+ # Meldgrove UI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The shared interface of the [Meldgrove](https://github.com/meldgrove) apps:
4
+ one theme, the components every app uses, and the update button. Apps take
5
+ the parts they need; an improvement here reaches every app with its next
6
+ dependency update.
7
+
8
+ ```sh
9
+ npm install @meldgrove/ui
10
+ ```
11
+
12
+ - **Theme:** design tokens (`tokens.css`) and the Tailwind CSS 4 theme
13
+ (`styles.css`), light and dark, with one accent color per app if wanted.
14
+ - **Components:** the [shadcn/ui](https://ui.shadcn.com) components of the
15
+ apps (style `new-york`, Radix UI, lucide icons), plus page states, a
16
+ confirm dialog, a copy button, a pager and a write-only secret field.
17
+ English and German.
18
+ - **Update button:** the admin's update button and the "Updates" settings of
19
+ every Meldgrove app, following the contract of the
20
+ [Meldgrove Updater](https://github.com/meldgrove/updater#the-apps-update-button).
21
+ React apps use the components; apps without React use two custom elements.
22
+
23
+ ## React apps
24
+
25
+ Peer dependencies: `react` and `react-dom` 19, `radix-ui`, `lucide-react`,
26
+ `sonner`; `cmdk` (command), `react-day-picker` (calendar) and `recharts`
27
+ (chart) only for those components.
28
+
29
+ In the app's stylesheet, after Tailwind:
30
+
31
+ ```css
32
+ @import "tailwindcss";
33
+ @import "@meldgrove/ui/styles.css";
34
+ ```
35
+
36
+ Components have one entry point each, named like the file in shadcn/ui:
37
+
38
+ ```tsx
39
+ import { Button } from "@meldgrove/ui/button";
40
+ import { Card, CardContent, CardHeader, CardTitle } from "@meldgrove/ui/card";
41
+ import { cn } from "@meldgrove/ui/utils";
42
+ ```
43
+
44
+ Client components carry `"use client"`, so Next.js server components can
45
+ import them; no `transpilePackages` is needed. `styles.css` lists every
46
+ component as a Tailwind source. An app that wants only the classes of the
47
+ components it uses imports `@meldgrove/ui/theme.css` instead and adds
48
+ `@source` lines for those files in `node_modules/@meldgrove/ui/dist/components`.
49
+
50
+ `SidebarInset` renders a `<div>`; the app's page content brings its own
51
+ `<main>`.
52
+
53
+ ### Language
54
+
55
+ Texts are English unless an `UIProvider` above the components says otherwise:
56
+
57
+ ```tsx
58
+ import { UIProvider } from "@meldgrove/ui/i18n";
59
+
60
+ <UIProvider locale="de">{children}</UIProvider>;
61
+ ```
62
+
63
+ ### Toasts
64
+
65
+ Components report through [sonner](https://sonner.emilkowal.ski). Mount the
66
+ toaster once; it follows the class `dark` on `<html>`:
67
+
68
+ ```tsx
69
+ import { Toaster } from "@meldgrove/ui/sonner";
70
+ ```
71
+
72
+ ## Colors
73
+
74
+ Every component uses the semantic tokens of shadcn/ui (`--primary`,
75
+ `--muted`, …), set in `tokens.css` for light (`:root`) and dark (`.dark`).
76
+ The accent (`--mg-accent`, `--mg-accent-foreground`) colors primary buttons,
77
+ links, the active sidebar item and the update dot.
78
+
79
+ - **One look for all apps** (the default): set nothing. A change of the
80
+ palette in this package reaches every app.
81
+ - **An accent per app:** set the two variables after the import, for light
82
+ and for dark:
83
+
84
+ ```css
85
+ :root {
86
+ --mg-accent: oklch(0.5 0.13 160);
87
+ --mg-accent-foreground: oklch(0.985 0 0);
88
+ }
89
+ .dark {
90
+ --mg-accent: oklch(0.75 0.13 160);
91
+ --mg-accent-foreground: oklch(0.2 0.02 160);
92
+ }
93
+ ```
94
+
95
+ The Meldgrove brand palette is not chosen yet; the tokens hold the neutral
96
+ palette the apps used so far.
97
+
98
+ ## Update button
99
+
100
+ The app serves the four admin routes of the updater contract (status,
101
+ `check`, `install`, `channel`). The components do the rest: polling, the
102
+ popover, the confirmation, following an installation through the restart,
103
+ reloading when the new version answers, and stopping when the session ends.
104
+
105
+ ```tsx
106
+ import { UpdateButton, UpdatesProvider, UpdatesSettingsCard } from "@meldgrove/ui/updates";
107
+
108
+ // For app admins only (everyone else gets 404 from the routes).
109
+ <UpdatesProvider
110
+ appName="Meldgrove Handbook"
111
+ project="handbook"
112
+ url="/api/admin/updates"
113
+ guideUrl="https://github.com/meldgrove/handbook/blob/main/docs/deployment.md#automatic-updates"
114
+ >
115
+ <UpdateButton /> {/* in the top bar */}
116
+ <UpdatesSettingsCard /> {/* in the admin settings; or <UpdatesSettings /> without the card */}
117
+ </UpdatesProvider>;
118
+ ```
119
+
120
+ - `url` is the status route; the others are `<url>/check`, `<url>/install`
121
+ and `<url>/channel` (a trailing slash carries over).
122
+ - `project` names the updater's systemd unit in the hint after 15 minutes
123
+ (`journalctl -u meldgrove-updater-<project>`).
124
+ - 401, 403, 404 (what the routes answer non-admins) and sign-in pages end
125
+ the session for the page: no more automatic requests. `onSignedOut(reason)`
126
+ lets the app react: `"signed-out"` (401 or a sign-in page; for example,
127
+ show the sign-in page) or `"forbidden"` (403 or 404; signed in, but no
128
+ longer an app admin).
129
+ - An app with its own API helper passes `transport` instead of `url` (see
130
+ `UpdatesTransport` in `@meldgrove/ui/updates`).
131
+ - `initialResponse`: a status the server already has, so the settings show
132
+ at once.
133
+ - `dateLocale`: full dates in another format, e.g. `de-DE` for 19.11.2026
134
+ (default `en-GB` for English, `de-DE` for German). Relative times ("2 hours
135
+ ago") follow `locale`, so an English page with German dates stays English.
136
+ `timeZone`: an IANA time zone such as `Europe/Berlin` (default: the
137
+ browser's).
138
+ - Read once when the provider mounts: `project`, `url`, `transport`,
139
+ `storageKey`/`storage`, `initialResponse`. The others follow changes.
140
+ - In Next.js, put the provider in a client component of the app when it gets
141
+ functions (`transport`, `notify`, `onSignedOut`). The status is read from
142
+ sessionStorage only after hydration, so server and client render the same.
143
+ - `@meldgrove/ui/updates/core` has the logic without React, for tests and
144
+ server code.
145
+
146
+ ## Apps without React
147
+
148
+ `dist/standalone/meldgrove-updates.js` defines `<meldgrove-update-button>`
149
+ and `<meldgrove-updates-settings>`: the same components, rendered into a
150
+ shadow root with their own styles (React included, about 150 kB gzipped).
151
+ Copy the file from the package into the app's static files and load it for
152
+ admins:
153
+
154
+ ```html
155
+ <script type="module" src="/static/meldgrove-updates.js"></script>
156
+
157
+ <meldgrove-update-button
158
+ url="/admin/updates/"
159
+ app-name="Meldgrove IAM"
160
+ project="iam"
161
+ locale="en"
162
+ theme="system"
163
+ guide-url="https://github.com/meldgrove/iam/blob/main/docs/deployment.md#automatic-updates"
164
+ ></meldgrove-update-button>
165
+
166
+ <meldgrove-updates-settings
167
+ url="/admin/updates/"
168
+ app-name="Meldgrove IAM"
169
+ project="iam"
170
+ ></meldgrove-updates-settings>
171
+ ```
172
+
173
+ | Attribute | Meaning |
174
+ | ---------------------------- | -------------------------------------------------------------------------------------- |
175
+ | `url` | The status route; elements with the same `url` share one status |
176
+ | `app-name`, `project` | As for React apps |
177
+ | `locale` | `en` (default) or `de` |
178
+ | `theme` | `class` (default: dark while `<html>` has the class `dark`), `system`, `light`, `dark` |
179
+ | `guide-url` | The deployment guide's section on automatic updates |
180
+ | `csrf-token` | Sent as `csrf-header` with every POST; without it, the cookie `csrf-cookie` |
181
+ | `csrf-cookie`, `csrf-header` | Default `csrftoken` and `X-CSRFToken` (Django) |
182
+ | `date-locale` | Format of full dates, e.g. `de-DE`; default `en-GB` for English |
183
+ | `time-zone` | IANA time zone of dates, e.g. `Europe/Berlin`; default the browser's |
184
+ | `storage-key` | sessionStorage prefix; default `meldgrove.updates.<project>` |
185
+ | `plain` | On the settings: no card of their own, for a section of the app |
186
+
187
+ The elements work under a strict Content Security Policy (`style-src
188
+ 'self'`, `script-src 'self'`): their styles are constructed style sheets.
189
+ An app's accent (`--mg-accent` on `:root`) reaches them. The React peer
190
+ dependencies are optional, so `npm install @meldgrove/ui` in an app without
191
+ React installs only a few small packages.
192
+
193
+ Apps without Tailwind can use `tokens.css` for the same colors. It switches
194
+ to dark with the class `dark` on `<html>`; an app that follows the device
195
+ sets that class from `prefers-color-scheme` in a small script.
196
+
197
+ ## Development
198
+
199
+ See [CONTRIBUTING.md](CONTRIBUTING.md). `npm run dev` opens a demo page with
200
+ every component in light and dark, English and German, and with an app
201
+ accent.
202
+
203
+ ## License
204
+
205
+ [Apache License 2.0](LICENSE).
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { AlertDialog as AlertDialogPrimitive } from "radix-ui";
3
+ import { Button } from "./button.tsx";
4
+ declare function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>): React.JSX.Element;
5
+ declare function AlertDialogTrigger({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>): React.JSX.Element;
6
+ declare function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>): React.JSX.Element;
7
+ declare function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>): React.JSX.Element;
8
+ declare function AlertDialogContent({ className, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {
9
+ size?: "default" | "sm";
10
+ }): React.JSX.Element;
11
+ declare function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
12
+ declare function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
13
+ declare function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): React.JSX.Element;
14
+ declare function AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): React.JSX.Element;
15
+ declare function AlertDialogMedia({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
16
+ declare function AlertDialogAction({ className, variant, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Action> & Pick<React.ComponentProps<typeof Button>, "variant" | "size">): React.JSX.Element;
17
+ declare function AlertDialogCancel({ className, variant, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> & Pick<React.ComponentProps<typeof Button>, "variant" | "size">): React.JSX.Element;
18
+ export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../lib/utils.js";
5
+ import { AlertDialog as AlertDialogPrimitive } from "radix-ui";
6
+ import { Button } from "./button.js";
7
+ import { usePortalContainer } from "../lib/portal.js";
8
+ function AlertDialog({ ...props }) {
9
+ return _jsx(AlertDialogPrimitive.Root, { "data-slot": "alert-dialog", ...props });
10
+ }
11
+ function AlertDialogTrigger({ ...props }) {
12
+ return _jsx(AlertDialogPrimitive.Trigger, { "data-slot": "alert-dialog-trigger", ...props });
13
+ }
14
+ function AlertDialogPortal({ ...props }) {
15
+ return (_jsx(AlertDialogPrimitive.Portal, { "data-slot": "alert-dialog-portal", container: usePortalContainer(), ...props }));
16
+ }
17
+ function AlertDialogOverlay({ className, ...props }) {
18
+ return (_jsx(AlertDialogPrimitive.Overlay, { "data-slot": "alert-dialog-overlay", className: cn("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", className), ...props }));
19
+ }
20
+ function AlertDialogContent({ className, size = "default", ...props }) {
21
+ return (_jsxs(AlertDialogPortal, { children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Content, { "data-slot": "alert-dialog-content", "data-size": size, className: cn("group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg", className), ...props })] }));
22
+ }
23
+ function AlertDialogHeader({ className, ...props }) {
24
+ return (_jsx("div", { "data-slot": "alert-dialog-header", className: cn("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", className), ...props }));
25
+ }
26
+ function AlertDialogFooter({ className, ...props }) {
27
+ return (_jsx("div", { "data-slot": "alert-dialog-footer", className: cn("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end", className), ...props }));
28
+ }
29
+ function AlertDialogTitle({ className, ...props }) {
30
+ return (_jsx(AlertDialogPrimitive.Title, { "data-slot": "alert-dialog-title", className: cn("text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2", className), ...props }));
31
+ }
32
+ function AlertDialogDescription({ className, ...props }) {
33
+ return (_jsx(AlertDialogPrimitive.Description, { "data-slot": "alert-dialog-description", className: cn("text-sm text-muted-foreground", className), ...props }));
34
+ }
35
+ function AlertDialogMedia({ className, ...props }) {
36
+ return (_jsx("div", { "data-slot": "alert-dialog-media", className: cn("mb-2 inline-flex size-16 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8", className), ...props }));
37
+ }
38
+ function AlertDialogAction({ className, variant = "default", size = "default", ...props }) {
39
+ return (_jsx(Button, { variant: variant, size: size, asChild: true, children: _jsx(AlertDialogPrimitive.Action, { "data-slot": "alert-dialog-action", className: cn(className), ...props }) }));
40
+ }
41
+ function AlertDialogCancel({ className, variant = "outline", size = "default", ...props }) {
42
+ return (_jsx(Button, { variant: variant, size: size, asChild: true, children: _jsx(AlertDialogPrimitive.Cancel, { "data-slot": "alert-dialog-cancel", className: cn(className), ...props }) }));
43
+ }
44
+ export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, };
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare const alertVariants: (props?: ({
4
+ variant?: "default" | "destructive" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): React.JSX.Element;
7
+ declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
8
+ declare function AlertDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
9
+ export { Alert, AlertTitle, AlertDescription };
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { cva } from "class-variance-authority";
4
+ import { cn } from "../lib/utils.js";
5
+ const alertVariants = cva("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", {
6
+ variants: {
7
+ variant: {
8
+ default: "bg-card text-card-foreground",
9
+ destructive: "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current",
10
+ },
11
+ },
12
+ defaultVariants: {
13
+ variant: "default",
14
+ },
15
+ });
16
+ function Alert({ className, variant, ...props }) {
17
+ return (_jsx("div", { "data-slot": "alert", role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
18
+ }
19
+ function AlertTitle({ className, ...props }) {
20
+ return (_jsx("div", { "data-slot": "alert-title", className: cn("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight", className), ...props }));
21
+ }
22
+ function AlertDescription({ className, ...props }) {
23
+ return (_jsx("div", { "data-slot": "alert-description", className: cn("col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed", className), ...props }));
24
+ }
25
+ export { Alert, AlertTitle, AlertDescription };
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import { Avatar as AvatarPrimitive } from "radix-ui";
3
+ declare function Avatar({ className, size, ...props }: React.ComponentProps<typeof AvatarPrimitive.Root> & {
4
+ size?: "default" | "sm" | "lg";
5
+ }): React.JSX.Element;
6
+ declare function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>): React.JSX.Element;
7
+ declare function AvatarFallback({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Fallback>): React.JSX.Element;
8
+ declare function AvatarBadge({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
9
+ declare function AvatarGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
10
+ declare function AvatarGroupCount({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
11
+ export { Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup, AvatarGroupCount };
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../lib/utils.js";
5
+ import { Avatar as AvatarPrimitive } from "radix-ui";
6
+ function Avatar({ className, size = "default", ...props }) {
7
+ return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", "data-size": size, className: cn("group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6", className), ...props }));
8
+ }
9
+ function AvatarImage({ className, ...props }) {
10
+ return (_jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", className: cn("aspect-square size-full", className), ...props }));
11
+ }
12
+ function AvatarFallback({ className, ...props }) {
13
+ return (_jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", className: cn("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs", className), ...props }));
14
+ }
15
+ function AvatarBadge({ className, ...props }) {
16
+ return (_jsx("span", { "data-slot": "avatar-badge", className: cn("absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground ring-2 ring-background select-none", "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden", "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2", "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2", className), ...props }));
17
+ }
18
+ function AvatarGroup({ className, ...props }) {
19
+ return (_jsx("div", { "data-slot": "avatar-group", className: cn("group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background", className), ...props }));
20
+ }
21
+ function AvatarGroupCount({ className, ...props }) {
22
+ return (_jsx("div", { "data-slot": "avatar-group-count", className: cn("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3", className), ...props }));
23
+ }
24
+ export { Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup, AvatarGroupCount };
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare const badgeVariants: (props?: ({
4
+ variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
7
+ asChild?: boolean;
8
+ }): React.JSX.Element;
9
+ export { Badge, badgeVariants };
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { cva } from "class-variance-authority";
4
+ import { cn } from "../lib/utils.js";
5
+ import { Slot } from "radix-ui";
6
+ const badgeVariants = cva("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3", {
7
+ variants: {
8
+ variant: {
9
+ default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
10
+ secondary: "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
11
+ destructive: "bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
12
+ outline: "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
13
+ ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
14
+ link: "text-primary underline-offset-4 [a&]:hover:underline",
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ variant: "default",
19
+ },
20
+ });
21
+ function Badge({ className, variant = "default", asChild = false, ...props }) {
22
+ const Comp = asChild ? Slot.Root : "span";
23
+ return (_jsx(Comp, { "data-slot": "badge", "data-variant": variant, className: cn(badgeVariants({ variant }), className), ...props }));
24
+ }
25
+ export { Badge, badgeVariants };
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ declare function Breadcrumb({ ...props }: React.ComponentProps<"nav">): React.JSX.Element;
3
+ declare function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">): React.JSX.Element;
4
+ declare function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
5
+ declare function BreadcrumbLink({ asChild, className, ...props }: React.ComponentProps<"a"> & {
6
+ asChild?: boolean;
7
+ }): React.JSX.Element;
8
+ declare function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
9
+ declare function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
10
+ declare function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
11
+ export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, };
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { cn } from "../lib/utils.js";
4
+ import { ChevronRight, MoreHorizontal } from "lucide-react";
5
+ import { Slot } from "radix-ui";
6
+ function Breadcrumb({ ...props }) {
7
+ return _jsx("nav", { "aria-label": "breadcrumb", "data-slot": "breadcrumb", ...props });
8
+ }
9
+ function BreadcrumbList({ className, ...props }) {
10
+ return (_jsx("ol", { "data-slot": "breadcrumb-list", className: cn("flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5", className), ...props }));
11
+ }
12
+ function BreadcrumbItem({ className, ...props }) {
13
+ return (_jsx("li", { "data-slot": "breadcrumb-item", className: cn("inline-flex items-center gap-1.5", className), ...props }));
14
+ }
15
+ function BreadcrumbLink({ asChild, className, ...props }) {
16
+ const Comp = asChild ? Slot.Root : "a";
17
+ return (_jsx(Comp, { "data-slot": "breadcrumb-link", className: cn("transition-colors hover:text-foreground", className), ...props }));
18
+ }
19
+ function BreadcrumbPage({ className, ...props }) {
20
+ return (_jsx("span", { "data-slot": "breadcrumb-page", role: "link", "aria-disabled": "true", "aria-current": "page", className: cn("font-normal text-foreground", className), ...props }));
21
+ }
22
+ function BreadcrumbSeparator({ children, className, ...props }) {
23
+ return (_jsx("li", { "data-slot": "breadcrumb-separator", role: "presentation", "aria-hidden": "true", className: cn("[&>svg]:size-3.5", className), ...props, children: children ?? _jsx(ChevronRight, {}) }));
24
+ }
25
+ function BreadcrumbEllipsis({ className, ...props }) {
26
+ return (_jsxs("span", { "data-slot": "breadcrumb-ellipsis", role: "presentation", "aria-hidden": "true", className: cn("flex size-9 items-center justify-center", className), ...props, children: [_jsx(MoreHorizontal, { className: "size-4" }), _jsx("span", { className: "sr-only", children: "More" })] }));
27
+ }
28
+ export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, };
@@ -0,0 +1,11 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import { Separator } from "./separator.tsx";
3
+ declare const buttonGroupVariants: (props?: ({
4
+ orientation?: "horizontal" | "vertical" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ declare function ButtonGroup({ className, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>): import("react").JSX.Element;
7
+ declare function ButtonGroupText({ className, asChild, ...props }: React.ComponentProps<"div"> & {
8
+ asChild?: boolean;
9
+ }): import("react").JSX.Element;
10
+ declare function ButtonGroupSeparator({ className, orientation, ...props }: React.ComponentProps<typeof Separator>): import("react").JSX.Element;
11
+ export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants };