@glimstone/react 0.0.0-stage → 4.0.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 (64) hide show
  1. package/README.md +118 -2
  2. package/dist/AboutCard.d.ts +152 -0
  3. package/dist/AboutCard.js +82 -0
  4. package/dist/Badge.d.ts +47 -0
  5. package/dist/Badge.js +35 -0
  6. package/dist/Button.d.ts +54 -0
  7. package/dist/Button.js +52 -0
  8. package/dist/Card.d.ts +29 -0
  9. package/dist/Card.js +20 -0
  10. package/dist/CoffeeDialog.d.ts +17 -0
  11. package/dist/CoffeeDialog.js +9 -0
  12. package/dist/Combobox.d.ts +16 -0
  13. package/dist/Combobox.js +32 -0
  14. package/dist/ConfirmDialog.d.ts +29 -0
  15. package/dist/ConfirmDialog.js +15 -0
  16. package/dist/CryptoDonateDialog.d.ts +61 -0
  17. package/dist/CryptoDonateDialog.js +23 -0
  18. package/dist/DropdownListbox.d.ts +22 -0
  19. package/dist/DropdownListbox.js +182 -0
  20. package/dist/EmptyState.d.ts +19 -0
  21. package/dist/EmptyState.js +10 -0
  22. package/dist/IconTipButton.d.ts +18 -0
  23. package/dist/IconTipButton.js +13 -0
  24. package/dist/InfoBubble.d.ts +4 -0
  25. package/dist/InfoBubble.js +19 -0
  26. package/dist/NumberField.d.ts +16 -0
  27. package/dist/NumberField.js +18 -0
  28. package/dist/PaypalDialog.d.ts +51 -0
  29. package/dist/PaypalDialog.js +20 -0
  30. package/dist/ReadmeButton.d.ts +29 -0
  31. package/dist/ReadmeButton.js +27 -0
  32. package/dist/Select.d.ts +41 -0
  33. package/dist/Select.js +192 -0
  34. package/dist/Selector.d.ts +67 -0
  35. package/dist/Selector.js +128 -0
  36. package/dist/SidebarRow.d.ts +22 -0
  37. package/dist/SidebarRow.js +10 -0
  38. package/dist/Slider.d.ts +12 -0
  39. package/dist/Slider.js +18 -0
  40. package/dist/SubCard.d.ts +15 -0
  41. package/dist/SubCard.js +14 -0
  42. package/dist/Toast.d.ts +29 -0
  43. package/dist/Toast.js +24 -0
  44. package/dist/Toggle.d.ts +16 -0
  45. package/dist/Toggle.js +4 -0
  46. package/dist/UnavailableNotice.d.ts +15 -0
  47. package/dist/UnavailableNotice.js +12 -0
  48. package/dist/WindowBar.d.ts +24 -0
  49. package/dist/WindowBar.js +31 -0
  50. package/dist/glyphs.d.ts +22 -0
  51. package/dist/glyphs.js +30 -0
  52. package/dist/index.d.ts +28 -0
  53. package/dist/index.js +28 -0
  54. package/dist/portalHue.d.ts +10 -0
  55. package/dist/portalHue.js +15 -0
  56. package/dist/useConfirm.d.ts +26 -0
  57. package/dist/useConfirm.js +39 -0
  58. package/dist/useLabelMode.d.ts +6 -0
  59. package/dist/useLabelMode.js +11 -0
  60. package/dist/usePaypalButtons.d.ts +15 -0
  61. package/dist/usePaypalButtons.js +42 -0
  62. package/dist/useTipBubble.d.ts +34 -0
  63. package/dist/useTipBubble.js +63 -0
  64. package/package.json +28 -4
package/README.md CHANGED
@@ -1,3 +1,119 @@
1
- # Temporary Holding Version
1
+ # @glimstone/react
2
+
3
+ The components of [GlimStone](https://junkerderprovinz.github.io/glimstone/) for
4
+ React 19. `@glimstone/core` says what a control must look like and decides what
5
+ it shows; these say what a control **is**, so an app uses them rather than
6
+ rebuilding them.
7
+
8
+ That distinction is the reason this package exists. Two apps built from the
9
+ prose alone arrived at the same design language in two different dialects: one
10
+ calls the switch `Toggle` and keeps it in `components/Toggle.tsx`, the other
11
+ calls it `Switch` and keeps it inside a `Field.tsx` next to six other controls;
12
+ one has `ConfirmDialog`, the other has `Confirm`. Every one of those is a correct
13
+ reading of the same document, and every rule would then have to be re-applied
14
+ by hand in each dialect.
15
+
16
+ ## Using it
17
+
18
+ ```sh
19
+ npm install @glimstone/core @glimstone/react
20
+ ```
21
+
22
+ ```tsx
23
+ import "@glimstone/core/tokens.css";
24
+ import { applyCachedAppearance, applyStoredLabelModes } from "@glimstone/core";
25
+ import { Button, setGlyphResolver } from "@glimstone/react";
26
+ import { Select } from "@glimstone/react/Select";
27
+
28
+ applyCachedAppearance();
29
+ applyStoredLabelModes();
30
+ setGlyphResolver((key) => appGlyphs[key]);
31
+ ```
32
+
33
+ Call the two `apply` functions at the app root before the first render, not
34
+ from the settings page that edits them, or the app opens in the default look
35
+ and snaps over. `setStoragePrefix()` before them keeps choices an app already
36
+ stored under its own name. Under Tailwind v4 load
37
+ `@glimstone/core/tailwind-theme.css` after the tokens; the components themselves
38
+ use no Tailwind class.
39
+
40
+ `Select`, `Combobox` and `Slider` come from their own entries and need
41
+ `@zag-js/react` with their machine packages (`@zag-js/select` and
42
+ `@zag-js/menu`, `@zag-js/combobox`, `@zag-js/slider`). The rest of the package
43
+ needs none of them.
44
+
45
+ ## What's here
46
+
47
+ | Component | What it is |
48
+ |---|---|
49
+ | `Button` | Every button, including the label engine's text/glyph/both modes and the chip form |
50
+ | `Toggle` | The switch. Never a checkbox |
51
+ | `Card` | The surface, and the one place a section heading is drawn |
52
+ | `Badge` | Status pills and the filled section heading the card draws |
53
+ | `Select` | The one dropdown, on Zag's select machine and on its menu machine for a list with submenus |
54
+ | `Combobox` | A field that filters a long list as somebody types |
55
+ | `Slider` | A value on a range, with the value in words beside the label |
56
+ | `DropdownListbox` | Deprecated, use `Select` |
57
+ | `ConfirmDialog` + `useConfirm` | The confirm surface for a destructive action, and the hook that gives it a portal, Escape, the Tab trap and focus back to the control that asked |
58
+ | `ToastViewport` | Transient feedback; the queue is the core's `toastEngine` |
59
+ | `InfoBubble`, `IconTipButton` | The "(i)" explanation and the hover name on an icon-only control |
60
+ | `InfoTile` | The Info tile with its Version, Help and About cards, each also on its own |
61
+ | `ReadmeButton` | The button in the shape of the README's, with its segments |
62
+ | `CryptoDonateDialog`, `CoffeeDialog`, `PaypalDialog` | The three windows to give |
63
+ | `Selector` | The one horizontal selector: tabs, filter bars, segmented pickers, one value or many, and with `orientation="vertical"` the column of tiles beside a settings area's pages |
64
+ | `NumberField` | A number with its two steppers inside the field and the wheel while it has focus |
65
+ | `SidebarRow` | One row of the rail: glyph, words by the label mode, the current page and a count |
66
+ | `EmptyState` | What a list, table or panel shows when it holds nothing |
67
+ | `SubCard` | A filled inset group inside a card, which replaces a fold-out |
68
+ | `UnavailableNotice` | What stands where a control would be, when the environment forbids the thing entirely |
69
+ | `WindowBar` | A desktop app's own title bar on Windows and Linux |
70
+ | `useLabelMode`, `useTipBubble`, `usePortalHue` | The small hooks the components need |
71
+ | `glyphs` | The marks the components draw themselves, and `setGlyphResolver`, the seam an app registers its own icon set through |
72
+
73
+ ## What is not here
74
+
75
+ **The icon set.** An icon's meaning belongs to the app: only it knows that its
76
+ own action is called "backup now". GlimStone ships the assortment as a
77
+ specification (`glyphs.md` in the core) and one function, `setGlyphResolver`,
78
+ that a button asks by meaning. Register it once at boot and every button can be
79
+ shown in glyph mode; skip it and buttons fall back to the glyph they are handed,
80
+ then to text alone.
81
+
82
+ **Translation.** Every string is a prop. The components carry the order and the
83
+ behaviour, the app carries its own language.
84
+
85
+ **Data.** No component fetches anything. The Version card takes its versions
86
+ as props and its update check as a function rather than reading a health
87
+ endpoint, so the same component serves an app with a different one.
88
+
89
+ ## The Info tile
90
+
91
+ `InfoTile` takes one prop object per card and a `hueIndex` for the first of
92
+ them; the others take the next positions. It returns the cards without a
93
+ wrapper, so they stack in the page's own rhythm.
94
+
95
+ - **Version:** `rows` lists the app first, then GlimStone and every component
96
+ the app ships, each with a `name`, an optional `sub` line, the `version` read
97
+ from the build and the `repoUrl` whose release page the number opens. A row
98
+ without `repoUrl`, or a build that is not a published release, shows the
99
+ number as plain text. `updateCheck.run` checks them all and resolves to how
100
+ many have a newer release; the button turns `ok` with `upToDate`, `warn` with
101
+ `updatesFound(n)`, or `danger` with `checkFailed` and a shake when it rejects.
102
+ The app puts the reason for a failure in its toast. One button stands
103
+ before the check: `whatsNew`, the app's own "New · n" button, which opens its
104
+ window with the release notes and the changes as tabs, or, in an app that
105
+ marks no changes, "Release notes" from `onReleaseNotes` with
106
+ `text.releaseNotes`, which opens the notes alone. The card never draws both.
107
+ - **Help:** the report sentence, GitHub, Email with `MAIL_SVG` when the
108
+ sentence names a mail route and `mailAddress` is set, the manual when
109
+ `manualUrl` and `text.manual` are set, with `MANUAL_SVG` as `manualGlyph` and
110
+ "Open" as `text.manualSub`, and the bug report when `onBugReport` and
111
+ `text.bugReport` are set, with `IconDiagnostics` as `bugGlyph` and "Download"
112
+ as `text.bugReportSub`.
113
+ - **About:** the maker's sentence, then the sentence about the money with the
114
+ give row under it.
115
+
116
+ The glyphs on the update check come from the app's resolver under the keys
117
+ `about.checkUpdates`, `about.upToDate`, `about.updatesFound` and
118
+ `about.checkFailed`, and the one on "Release notes" under `about.releaseNotes`.
2
119
 
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.
@@ -0,0 +1,152 @@
1
+ import { type ReactNode } from "react";
2
+ import { type OpenUrl, type UpdateCheck, type VersionRow } from "@glimstone/core";
3
+ export type { UpdateCheck, VersionRow } from "@glimstone/core";
4
+ export interface InfoAboutCardProps {
5
+ text: {
6
+ title: string;
7
+ body: string;
8
+ coffee: string;
9
+ /** The coffee button's accessible name; its artwork carries the words. */
10
+ coffeeButton: string;
11
+ /** The second give button. Only drawn together with `onPaypal`. */
12
+ paypalButton?: string;
13
+ /** The third. Only drawn together with `onCrypto`. */
14
+ cryptoButton?: string;
15
+ };
16
+ /** Opens the coffee window (CoffeeDialog), which stays inside the app. */
17
+ onCoffee: () => void;
18
+ /** Buy Me a Coffee's own button artwork, `COFFEE_BUTTON_SVG` from appMarks.ts. */
19
+ coffeeArt: ReactNode;
20
+ /** Opens the PayPal window (PaypalDialog). Omit it where the maker takes no
21
+ * PayPal donations. */
22
+ onPaypal?: () => void;
23
+ /**
24
+ * The marks on the other give buttons. They are passed rather than resolved
25
+ * by label key, because a rule keyed on "crypto" would put a currency's
26
+ * symbol on settings that have nothing to do with it.
27
+ */
28
+ paypalGlyph?: ReactNode;
29
+ /** Opens the crypto window (CryptoDonateDialog). Omit it and the card offers
30
+ * no crypto button. */
31
+ onCrypto?: () => void;
32
+ cryptoGlyph?: ReactNode;
33
+ hueIndex?: number;
34
+ }
35
+ /** The last card of the Info tile: who made the app, then the give row. */
36
+ export declare function InfoAboutCard({ text, onCoffee, coffeeArt, onPaypal, paypalGlyph, onCrypto, cryptoGlyph, hueIndex, }: InfoAboutCardProps): import("react").JSX.Element;
37
+ export interface InfoVersionCardProps {
38
+ text: {
39
+ title: string;
40
+ /** The card's "(i)", such as what a click on a number opens. */
41
+ hint?: string;
42
+ unreleased: (version: string) => string;
43
+ /** "Release notes". Only drawn with `onReleaseNotes` and without `whatsNew`. */
44
+ releaseNotes?: string;
45
+ };
46
+ /** The app first, then the design language, then every component it ships. */
47
+ rows: VersionRow[];
48
+ /** "Check for updates" at the bottom of the card. Omit it and the card
49
+ * offers no check. */
50
+ updateCheck?: UpdateCheck;
51
+ /** Opens the app's window on the running version's release notes, for an
52
+ * app that marks no changes. */
53
+ onReleaseNotes?: () => void;
54
+ /** The app's own "New · n" button, wearing `IconWhatsNew` with the dot in
55
+ * front. It takes the place of "Release notes", so the card has one button there. */
56
+ whatsNew?: ReactNode;
57
+ openUrl?: OpenUrl;
58
+ hueIndex?: number;
59
+ }
60
+ /** The first card: every version as a row, and the New or Release notes button and the update check under them. */
61
+ export declare function InfoVersionCard({ text, rows, updateCheck, onReleaseNotes, whatsNew, openUrl, hueIndex, }: InfoVersionCardProps): import("react").JSX.Element;
62
+ export interface InfoHelpCardProps {
63
+ text: {
64
+ title?: string;
65
+ /** The card's "(i)", such as what the bug report holds. */
66
+ hint?: string;
67
+ report: string;
68
+ repoButton: string;
69
+ mailButton: string;
70
+ mailSubject: string;
71
+ /** "Bug report". Only drawn together with `onBugReport`. */
72
+ bugReport?: string;
73
+ /** The bug report's second line, "Download". */
74
+ bugReportSub?: string;
75
+ /** "Manual". Only drawn together with `manualUrl`. */
76
+ manual?: string;
77
+ /** The manual's second line, "Open". */
78
+ manualSub?: string;
79
+ };
80
+ repoUrl: string;
81
+ /** The mark on the repository button, passed for the same reason as the
82
+ * give buttons' marks. */
83
+ repoGlyph?: ReactNode;
84
+ /** The workshop's own mailbox. Omit it and the card offers no mail route. */
85
+ mailAddress?: string;
86
+ /** The envelope, `MAIL_SVG` from appMarks.ts, which opens under the pointer. */
87
+ mailGlyph?: ReactNode;
88
+ /** The app's handbook. Omit it where the app has none; the README is not a
89
+ * manual. */
90
+ manualUrl?: string;
91
+ /** The book, `MANUAL_SVG` from appMarks.ts, which opens under the pointer. */
92
+ manualGlyph?: ReactNode;
93
+ /** Downloads the instance's logs and settings as one file, without
94
+ * passwords, keys or credentials. */
95
+ onBugReport?: () => void;
96
+ /** `IconDiagnostics`, the bug. */
97
+ bugGlyph?: ReactNode;
98
+ openUrl?: OpenUrl;
99
+ hueIndex?: number;
100
+ }
101
+ /** The second card: a sentence inviting a report, then GitHub, Email, the manual and the bug report. */
102
+ export declare function InfoHelpCard({ text, repoUrl, repoGlyph, mailAddress, mailGlyph, manualUrl, manualGlyph, onBugReport, bugGlyph, openUrl, hueIndex, }: InfoHelpCardProps): import("react").JSX.Element;
103
+ export interface InfoTileProps {
104
+ version: Omit<InfoVersionCardProps, "hueIndex">;
105
+ help: Omit<InfoHelpCardProps, "hueIndex">;
106
+ about: Omit<InfoAboutCardProps, "hueIndex">;
107
+ /** The Version card's rainbow position; the cards after it take the next ones. */
108
+ hueIndex?: number;
109
+ }
110
+ /** The Info tile's cards in their fixed order, for the page that stacks them. */
111
+ export declare function InfoTile({ version, help, about, hueIndex }: InfoTileProps): import("react").JSX.Element;
112
+ /**
113
+ * The 3.2.0 props of the single About card, laid out as the Info tile: the
114
+ * About card under `text.title`, the Version card under `text.version` with the
115
+ * app and GlimStone as its rows, and the Help card.
116
+ *
117
+ * @deprecated Use `InfoTile`, which adds the version rows' sub-lines, the
118
+ * other components, "Check for updates" and the bug report.
119
+ */
120
+ export declare function AboutCard({ text, version, glimstoneVersion, repoUrl, repoGlyph, glimstoneRepoUrl, onCoffee, coffeeArt, cryptoGlyph, paypalGlyph, onPaypal, onCrypto, mailAddress, mailGlyph, openUrl, hueIndex, }: {
121
+ text: {
122
+ title: string;
123
+ body: string;
124
+ coffee: string;
125
+ coffeeButton: string;
126
+ cryptoButton?: string;
127
+ paypalButton?: string;
128
+ report: string;
129
+ repoButton: string;
130
+ mailButton: string;
131
+ mailSubject: string;
132
+ version: string;
133
+ unreleased: (version: string) => string;
134
+ /** The Help card's heading. Without it the card draws none. */
135
+ helpTitle?: string;
136
+ };
137
+ version: string | null;
138
+ glimstoneVersion: string;
139
+ repoUrl: string;
140
+ repoGlyph?: ReactNode;
141
+ glimstoneRepoUrl: string;
142
+ onCoffee: () => void;
143
+ coffeeArt: ReactNode;
144
+ cryptoGlyph?: ReactNode;
145
+ paypalGlyph?: ReactNode;
146
+ onPaypal?: () => void;
147
+ onCrypto?: () => void;
148
+ mailAddress?: string;
149
+ mailGlyph?: ReactNode;
150
+ openUrl?: (url: string) => void;
151
+ hueIndex?: number;
152
+ }): import("react").JSX.Element;
@@ -0,0 +1,82 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { mailHref, offersMail, openInBrowser, runUpdateCheck, updateFace, updateStage, versionLink, } from "@glimstone/core";
4
+ import { Button } from "./Button.js";
5
+ import { Card } from "./Card.js";
6
+ import { ReadmeButton } from "./ReadmeButton.js";
7
+ /** The last card of the Info tile: who made the app, then the give row. */
8
+ export function InfoAboutCard({ text, onCoffee, coffeeArt, onPaypal, paypalGlyph, onCrypto, cryptoGlyph, hueIndex, }) {
9
+ return (_jsxs(Card, { title: text.title, hueIndex: hueIndex, children: [_jsx("p", { className: "glim-info-text", children: text.body }), _jsx("p", { className: "glim-info-text", children: text.coffee }), _jsxs("div", { className: "glim-readme-btn-rows glim-about-give", children: [_jsx(ReadmeButton, { brand: "coffee", parts: [{ name: text.coffeeButton, onClick: onCoffee }], art: coffeeArt }), onPaypal && text.paypalButton && (_jsx(ReadmeButton, { brand: "paypal", parts: [{ name: text.paypalButton, onClick: onPaypal }], mark: paypalGlyph, markClass: "glim-paypal-mark" })), onCrypto && text.cryptoButton && (_jsx(ReadmeButton, { brand: "bitcoin", parts: [{ name: text.cryptoButton, onClick: onCrypto }], mark: cryptoGlyph, markClass: "glim-bitcoin-mark" }))] })] }));
10
+ }
11
+ /** The first card: every version as a row, and the New or Release notes button and the update check under them. */
12
+ export function InfoVersionCard({ text, rows, updateCheck, onReleaseNotes, whatsNew, openUrl = openInBrowser, hueIndex, }) {
13
+ const notes = !whatsNew && onReleaseNotes && text.releaseNotes;
14
+ return (_jsxs(Card, { title: text.title, hint: text.hint, hueIndex: hueIndex, children: [_jsx("ul", { className: "glim-version-rows", children: rows.map((row) => (_jsxs("li", { className: "glim-version-row", children: [_jsxs("span", { className: "glim-version-name", children: [_jsx("span", { className: "glim-version-part", children: row.name }), row.sub && _jsx("span", { className: "glim-version-sub", children: row.sub })] }), _jsx(VersionNumber, { row: row, unreleased: text.unreleased, openUrl: openUrl })] }, row.name))) }), (notes || whatsNew || updateCheck) && (_jsxs("div", { className: "glim-version-actions", children: [notes && _jsx(Button, { label: notes, labelKey: "about.releaseNotes", onClick: onReleaseNotes }), whatsNew, updateCheck && _jsx(UpdateCheckButton, { ...updateCheck })] }))] }));
15
+ }
16
+ /** The update check shows its verdict on itself, like a test button. */
17
+ function UpdateCheckButton(check) {
18
+ const [verdict, setVerdict] = useState({ kind: "idle" });
19
+ const [shake, setShake] = useState(0);
20
+ const face = updateFace(verdict, check.text);
21
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { label: face.label, labelKey: face.labelKey, tone: face.tone, stage: updateStage(check.text, face.label), busy: verdict.kind === "busy", onClick: () => void runUpdateCheck(check, verdict, (v) => {
22
+ setVerdict(v);
23
+ if (v.kind === "failed")
24
+ setShake((n) => n + 1);
25
+ }), className: shake > 0 ? "glim-shake" : "" }, shake), _jsx("span", { role: "status", className: "glim-sr-only", children: face.announced })] }));
26
+ }
27
+ /**
28
+ * The number at a row's end, a link to its release page when it is a published
29
+ * release. It has no underline; the ink lifts on hover.
30
+ */
31
+ function VersionNumber({ row, unreleased, openUrl }) {
32
+ const { shown, released, href } = versionLink(row);
33
+ if (!href)
34
+ return _jsx("span", { className: "glim-num glim-version-number", children: released ? shown : unreleased(shown) });
35
+ return (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", onClick: (e) => {
36
+ e.preventDefault();
37
+ openUrl(href);
38
+ }, className: "glim-num glim-version-number", children: shown }));
39
+ }
40
+ /** The second card: a sentence inviting a report, then GitHub, Email, the manual and the bug report. */
41
+ export function InfoHelpCard({ text, repoUrl, repoGlyph, mailAddress, mailGlyph, manualUrl, manualGlyph, onBugReport, bugGlyph, openUrl = openInBrowser, hueIndex, }) {
42
+ const wantsMail = offersMail(text.report, mailAddress);
43
+ return (_jsxs(Card, { title: text.title, hint: text.hint, hueIndex: hueIndex, children: [_jsx("p", { className: "glim-info-text", children: text.report }), _jsxs("div", { className: "glim-readme-btn-rows", children: [_jsx(ReadmeButton, { brand: "github", parts: [{ name: text.repoButton, onClick: () => openUrl(repoUrl) }], mark: repoGlyph, markClass: "glim-github-mark" }), wantsMail && (_jsx(ReadmeButton, { brand: "house", parts: [
44
+ {
45
+ name: text.mailButton,
46
+ onClick: () => openUrl(mailHref(mailAddress, text.mailSubject)),
47
+ },
48
+ ], mark: mailGlyph, markClass: "glim-house-mark" })), manualUrl && text.manual && (_jsx(ReadmeButton, { brand: "docs", parts: [{ name: text.manual, sub: text.manualSub, onClick: () => openUrl(manualUrl) }], mark: manualGlyph, markClass: "glim-docs-mark" })), onBugReport && text.bugReport && (_jsx(ReadmeButton, { brand: "github", parts: [{ name: text.bugReport, sub: text.bugReportSub, onClick: onBugReport }], mark: bugGlyph }))] })] }));
49
+ }
50
+ /** The Info tile's cards in their fixed order, for the page that stacks them. */
51
+ export function InfoTile({ version, help, about, hueIndex }) {
52
+ const at = (offset) => (hueIndex === undefined ? undefined : hueIndex + offset);
53
+ return (_jsxs(_Fragment, { children: [_jsx(InfoVersionCard, { ...version, hueIndex: at(0) }), _jsx(InfoHelpCard, { ...help, hueIndex: at(1) }), _jsx(InfoAboutCard, { ...about, hueIndex: at(2) })] }));
54
+ }
55
+ /**
56
+ * The 3.2.0 props of the single About card, laid out as the Info tile: the
57
+ * About card under `text.title`, the Version card under `text.version` with the
58
+ * app and GlimStone as its rows, and the Help card.
59
+ *
60
+ * @deprecated Use `InfoTile`, which adds the version rows' sub-lines, the
61
+ * other components, "Check for updates" and the bug report.
62
+ */
63
+ export function AboutCard({ text, version, glimstoneVersion, repoUrl, repoGlyph, glimstoneRepoUrl, onCoffee, coffeeArt, cryptoGlyph, paypalGlyph, onPaypal, onCrypto, mailAddress, mailGlyph, openUrl = openInBrowser, hueIndex, }) {
64
+ const rows = [
65
+ ...(version ? [{ name: text.version, version, repoUrl }] : []),
66
+ { name: "GlimStone", version: glimstoneVersion, repoUrl: glimstoneRepoUrl },
67
+ ];
68
+ return (_jsx(InfoTile, { hueIndex: hueIndex, about: { text, onCoffee, coffeeArt, onPaypal, paypalGlyph, onCrypto, cryptoGlyph }, version: { text: { title: text.version, unreleased: text.unreleased }, rows, openUrl }, help: {
69
+ text: {
70
+ title: text.helpTitle,
71
+ report: text.report,
72
+ repoButton: text.repoButton,
73
+ mailButton: text.mailButton,
74
+ mailSubject: text.mailSubject,
75
+ },
76
+ repoUrl,
77
+ repoGlyph,
78
+ mailAddress,
79
+ mailGlyph,
80
+ openUrl,
81
+ } }));
82
+ }
@@ -0,0 +1,47 @@
1
+ import type { ReactNode } from "react";
2
+ import { type BadgeShape, type BadgeSize, type BadgeTone, type NotchInset } from "@glimstone/core";
3
+ export type { BadgeShape, BadgeSize, BadgeTone, NotchInset } from "@glimstone/core";
4
+ export interface BadgeProps {
5
+ children: ReactNode;
6
+ /** Status colour. Defaults to the neutral chip. */
7
+ tone?: BadgeTone;
8
+ /** Size stage; see badgeClassName in the core. A square icon-only badge is always
9
+ * `"icon"`. */
10
+ size?: BadgeSize;
11
+ shape?: BadgeShape;
12
+ /** Render as a <button> or a real <a href>, with the same box as a span. */
13
+ as?: "span" | "button" | "a";
14
+ onClick?: () => void;
15
+ disabled?: boolean;
16
+ title?: string;
17
+ /** Accessible name for an icon-only badge whose glyph is aria-hidden. */
18
+ ariaLabel?: string;
19
+ /** `as="a"` only: passed straight through to the underlying <a>. */
20
+ href?: string;
21
+ target?: string;
22
+ rel?: string;
23
+ /** Let content that wraps grow the box instead of overflowing it. */
24
+ wrap?: boolean;
25
+ /** Extra classes, such as `tabular-nums` for a count, or `max-w-full` with
26
+ * `wrap` in a narrow column. */
27
+ className?: string;
28
+ /** Rainbow position, by the caller's list index among the badges visible at
29
+ * once. Only `heading` and `active` take it, since the other tones are
30
+ * status signals. Omit it for the only such badge on a page, which keeps
31
+ * the single accent. */
32
+ hueIndex?: number;
33
+ /** `as="button"` only. The tooltip and accessible name of an icon-only
34
+ * button, rendered through IconTipButton; it also makes the badge
35
+ * icon-only for sizing, and replaces `title` and `ariaLabel`. */
36
+ tip?: string;
37
+ /** Heading notch only: the card's content padding in quarter-rem steps
38
+ * (`insetStart={5}` for 1.25rem), for the two cases NotchInset describes.
39
+ * Omit it where the static position already lands right. */
40
+ insetStart?: NotchInset;
41
+ /** Heading notch only: keep the notch's look without positioning it, for
42
+ * several heading badges that straddle one card edge together inside a
43
+ * caller-positioned <h2>. `insetStart` is ignored alongside it. A heading
44
+ * badge in normal flow is a `tone="heading"` badge at another size. */
45
+ inFlow?: boolean;
46
+ }
47
+ export declare function Badge({ children, tone, size, shape, as, onClick, disabled, title, ariaLabel, href, target, rel, wrap, className, hueIndex, tip, insetStart, inFlow, }: BadgeProps): import("react").JSX.Element;
package/dist/Badge.js ADDED
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { badgeClassName, hueVars } from "@glimstone/core";
3
+ import { IconTipButton } from "./IconTipButton.js";
4
+ export function Badge({ children, tone = "neutral", size = "medium", shape = "rounded", as = "span", onClick, disabled, title, ariaLabel, href, target, rel, wrap, className, hueIndex, tip, insetStart, inFlow, }) {
5
+ // No rainbow subscription: Badge holds no hooks so a test can call it as a
6
+ // plain function, and hueVars points at the root's colours, so a palette
7
+ // change reaches the badge without a render.
8
+ //
9
+ // Rainbow never colours text: --accent-ink is not redefined under .glim-hue,
10
+ // so a hued active badge's text keeps the single accent's ink while its
11
+ // background follows the hue.
12
+ const hueOn = hueIndex !== undefined && (tone === "heading" || tone === "active");
13
+ // `.glim-notch-hue` drives the card-wide reactive hover in tokens.css, so it
14
+ // is only set on a heading-sized badge.
15
+ const isNotchHue = hueOn && size === "heading";
16
+ const classes = [
17
+ hueOn && "glim-hue",
18
+ isNotchHue && "glim-notch-hue",
19
+ badgeClassName({ tone, size, shape, wrap, iconOnly: tip !== undefined, inFlow, insetStart, action: as !== "span" }),
20
+ className,
21
+ ]
22
+ .filter(Boolean)
23
+ .join(" ");
24
+ const hueStyle = hueOn ? hueVars(hueIndex) : undefined;
25
+ if (as === "button") {
26
+ if (tip !== undefined) {
27
+ return (_jsx(IconTipButton, { tip: tip, onClick: onClick, disabled: disabled, style: hueStyle, className: classes, children: children }));
28
+ }
29
+ return (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, title: title, "aria-label": ariaLabel, style: hueStyle, className: classes, children: children }));
30
+ }
31
+ if (as === "a") {
32
+ return (_jsx("a", { href: href, target: target, rel: rel, title: title, "aria-label": ariaLabel, style: hueStyle, className: classes, children: children }));
33
+ }
34
+ return (_jsx("span", { title: title, "aria-label": ariaLabel, style: hueStyle, className: classes, children: children }));
35
+ }
@@ -0,0 +1,54 @@
1
+ import type { ReactNode, Ref } from "react";
2
+ import { type ButtonTone, type ButtonVariant, type WidthStage } from "@glimstone/core";
3
+ export type { ButtonTone, ButtonVariant } from "@glimstone/core";
4
+ export declare function Button({ label, labelKey, glyph, onClick, tone, variant, disabled, type, className, title, hueIndex, busy, autoFocus, stage: stageOverride, keepLabel, ref, }: {
5
+ /** The button's words, present in every mode: visible, or hidden but
6
+ * announced and shown as the tooltip. Keep it stable, since a label that
7
+ * changes while the button works would resize it; put changing state in
8
+ * `title`. */
9
+ label: string;
10
+ /** The translation key behind `label`, or `null` when the label is data such
11
+ * as a path. It picks the glyph by meaning (glyphFor), so the same verb
12
+ * wears the same symbol everywhere; an explicit `glyph` wins.
13
+ *
14
+ * It is required so every call site answers "this key" or "none" instead of
15
+ * silently falling back to text in glyph mode. When the label branches, the
16
+ * key branches with it. */
17
+ labelKey: string | null;
18
+ /** Optional icon, overriding whatever `labelKey` would have chosen. Without
19
+ * either, glyph mode shows this button's text instead of an empty box. */
20
+ glyph?: ReactNode;
21
+ onClick?: () => void;
22
+ tone?: ButtonTone;
23
+ /** "chip" inside a pill, "icon" for a row action; see ButtonVariant. */
24
+ variant?: ButtonVariant;
25
+ disabled?: boolean;
26
+ type?: "button" | "submit";
27
+ className?: string;
28
+ /** Extra explanation, and the place for anything that changes: the running
29
+ * state, or why the button is unavailable. It shows in the hover and focus
30
+ * bubble, joined with the label where the label is hidden, and still
31
+ * reaches a disabled button through useTipBubble's `wrap`. */
32
+ title?: string;
33
+ /** This button's own rainbow position, as on Badge. Usually unnecessary: a
34
+ * Card with a `hueIndex` rebinds `--accent` for everything inside it, and
35
+ * passing the card's own index changes nothing. Pass it only for a
36
+ * colour different from the card's, such as a row that owns its position. */
37
+ hueIndex?: number;
38
+ /** Forwarded to the underlying <button>, so a dialog can move focus to it. */
39
+ ref?: Ref<HTMLButtonElement>;
40
+ /** Shows a spinner in place of the glyph. Separate from `disabled`, since a
41
+ * caller may want one without the other. */
42
+ busy?: boolean;
43
+ /** For a dialog that opens with focus on one of its buttons. */
44
+ autoFocus?: boolean;
45
+ /** Forces a width stage instead of deriving one from the label, for two
46
+ * buttons rendered by different components that should match: pass
47
+ * `groupStage([labelA, labelB])` to both. Use it only for such a pair.
48
+ * Ignored in glyph and reactive mode, which take no stage. */
49
+ stage?: WidthStage;
50
+ /** Keeps the label visible in every mode, for a button whose label is
51
+ * content rather than a verb, such as a directory row in a folder browser.
52
+ * The glyph still shows beside it. */
53
+ keepLabel?: boolean;
54
+ }): import("react").JSX.Element;
package/dist/Button.js ADDED
@@ -0,0 +1,52 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { buttonView, takePageHue } from "@glimstone/core";
3
+ import { useLabelMode } from "./useLabelMode.js";
4
+ import { useTipBubble } from "./useTipBubble.js";
5
+ import { glyphFor, IconClose } from "./glyphs.js";
6
+ // The one clickable control; what it shows and how wide it is come from
7
+ // buttonView() in the core.
8
+ export function Button({ label, labelKey, glyph, onClick, tone = "neutral", variant = "default", disabled = false, type = "button", className = "", title, hueIndex, busy = false, autoFocus = false, stage: stageOverride, keepLabel = false, ref, }) {
9
+ const mode = useLabelMode("buttons");
10
+ // A chip always closes, so it has a glyph even when no call site passes one.
11
+ const resolved = glyph ?? (labelKey ? glyphFor(labelKey) : undefined) ?? (variant === "chip" ? _jsx(IconClose, {}) : undefined);
12
+ const view = buttonView({
13
+ mode,
14
+ label,
15
+ hasGlyph: !!resolved || busy,
16
+ tone,
17
+ variant,
18
+ disabled,
19
+ keepLabel,
20
+ title,
21
+ hueIndex,
22
+ stage: stageOverride,
23
+ });
24
+ const tooltip = useTipBubble(view.tip, disabled);
25
+ const handlers = view.pageHue
26
+ ? {
27
+ ...tooltip.handlers,
28
+ onMouseEnter: (e) => {
29
+ takePageHue(e.currentTarget);
30
+ tooltip.handlers.onMouseEnter();
31
+ },
32
+ onFocus: (e) => {
33
+ takePageHue(e.currentTarget);
34
+ tooltip.handlers.onFocus();
35
+ },
36
+ }
37
+ : tooltip.handlers;
38
+ return (_jsxs(_Fragment, { children: [tooltip.wrap(_jsxs("button", { ref: mergeRefs(ref, tooltip.ref), type: type, onClick: onClick, disabled: disabled, autoFocus: autoFocus, "aria-busy": busy || undefined, "aria-describedby": tooltip.describedBy, ...handlers, style: view.style, className: `${view.className} ${className}`.trim(), children: [view.showGlyph && (_jsx("span", { className: "glim-btn-glyph", children: busy ? _jsx("span", { className: "glim-spinner" }) : resolved })), _jsx("span", { className: view.labelClass, children: label })] })), tooltip.bubble] }));
39
+ }
40
+ /**
41
+ * Feeds one element to both the caller's `ref`, a callback or an object, and
42
+ * the tooltip's, which places the bubble against it.
43
+ */
44
+ function mergeRefs(outer, inner) {
45
+ return (el) => {
46
+ inner(el);
47
+ if (typeof outer === "function")
48
+ outer(el);
49
+ else if (outer)
50
+ outer.current = el;
51
+ };
52
+ }
package/dist/Card.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * The surface everything else sits on, and the one place a section heading is
4
+ * drawn.
5
+ *
6
+ * The `<h2>` holds a filled badge that straddles the card's top edge, so the box
7
+ * is `relative` for the notch to resolve against this card. The `hint` bubble
8
+ * rides inside the badge because the badge is out of normal flow. With a
9
+ * `hueIndex` the card sets `--accent` once for everything inside it, so no button
10
+ * has to derive the hue itself. A nested card drops its surface and side padding
11
+ * but keeps its top padding, which the heading notch pokes into.
12
+ *
13
+ * A card with neither `title` nor `hint` draws no heading.
14
+ */
15
+ export declare function Card({ title, hint, children, hueIndex, nested, }: {
16
+ /** The section name. Omit it where a control inside already carries the same
17
+ * name; the badge still renders to keep the card's hue notch. */
18
+ title?: string;
19
+ /** One line saying what this whole card does, drawn as an "(i)" beside the
20
+ * title. */
21
+ hint?: string;
22
+ children: ReactNode;
23
+ /** This card's position in the rainbow, counted across the cards visible on
24
+ * the active tab. Omit it for a tab's only card. */
25
+ hueIndex?: number;
26
+ /** This card sits inside another card that already provides the surface and
27
+ * the padding. */
28
+ nested?: boolean;
29
+ }): import("react").JSX.Element;
package/dist/Card.js ADDED
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { hueVars } from "@glimstone/core";
3
+ import { Badge } from "./Badge.js";
4
+ import { InfoBubble } from "./InfoBubble.js";
5
+ /**
6
+ * The surface everything else sits on, and the one place a section heading is
7
+ * drawn.
8
+ *
9
+ * The `<h2>` holds a filled badge that straddles the card's top edge, so the box
10
+ * is `relative` for the notch to resolve against this card. The `hint` bubble
11
+ * rides inside the badge because the badge is out of normal flow. With a
12
+ * `hueIndex` the card sets `--accent` once for everything inside it, so no button
13
+ * has to derive the hue itself. A nested card drops its surface and side padding
14
+ * but keeps its top padding, which the heading notch pokes into.
15
+ *
16
+ * A card with neither `title` nor `hint` draws no heading.
17
+ */
18
+ export function Card({ title, hint, children, hueIndex, nested, }) {
19
+ return (_jsxs("div", { className: `glim-panel glim-notch-card${nested ? " glim-panel--nested" : ""}${hueIndex !== undefined ? " glim-hue" : ""}`, style: hueIndex !== undefined ? hueVars(hueIndex) : undefined, children: [(title || hint) && (_jsx("h2", { className: "glim-panel-heading", children: _jsxs(Badge, { tone: "heading", size: "heading", wrap: true, hueIndex: hueIndex, children: [title, hint && _jsx(InfoBubble, { tip: hint, onAccent: true })] }) })), children] }));
20
+ }
@@ -0,0 +1,17 @@
1
+ import type { Ref } from "react";
2
+ export interface CoffeeDialogProps {
3
+ /** `https://buymeacoffee.com/widget/page/<handle>` with its query. */
4
+ widgetUrl: string;
5
+ text: {
6
+ title: string;
7
+ /** The app's appeal, the same in every giving window. */
8
+ appeal: string;
9
+ /** One sentence: the payment happens at BMAC, and no account is needed. */
10
+ intro: string;
11
+ closeLabel: string;
12
+ };
13
+ onClose: () => void;
14
+ /** The window's own card, for the app's Escape handling and focus trap. */
15
+ ref?: Ref<HTMLDivElement>;
16
+ }
17
+ export declare function CoffeeDialog({ widgetUrl, text, onClose, ref }: CoffeeDialogProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Badge } from "./Badge.js";
3
+ import { Button } from "./Button.js";
4
+ export function CoffeeDialog({ widgetUrl, text, onClose, ref }) {
5
+ return (_jsx("div", { className: "glim-modal-backdrop", onClick: (e) => {
6
+ if (e.target === e.currentTarget)
7
+ onClose();
8
+ }, children: _jsxs("div", { ref: ref, tabIndex: -1, role: "dialog", "aria-modal": "true", "aria-labelledby": "coffee-title", className: "glim-modal-card glim-modal-card--wide glim-modal-card--tall", children: [_jsx("div", { className: "glim-modal-head", children: _jsx("h2", { id: "coffee-title", className: "glim-modal-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, children: text.title }) }) }), _jsxs("div", { className: "glim-give-body", children: [_jsx("p", { className: "glim-give-appeal", children: text.appeal }), _jsx("p", { className: "glim-give-intro", children: text.intro }), _jsx("div", { className: "glim-give-frame", children: _jsx("iframe", { src: widgetUrl, title: text.title, allow: "payment", className: "glim-give-iframe" }) })] }), _jsx("div", { className: "glim-give-foot", children: _jsx(Button, { label: text.closeLabel, labelKey: "common.close", tone: "neutral", onClick: onClose }) })] }) }));
9
+ }
@@ -0,0 +1,16 @@
1
+ import type { SelectOption } from "./Select.tsx";
2
+ export interface ComboboxProps {
3
+ label: string;
4
+ hideLabel?: boolean;
5
+ options: SelectOption[];
6
+ /** The chosen value, or "" while nothing is chosen. */
7
+ value: string;
8
+ onChange: (value: string) => void;
9
+ placeholder?: string;
10
+ /** The line the list shows when nothing matches. */
11
+ empty: string;
12
+ /** Accessible name of the button that opens the full list. */
13
+ toggleLabel: string;
14
+ disabled?: boolean;
15
+ }
16
+ export declare function Combobox({ label, hideLabel, options, value, onChange, placeholder, empty, toggleLabel, disabled }: ComboboxProps): import("react").JSX.Element;