@edhspace/ui 0.0.0-stage → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ ISC License
2
+
3
+ Copyright (c) EDHspace contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose
6
+ with or without fee is hereby granted, provided that the above copyright notice
7
+ and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
12
+ OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
13
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
14
+ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,53 @@
1
- # Temporary Holding Version
1
+ # @edhspace/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
+ Lightweight React 19 components for panels, card lists, mana symbols, and forms.
4
+ Use them with the EDHspace SDK or in a standalone React application.
5
+
6
+ ```tsx
7
+ import { CardList, PanelLayout, Notice } from "@edhspace/ui";
8
+ import "@edhspace/ui/styles.css";
9
+
10
+ <PanelLayout title={deck.name}>
11
+ {error && <Notice error>{error.message}</Notice>}
12
+ <CardList cards={deck.cards} onInspect={inspectCard} />
13
+ </PanelLayout>;
14
+ ```
15
+
16
+ Exports include PanelLayout/Panel, CardList, CardPreview, ManaCost, SymbolText,
17
+ StatBadge, FilterBar, EmptyState, ActionPanel, DataTable, Button, Field, Notice
18
+ and ActionBar, plus the host-controlled ApiRequestDialog. The host injects shared hover anchors/native galleries through
19
+ CardPreviewProvider; standalone consumers get an explicit inspection button.
20
+ Presentation never grants access or performs privileged actions itself.
21
+
22
+ ApiRequestDialog displays the requesting extension, destination, method and
23
+ outgoing data. Its host supplies `onAccept(remember)` and `onCancel`; GET offers
24
+ session consent, while POST has no remember option. Native dialog behavior keeps
25
+ focus inside, focuses Cancel initially, and supports Escape. The component does
26
+ not make requests or grant permissions.
27
+
28
+ Styles are opt-in and namespaced. Native usage inherits live `--set-*` tokens;
29
+ standalone ThemeProvider accepts background, foreground, muted, accent, border
30
+ and font. No theme reopen or animation is required. Mana images use
31
+ `https://svgs.scryfall.io`; hosting CSP must permit that image origin.
32
+ `SymbolRenderingProvider mode="text"` renders readable mana/rules tokens without
33
+ external images. The sideload bootstrap enables this mode automatically; native
34
+ and standalone rendering keep their existing image behavior.
35
+
36
+ Controls have 44px targets, visible focus, wrapper-based gaps and wrapping.
37
+ Fields associate labels with inputs; Notice announces status/errors.
38
+ ActionPanel supports arrow/Home/End navigation across enabled buttons while
39
+ preserving Tab. DataTable retains semantic headers and local horizontal scrolling.
40
+
41
+ ## Source layout
42
+
43
+ Keep one React component per file in `src/components/`, including providers and
44
+ internal symbol rendering. Shared React contexts belong in `src/contexts/`;
45
+ shared data types belong in `src/types/`. Components import siblings directly,
46
+ not through the barrel. `src/components/index.ts` defines the public exports and
47
+ `src/index.ts` reexports them for `@edhspace/ui` consumer imports.
48
+ The existing `Panel` and `PanelLayout` names refer to the same component.
49
+
50
+ Run `npm run build`, `npm run typecheck`, and `npm test` in this directory.
51
+ Build emits ESM/CommonJS, declarations and `dist/styles.css`; React remains a peer.
52
+ Native hosts must deduplicate React/React DOM across linked packages.
53
+ `npm pack --dry-run` inspects distributable files without publication.
package/dist/index.cjs ADDED
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ ActionBar: () => ActionBar,
24
+ ActionPanel: () => ActionPanel,
25
+ ApiRequestDialog: () => ApiRequestDialog,
26
+ Button: () => Button,
27
+ CardList: () => CardList,
28
+ CardPreview: () => CardPreview,
29
+ CardPreviewProvider: () => CardPreviewProvider,
30
+ DataTable: () => DataTable,
31
+ EmptyState: () => EmptyState,
32
+ Field: () => Field,
33
+ FilterBar: () => FilterBar,
34
+ ManaCost: () => ManaCost,
35
+ Notice: () => Notice,
36
+ Panel: () => Panel,
37
+ PanelLayout: () => Panel,
38
+ StatBadge: () => StatBadge,
39
+ SymbolRenderingProvider: () => SymbolRenderingProvider,
40
+ SymbolText: () => SymbolText,
41
+ ThemeProvider: () => ThemeProvider
42
+ });
43
+ module.exports = __toCommonJS(index_exports);
44
+
45
+ // src/components/theme-provider.tsx
46
+ var import_jsx_runtime = require("react/jsx-runtime");
47
+ function ThemeProvider({ theme, children }) {
48
+ const style = {
49
+ "--edhspace-background": theme.background,
50
+ "--edhspace-foreground": theme.foreground,
51
+ "--edhspace-muted": theme.muted,
52
+ "--edhspace-accent": theme.accent,
53
+ "--edhspace-border": theme.border,
54
+ "--edhspace-font": theme.font
55
+ };
56
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "edhspace-ui", style, children });
57
+ }
58
+
59
+ // src/components/panel.tsx
60
+ var import_jsx_runtime2 = require("react/jsx-runtime");
61
+ function Panel({
62
+ title,
63
+ children,
64
+ actions
65
+ }) {
66
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "edhspace-panel", children: [
67
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { children: [
68
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: title }),
69
+ actions
70
+ ] }),
71
+ children
72
+ ] });
73
+ }
74
+
75
+ // src/components/action-bar.tsx
76
+ var import_jsx_runtime3 = require("react/jsx-runtime");
77
+ function ActionBar({ children, label }) {
78
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "edhspace-actions", role: "group", "aria-label": label, children });
79
+ }
80
+
81
+ // src/components/button.tsx
82
+ var import_jsx_runtime4 = require("react/jsx-runtime");
83
+ function Button({ type = "button", className = "", ...props }) {
84
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { ...props, type, className: `edhspace-button ${className}`.trim() });
85
+ }
86
+
87
+ // src/components/field.tsx
88
+ var import_react = require("react");
89
+ var import_jsx_runtime5 = require("react/jsx-runtime");
90
+ function Field({ label, ...props }) {
91
+ const id = (0, import_react.useId)();
92
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "edhspace-field", htmlFor: props.id ?? id, children: [
93
+ label,
94
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { ...props, id: props.id ?? id })
95
+ ] });
96
+ }
97
+
98
+ // src/components/notice.tsx
99
+ var import_jsx_runtime6 = require("react/jsx-runtime");
100
+ function Notice({ children, error = false }) {
101
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "edhspace-notice", role: error ? "alert" : "status", children });
102
+ }
103
+
104
+ // src/components/card-preview.tsx
105
+ var import_react3 = require("react");
106
+
107
+ // src/contexts/card-preview.ts
108
+ var import_react2 = require("react");
109
+ var CardPreviewContext = (0, import_react2.createContext)(void 0);
110
+
111
+ // src/components/card-preview.tsx
112
+ var import_jsx_runtime7 = require("react/jsx-runtime");
113
+ function CardPreview({ card, onInspect }) {
114
+ const Renderer = (0, import_react3.useContext)(CardPreviewContext);
115
+ return Renderer ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Renderer, { card, onInspect }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { onClick: onInspect, children: card.name });
116
+ }
117
+
118
+ // src/components/symbol.tsx
119
+ var import_react5 = require("react");
120
+
121
+ // src/contexts/symbol-rendering.ts
122
+ var import_react4 = require("react");
123
+ var SymbolRenderingContext = (0, import_react4.createContext)("images");
124
+
125
+ // src/components/symbol.tsx
126
+ var import_jsx_runtime8 = require("react/jsx-runtime");
127
+ function Symbol2({ token, labeled = false }) {
128
+ const mode = (0, import_react5.useContext)(SymbolRenderingContext);
129
+ const [failed, setFailed] = (0, import_react5.useState)(false);
130
+ const name = token.slice(1, -1).replaceAll("/", "");
131
+ return failed || mode === "text" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: token }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
132
+ "img",
133
+ {
134
+ src: `https://svgs.scryfall.io/card-symbols/${encodeURIComponent(name)}.svg`,
135
+ alt: labeled ? token : "",
136
+ width: "16",
137
+ height: "16",
138
+ loading: "lazy",
139
+ onError: () => setFailed(true)
140
+ }
141
+ );
142
+ }
143
+
144
+ // src/components/mana-cost.tsx
145
+ var import_jsx_runtime9 = require("react/jsx-runtime");
146
+ function ManaCost({ cost, title = cost }) {
147
+ if (!cost) return null;
148
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "mana-cost", role: "img", "aria-label": `Mana cost ${cost}`, title, children: cost.split(/(\{[^}]+\})/g).filter(Boolean).map(
149
+ (part, index) => part.startsWith("{") && part.endsWith("}") ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Symbol2, { token: part }, `${index}:${part}`) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: part }, index)
150
+ ) });
151
+ }
152
+
153
+ // src/components/card-list.tsx
154
+ var import_jsx_runtime10 = require("react/jsx-runtime");
155
+ function CardList({
156
+ cards,
157
+ onInspect,
158
+ label = "Cards"
159
+ }) {
160
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "edhspace-card-list", "aria-label": label, children: cards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("li", { children: [
161
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-label": `${card.quantity} copies`, children: card.quantity }),
162
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CardPreview, { card, onInspect: () => onInspect(card) }),
163
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ManaCost, { cost: card.manaCost })
164
+ ] }, card.id)) });
165
+ }
166
+
167
+ // src/components/card-preview-provider.tsx
168
+ var import_jsx_runtime11 = require("react/jsx-runtime");
169
+ function CardPreviewProvider({
170
+ renderer,
171
+ children
172
+ }) {
173
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CardPreviewContext.Provider, { value: renderer, children });
174
+ }
175
+
176
+ // src/components/stat-badge.tsx
177
+ var import_jsx_runtime12 = require("react/jsx-runtime");
178
+ function StatBadge({ label, value }) {
179
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "edhspace-stat", children: [
180
+ label,
181
+ ": ",
182
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: value })
183
+ ] });
184
+ }
185
+
186
+ // src/components/filter-bar.tsx
187
+ var import_jsx_runtime13 = require("react/jsx-runtime");
188
+ function FilterBar({ label, children }) {
189
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "edhspace-filter-bar", role: "group", "aria-label": label, children });
190
+ }
191
+
192
+ // src/components/empty-state.tsx
193
+ var import_jsx_runtime14 = require("react/jsx-runtime");
194
+ function EmptyState({
195
+ title,
196
+ children,
197
+ action
198
+ }) {
199
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: "edhspace-empty", role: "status", children: [
200
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { children: title }),
201
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children }),
202
+ action
203
+ ] });
204
+ }
205
+
206
+ // src/components/action-panel.tsx
207
+ var import_jsx_runtime15 = require("react/jsx-runtime");
208
+ function ActionPanel({ label, children }) {
209
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
210
+ "div",
211
+ {
212
+ className: "edhspace-actions",
213
+ role: "toolbar",
214
+ "aria-label": label,
215
+ onKeyDown: (event) => {
216
+ if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
217
+ const controls = Array.from(
218
+ event.currentTarget.querySelectorAll("button:not(:disabled)")
219
+ );
220
+ const index = controls.findIndex((control) => control === event.target);
221
+ if (index < 0 || !controls.length) return;
222
+ event.preventDefault();
223
+ const next = event.key === "Home" ? 0 : event.key === "End" ? controls.length - 1 : (index + (event.key === "ArrowRight" ? 1 : -1) + controls.length) % controls.length;
224
+ controls[next].focus();
225
+ },
226
+ children
227
+ }
228
+ );
229
+ }
230
+
231
+ // src/components/data-table.tsx
232
+ var import_jsx_runtime16 = require("react/jsx-runtime");
233
+ function DataTable({
234
+ rows,
235
+ columns,
236
+ rowId,
237
+ label
238
+ }) {
239
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "edhspace-table-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("table", { "aria-label": label, children: [
240
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("th", { scope: "col", children: column.title }, column.id)) }) }),
241
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tbody", { children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("td", { children: column.render(row) }, column.id)) }, rowId(row))) })
242
+ ] }) });
243
+ }
244
+
245
+ // src/components/symbol-text.tsx
246
+ var import_jsx_runtime17 = require("react/jsx-runtime");
247
+ function SymbolText({ text }) {
248
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: text?.split(/(\{[^}]+\})/g).map(
249
+ (part, index) => /^\{[^}]+\}$/.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "oracle-symbol", title: part, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Symbol2, { token: part, labeled: true }) }, `${index}:${part}`) : part
250
+ ) });
251
+ }
252
+
253
+ // src/components/symbol-rendering-provider.tsx
254
+ var import_jsx_runtime18 = require("react/jsx-runtime");
255
+ function SymbolRenderingProvider({
256
+ mode,
257
+ children
258
+ }) {
259
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolRenderingContext.Provider, { value: mode, children });
260
+ }
261
+
262
+ // src/components/api-request-dialog.tsx
263
+ var import_react6 = require("react");
264
+ var import_jsx_runtime19 = require("react/jsx-runtime");
265
+ function ApiRequestDialog({
266
+ extension,
267
+ url,
268
+ method,
269
+ data,
270
+ onAccept,
271
+ onCancel
272
+ }) {
273
+ const dialog = (0, import_react6.useRef)(null);
274
+ const cancel = (0, import_react6.useRef)(null);
275
+ const title = (0, import_react6.useId)();
276
+ const description = (0, import_react6.useId)();
277
+ const [remember, setRemember] = (0, import_react6.useState)(false);
278
+ (0, import_react6.useEffect)(() => {
279
+ const element = dialog.current;
280
+ const previous = element?.ownerDocument.activeElement;
281
+ element?.showModal();
282
+ cancel.current?.focus();
283
+ return () => {
284
+ element?.close();
285
+ if (previous instanceof HTMLElement && previous.isConnected) previous.focus();
286
+ };
287
+ }, []);
288
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
289
+ "dialog",
290
+ {
291
+ ref: dialog,
292
+ className: "edhspace-api-dialog",
293
+ "aria-labelledby": title,
294
+ "aria-describedby": description,
295
+ onCancel: (event) => {
296
+ event.preventDefault();
297
+ onCancel();
298
+ },
299
+ onKeyDown: (event) => {
300
+ if (event.key !== "Tab") return;
301
+ const controls = Array.from(
302
+ event.currentTarget.querySelectorAll(
303
+ 'button:not([disabled]), input:not([disabled]), [tabindex="0"]'
304
+ )
305
+ );
306
+ const first = controls[0];
307
+ const last = controls[controls.length - 1];
308
+ const active = event.currentTarget.ownerDocument.activeElement;
309
+ if (event.shiftKey && active === first) {
310
+ event.preventDefault();
311
+ last?.focus();
312
+ } else if (!event.shiftKey && active === last) {
313
+ event.preventDefault();
314
+ first?.focus();
315
+ }
316
+ },
317
+ children: [
318
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { id: title, children: "Allow API request?" }),
319
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("p", { id: description, children: [
320
+ extension,
321
+ " will send the shown data to this service."
322
+ ] }),
323
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("dl", { children: [
324
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dt", { children: "Request" }),
325
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dd", { children: method }),
326
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dt", { children: "Destination" }),
327
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("dd", { children: url })
328
+ ] }),
329
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("pre", { "aria-label": "Request data", tabIndex: 0, children: data }),
330
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { children: "EDHspace cookies and account credentials are not sent." }),
331
+ method === "GET" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "edhspace-api-remember", children: [
332
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
333
+ "input",
334
+ {
335
+ type: "checkbox",
336
+ checked: remember,
337
+ onChange: (event) => setRemember(event.target.checked)
338
+ }
339
+ ),
340
+ "Allow GET requests to this API for this session"
341
+ ] }),
342
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ActionBar, { label: "API request approval", children: [
343
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { ref: cancel, onClick: onCancel, children: "Cancel" }),
344
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { onClick: () => onAccept(remember), children: "Allow request" })
345
+ ] })
346
+ ]
347
+ }
348
+ );
349
+ }
350
+ // Annotate the CommonJS export names for ESM import in node:
351
+ 0 && (module.exports = {
352
+ ActionBar,
353
+ ActionPanel,
354
+ ApiRequestDialog,
355
+ Button,
356
+ CardList,
357
+ CardPreview,
358
+ CardPreviewProvider,
359
+ DataTable,
360
+ EmptyState,
361
+ Field,
362
+ FilterBar,
363
+ ManaCost,
364
+ Notice,
365
+ Panel,
366
+ PanelLayout,
367
+ StatBadge,
368
+ SymbolRenderingProvider,
369
+ SymbolText,
370
+ ThemeProvider
371
+ });
@@ -0,0 +1,119 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentProps, ComponentType } from 'react';
3
+
4
+ type Theme = {
5
+ background: string;
6
+ foreground: string;
7
+ muted: string;
8
+ accent: string;
9
+ border: string;
10
+ font: string;
11
+ };
12
+ declare function ThemeProvider({ theme, children }: {
13
+ theme: Theme;
14
+ children: ReactNode;
15
+ }): react.JSX.Element;
16
+
17
+ declare function Panel({ title, children, actions, }: {
18
+ title: string;
19
+ children: ReactNode;
20
+ actions?: ReactNode;
21
+ }): react.JSX.Element;
22
+
23
+ declare function ActionBar({ children, label }: {
24
+ children: ReactNode;
25
+ label: string;
26
+ }): react.JSX.Element;
27
+
28
+ declare function Button({ type, className, ...props }: ComponentProps<"button">): react.JSX.Element;
29
+
30
+ declare function Field({ label, ...props }: ComponentProps<"input"> & {
31
+ label: string;
32
+ }): react.JSX.Element;
33
+
34
+ declare function Notice({ children, error }: {
35
+ children: ReactNode;
36
+ error?: boolean;
37
+ }): react.JSX.Element;
38
+
39
+ type CardListItem = {
40
+ id: string;
41
+ name: string;
42
+ quantity: number;
43
+ manaCost?: string;
44
+ };
45
+
46
+ declare function CardList<T extends CardListItem>({ cards, onInspect, label, }: {
47
+ cards: readonly T[];
48
+ onInspect(card: T): void;
49
+ label?: string;
50
+ }): react.JSX.Element;
51
+
52
+ type PreviewProps = {
53
+ card: CardListItem;
54
+ onInspect(): void;
55
+ };
56
+
57
+ declare function CardPreviewProvider({ renderer, children, }: {
58
+ renderer: ComponentType<PreviewProps>;
59
+ children: ReactNode;
60
+ }): react.JSX.Element;
61
+
62
+ declare function CardPreview({ card, onInspect }: PreviewProps): react.JSX.Element;
63
+
64
+ declare function StatBadge({ label, value }: {
65
+ label: string;
66
+ value: ReactNode;
67
+ }): react.JSX.Element;
68
+
69
+ declare function FilterBar({ label, children }: {
70
+ label: string;
71
+ children: ReactNode;
72
+ }): react.JSX.Element;
73
+
74
+ declare function EmptyState({ title, children, action, }: {
75
+ title: string;
76
+ children: ReactNode;
77
+ action?: ReactNode;
78
+ }): react.JSX.Element;
79
+
80
+ declare function ActionPanel({ label, children }: {
81
+ label: string;
82
+ children: ReactNode;
83
+ }): react.JSX.Element;
84
+
85
+ declare function DataTable<T>({ rows, columns, rowId, label, }: {
86
+ rows: readonly T[];
87
+ columns: readonly {
88
+ id: string;
89
+ title: string;
90
+ render(row: T): ReactNode;
91
+ }[];
92
+ rowId(row: T): string;
93
+ label: string;
94
+ }): react.JSX.Element;
95
+
96
+ declare function ManaCost({ cost, title }: {
97
+ cost?: string;
98
+ title?: string;
99
+ }): react.JSX.Element | null;
100
+
101
+ declare function SymbolText({ text }: {
102
+ text: string | null | undefined;
103
+ }): react.JSX.Element;
104
+
105
+ declare function SymbolRenderingProvider({ mode, children, }: {
106
+ mode: "images" | "text";
107
+ children: ReactNode;
108
+ }): react.JSX.Element;
109
+
110
+ declare function ApiRequestDialog({ extension, url, method, data, onAccept, onCancel, }: {
111
+ extension: string;
112
+ url: string;
113
+ method: "GET" | "POST";
114
+ data: string;
115
+ onAccept(remember: boolean): void;
116
+ onCancel(): void;
117
+ }): react.JSX.Element;
118
+
119
+ export { ActionBar, ActionPanel, ApiRequestDialog, Button, CardList, type CardListItem, CardPreview, CardPreviewProvider, DataTable, EmptyState, Field, FilterBar, ManaCost, Notice, Panel, Panel as PanelLayout, StatBadge, SymbolRenderingProvider, SymbolText, type Theme, ThemeProvider };
@@ -0,0 +1,119 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentProps, ComponentType } from 'react';
3
+
4
+ type Theme = {
5
+ background: string;
6
+ foreground: string;
7
+ muted: string;
8
+ accent: string;
9
+ border: string;
10
+ font: string;
11
+ };
12
+ declare function ThemeProvider({ theme, children }: {
13
+ theme: Theme;
14
+ children: ReactNode;
15
+ }): react.JSX.Element;
16
+
17
+ declare function Panel({ title, children, actions, }: {
18
+ title: string;
19
+ children: ReactNode;
20
+ actions?: ReactNode;
21
+ }): react.JSX.Element;
22
+
23
+ declare function ActionBar({ children, label }: {
24
+ children: ReactNode;
25
+ label: string;
26
+ }): react.JSX.Element;
27
+
28
+ declare function Button({ type, className, ...props }: ComponentProps<"button">): react.JSX.Element;
29
+
30
+ declare function Field({ label, ...props }: ComponentProps<"input"> & {
31
+ label: string;
32
+ }): react.JSX.Element;
33
+
34
+ declare function Notice({ children, error }: {
35
+ children: ReactNode;
36
+ error?: boolean;
37
+ }): react.JSX.Element;
38
+
39
+ type CardListItem = {
40
+ id: string;
41
+ name: string;
42
+ quantity: number;
43
+ manaCost?: string;
44
+ };
45
+
46
+ declare function CardList<T extends CardListItem>({ cards, onInspect, label, }: {
47
+ cards: readonly T[];
48
+ onInspect(card: T): void;
49
+ label?: string;
50
+ }): react.JSX.Element;
51
+
52
+ type PreviewProps = {
53
+ card: CardListItem;
54
+ onInspect(): void;
55
+ };
56
+
57
+ declare function CardPreviewProvider({ renderer, children, }: {
58
+ renderer: ComponentType<PreviewProps>;
59
+ children: ReactNode;
60
+ }): react.JSX.Element;
61
+
62
+ declare function CardPreview({ card, onInspect }: PreviewProps): react.JSX.Element;
63
+
64
+ declare function StatBadge({ label, value }: {
65
+ label: string;
66
+ value: ReactNode;
67
+ }): react.JSX.Element;
68
+
69
+ declare function FilterBar({ label, children }: {
70
+ label: string;
71
+ children: ReactNode;
72
+ }): react.JSX.Element;
73
+
74
+ declare function EmptyState({ title, children, action, }: {
75
+ title: string;
76
+ children: ReactNode;
77
+ action?: ReactNode;
78
+ }): react.JSX.Element;
79
+
80
+ declare function ActionPanel({ label, children }: {
81
+ label: string;
82
+ children: ReactNode;
83
+ }): react.JSX.Element;
84
+
85
+ declare function DataTable<T>({ rows, columns, rowId, label, }: {
86
+ rows: readonly T[];
87
+ columns: readonly {
88
+ id: string;
89
+ title: string;
90
+ render(row: T): ReactNode;
91
+ }[];
92
+ rowId(row: T): string;
93
+ label: string;
94
+ }): react.JSX.Element;
95
+
96
+ declare function ManaCost({ cost, title }: {
97
+ cost?: string;
98
+ title?: string;
99
+ }): react.JSX.Element | null;
100
+
101
+ declare function SymbolText({ text }: {
102
+ text: string | null | undefined;
103
+ }): react.JSX.Element;
104
+
105
+ declare function SymbolRenderingProvider({ mode, children, }: {
106
+ mode: "images" | "text";
107
+ children: ReactNode;
108
+ }): react.JSX.Element;
109
+
110
+ declare function ApiRequestDialog({ extension, url, method, data, onAccept, onCancel, }: {
111
+ extension: string;
112
+ url: string;
113
+ method: "GET" | "POST";
114
+ data: string;
115
+ onAccept(remember: boolean): void;
116
+ onCancel(): void;
117
+ }): react.JSX.Element;
118
+
119
+ export { ActionBar, ActionPanel, ApiRequestDialog, Button, CardList, type CardListItem, CardPreview, CardPreviewProvider, DataTable, EmptyState, Field, FilterBar, ManaCost, Notice, Panel, Panel as PanelLayout, StatBadge, SymbolRenderingProvider, SymbolText, type Theme, ThemeProvider };
package/dist/index.js ADDED
@@ -0,0 +1,326 @@
1
+ // src/components/theme-provider.tsx
2
+ import { jsx } from "react/jsx-runtime";
3
+ function ThemeProvider({ theme, children }) {
4
+ const style = {
5
+ "--edhspace-background": theme.background,
6
+ "--edhspace-foreground": theme.foreground,
7
+ "--edhspace-muted": theme.muted,
8
+ "--edhspace-accent": theme.accent,
9
+ "--edhspace-border": theme.border,
10
+ "--edhspace-font": theme.font
11
+ };
12
+ return /* @__PURE__ */ jsx("div", { className: "edhspace-ui", style, children });
13
+ }
14
+
15
+ // src/components/panel.tsx
16
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
17
+ function Panel({
18
+ title,
19
+ children,
20
+ actions
21
+ }) {
22
+ return /* @__PURE__ */ jsxs("section", { className: "edhspace-panel", children: [
23
+ /* @__PURE__ */ jsxs("header", { children: [
24
+ /* @__PURE__ */ jsx2("h2", { children: title }),
25
+ actions
26
+ ] }),
27
+ children
28
+ ] });
29
+ }
30
+
31
+ // src/components/action-bar.tsx
32
+ import { jsx as jsx3 } from "react/jsx-runtime";
33
+ function ActionBar({ children, label }) {
34
+ return /* @__PURE__ */ jsx3("div", { className: "edhspace-actions", role: "group", "aria-label": label, children });
35
+ }
36
+
37
+ // src/components/button.tsx
38
+ import { jsx as jsx4 } from "react/jsx-runtime";
39
+ function Button({ type = "button", className = "", ...props }) {
40
+ return /* @__PURE__ */ jsx4("button", { ...props, type, className: `edhspace-button ${className}`.trim() });
41
+ }
42
+
43
+ // src/components/field.tsx
44
+ import { useId } from "react";
45
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
46
+ function Field({ label, ...props }) {
47
+ const id = useId();
48
+ return /* @__PURE__ */ jsxs2("label", { className: "edhspace-field", htmlFor: props.id ?? id, children: [
49
+ label,
50
+ /* @__PURE__ */ jsx5("input", { ...props, id: props.id ?? id })
51
+ ] });
52
+ }
53
+
54
+ // src/components/notice.tsx
55
+ import { jsx as jsx6 } from "react/jsx-runtime";
56
+ function Notice({ children, error = false }) {
57
+ return /* @__PURE__ */ jsx6("p", { className: "edhspace-notice", role: error ? "alert" : "status", children });
58
+ }
59
+
60
+ // src/components/card-preview.tsx
61
+ import { useContext } from "react";
62
+
63
+ // src/contexts/card-preview.ts
64
+ import { createContext } from "react";
65
+ var CardPreviewContext = createContext(void 0);
66
+
67
+ // src/components/card-preview.tsx
68
+ import { jsx as jsx7 } from "react/jsx-runtime";
69
+ function CardPreview({ card, onInspect }) {
70
+ const Renderer = useContext(CardPreviewContext);
71
+ return Renderer ? /* @__PURE__ */ jsx7(Renderer, { card, onInspect }) : /* @__PURE__ */ jsx7(Button, { onClick: onInspect, children: card.name });
72
+ }
73
+
74
+ // src/components/symbol.tsx
75
+ import { useContext as useContext2, useState } from "react";
76
+
77
+ // src/contexts/symbol-rendering.ts
78
+ import { createContext as createContext2 } from "react";
79
+ var SymbolRenderingContext = createContext2("images");
80
+
81
+ // src/components/symbol.tsx
82
+ import { jsx as jsx8 } from "react/jsx-runtime";
83
+ function Symbol({ token, labeled = false }) {
84
+ const mode = useContext2(SymbolRenderingContext);
85
+ const [failed, setFailed] = useState(false);
86
+ const name = token.slice(1, -1).replaceAll("/", "");
87
+ return failed || mode === "text" ? /* @__PURE__ */ jsx8("span", { children: token }) : /* @__PURE__ */ jsx8(
88
+ "img",
89
+ {
90
+ src: `https://svgs.scryfall.io/card-symbols/${encodeURIComponent(name)}.svg`,
91
+ alt: labeled ? token : "",
92
+ width: "16",
93
+ height: "16",
94
+ loading: "lazy",
95
+ onError: () => setFailed(true)
96
+ }
97
+ );
98
+ }
99
+
100
+ // src/components/mana-cost.tsx
101
+ import { jsx as jsx9 } from "react/jsx-runtime";
102
+ function ManaCost({ cost, title = cost }) {
103
+ if (!cost) return null;
104
+ return /* @__PURE__ */ jsx9("span", { className: "mana-cost", role: "img", "aria-label": `Mana cost ${cost}`, title, children: cost.split(/(\{[^}]+\})/g).filter(Boolean).map(
105
+ (part, index) => part.startsWith("{") && part.endsWith("}") ? /* @__PURE__ */ jsx9(Symbol, { token: part }, `${index}:${part}`) : /* @__PURE__ */ jsx9("span", { children: part }, index)
106
+ ) });
107
+ }
108
+
109
+ // src/components/card-list.tsx
110
+ import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
111
+ function CardList({
112
+ cards,
113
+ onInspect,
114
+ label = "Cards"
115
+ }) {
116
+ return /* @__PURE__ */ jsx10("ul", { className: "edhspace-card-list", "aria-label": label, children: cards.map((card) => /* @__PURE__ */ jsxs3("li", { children: [
117
+ /* @__PURE__ */ jsx10("span", { "aria-label": `${card.quantity} copies`, children: card.quantity }),
118
+ /* @__PURE__ */ jsx10(CardPreview, { card, onInspect: () => onInspect(card) }),
119
+ /* @__PURE__ */ jsx10(ManaCost, { cost: card.manaCost })
120
+ ] }, card.id)) });
121
+ }
122
+
123
+ // src/components/card-preview-provider.tsx
124
+ import { jsx as jsx11 } from "react/jsx-runtime";
125
+ function CardPreviewProvider({
126
+ renderer,
127
+ children
128
+ }) {
129
+ return /* @__PURE__ */ jsx11(CardPreviewContext.Provider, { value: renderer, children });
130
+ }
131
+
132
+ // src/components/stat-badge.tsx
133
+ import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
134
+ function StatBadge({ label, value }) {
135
+ return /* @__PURE__ */ jsxs4("span", { className: "edhspace-stat", children: [
136
+ label,
137
+ ": ",
138
+ /* @__PURE__ */ jsx12("strong", { children: value })
139
+ ] });
140
+ }
141
+
142
+ // src/components/filter-bar.tsx
143
+ import { jsx as jsx13 } from "react/jsx-runtime";
144
+ function FilterBar({ label, children }) {
145
+ return /* @__PURE__ */ jsx13("div", { className: "edhspace-filter-bar", role: "group", "aria-label": label, children });
146
+ }
147
+
148
+ // src/components/empty-state.tsx
149
+ import { jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
150
+ function EmptyState({
151
+ title,
152
+ children,
153
+ action
154
+ }) {
155
+ return /* @__PURE__ */ jsxs5("section", { className: "edhspace-empty", role: "status", children: [
156
+ /* @__PURE__ */ jsx14("h3", { children: title }),
157
+ /* @__PURE__ */ jsx14("p", { children }),
158
+ action
159
+ ] });
160
+ }
161
+
162
+ // src/components/action-panel.tsx
163
+ import { jsx as jsx15 } from "react/jsx-runtime";
164
+ function ActionPanel({ label, children }) {
165
+ return /* @__PURE__ */ jsx15(
166
+ "div",
167
+ {
168
+ className: "edhspace-actions",
169
+ role: "toolbar",
170
+ "aria-label": label,
171
+ onKeyDown: (event) => {
172
+ if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
173
+ const controls = Array.from(
174
+ event.currentTarget.querySelectorAll("button:not(:disabled)")
175
+ );
176
+ const index = controls.findIndex((control) => control === event.target);
177
+ if (index < 0 || !controls.length) return;
178
+ event.preventDefault();
179
+ const next = event.key === "Home" ? 0 : event.key === "End" ? controls.length - 1 : (index + (event.key === "ArrowRight" ? 1 : -1) + controls.length) % controls.length;
180
+ controls[next].focus();
181
+ },
182
+ children
183
+ }
184
+ );
185
+ }
186
+
187
+ // src/components/data-table.tsx
188
+ import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
189
+ function DataTable({
190
+ rows,
191
+ columns,
192
+ rowId,
193
+ label
194
+ }) {
195
+ return /* @__PURE__ */ jsx16("div", { className: "edhspace-table-scroll", children: /* @__PURE__ */ jsxs6("table", { "aria-label": label, children: [
196
+ /* @__PURE__ */ jsx16("thead", { children: /* @__PURE__ */ jsx16("tr", { children: columns.map((column) => /* @__PURE__ */ jsx16("th", { scope: "col", children: column.title }, column.id)) }) }),
197
+ /* @__PURE__ */ jsx16("tbody", { children: rows.map((row) => /* @__PURE__ */ jsx16("tr", { children: columns.map((column) => /* @__PURE__ */ jsx16("td", { children: column.render(row) }, column.id)) }, rowId(row))) })
198
+ ] }) });
199
+ }
200
+
201
+ // src/components/symbol-text.tsx
202
+ import { Fragment, jsx as jsx17 } from "react/jsx-runtime";
203
+ function SymbolText({ text }) {
204
+ return /* @__PURE__ */ jsx17(Fragment, { children: text?.split(/(\{[^}]+\})/g).map(
205
+ (part, index) => /^\{[^}]+\}$/.test(part) ? /* @__PURE__ */ jsx17("span", { className: "oracle-symbol", title: part, children: /* @__PURE__ */ jsx17(Symbol, { token: part, labeled: true }) }, `${index}:${part}`) : part
206
+ ) });
207
+ }
208
+
209
+ // src/components/symbol-rendering-provider.tsx
210
+ import { jsx as jsx18 } from "react/jsx-runtime";
211
+ function SymbolRenderingProvider({
212
+ mode,
213
+ children
214
+ }) {
215
+ return /* @__PURE__ */ jsx18(SymbolRenderingContext.Provider, { value: mode, children });
216
+ }
217
+
218
+ // src/components/api-request-dialog.tsx
219
+ import { useEffect, useId as useId2, useRef, useState as useState2 } from "react";
220
+ import { jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
221
+ function ApiRequestDialog({
222
+ extension,
223
+ url,
224
+ method,
225
+ data,
226
+ onAccept,
227
+ onCancel
228
+ }) {
229
+ const dialog = useRef(null);
230
+ const cancel = useRef(null);
231
+ const title = useId2();
232
+ const description = useId2();
233
+ const [remember, setRemember] = useState2(false);
234
+ useEffect(() => {
235
+ const element = dialog.current;
236
+ const previous = element?.ownerDocument.activeElement;
237
+ element?.showModal();
238
+ cancel.current?.focus();
239
+ return () => {
240
+ element?.close();
241
+ if (previous instanceof HTMLElement && previous.isConnected) previous.focus();
242
+ };
243
+ }, []);
244
+ return /* @__PURE__ */ jsxs7(
245
+ "dialog",
246
+ {
247
+ ref: dialog,
248
+ className: "edhspace-api-dialog",
249
+ "aria-labelledby": title,
250
+ "aria-describedby": description,
251
+ onCancel: (event) => {
252
+ event.preventDefault();
253
+ onCancel();
254
+ },
255
+ onKeyDown: (event) => {
256
+ if (event.key !== "Tab") return;
257
+ const controls = Array.from(
258
+ event.currentTarget.querySelectorAll(
259
+ 'button:not([disabled]), input:not([disabled]), [tabindex="0"]'
260
+ )
261
+ );
262
+ const first = controls[0];
263
+ const last = controls[controls.length - 1];
264
+ const active = event.currentTarget.ownerDocument.activeElement;
265
+ if (event.shiftKey && active === first) {
266
+ event.preventDefault();
267
+ last?.focus();
268
+ } else if (!event.shiftKey && active === last) {
269
+ event.preventDefault();
270
+ first?.focus();
271
+ }
272
+ },
273
+ children: [
274
+ /* @__PURE__ */ jsx19("h2", { id: title, children: "Allow API request?" }),
275
+ /* @__PURE__ */ jsxs7("p", { id: description, children: [
276
+ extension,
277
+ " will send the shown data to this service."
278
+ ] }),
279
+ /* @__PURE__ */ jsxs7("dl", { children: [
280
+ /* @__PURE__ */ jsx19("dt", { children: "Request" }),
281
+ /* @__PURE__ */ jsx19("dd", { children: method }),
282
+ /* @__PURE__ */ jsx19("dt", { children: "Destination" }),
283
+ /* @__PURE__ */ jsx19("dd", { children: url })
284
+ ] }),
285
+ /* @__PURE__ */ jsx19("pre", { "aria-label": "Request data", tabIndex: 0, children: data }),
286
+ /* @__PURE__ */ jsx19("p", { children: "EDHspace cookies and account credentials are not sent." }),
287
+ method === "GET" && /* @__PURE__ */ jsxs7("label", { className: "edhspace-api-remember", children: [
288
+ /* @__PURE__ */ jsx19(
289
+ "input",
290
+ {
291
+ type: "checkbox",
292
+ checked: remember,
293
+ onChange: (event) => setRemember(event.target.checked)
294
+ }
295
+ ),
296
+ "Allow GET requests to this API for this session"
297
+ ] }),
298
+ /* @__PURE__ */ jsxs7(ActionBar, { label: "API request approval", children: [
299
+ /* @__PURE__ */ jsx19(Button, { ref: cancel, onClick: onCancel, children: "Cancel" }),
300
+ /* @__PURE__ */ jsx19(Button, { onClick: () => onAccept(remember), children: "Allow request" })
301
+ ] })
302
+ ]
303
+ }
304
+ );
305
+ }
306
+ export {
307
+ ActionBar,
308
+ ActionPanel,
309
+ ApiRequestDialog,
310
+ Button,
311
+ CardList,
312
+ CardPreview,
313
+ CardPreviewProvider,
314
+ DataTable,
315
+ EmptyState,
316
+ Field,
317
+ FilterBar,
318
+ ManaCost,
319
+ Notice,
320
+ Panel,
321
+ Panel as PanelLayout,
322
+ StatBadge,
323
+ SymbolRenderingProvider,
324
+ SymbolText,
325
+ ThemeProvider
326
+ };
@@ -0,0 +1,238 @@
1
+ .edhspace-ui {
2
+ --edhspace-background: var(--set-panel, #fff);
3
+ --edhspace-foreground: var(--set-text, #182b24);
4
+ --edhspace-muted: var(--set-muted, #485b53);
5
+ --edhspace-accent: var(--set-accent, #245a42);
6
+ --edhspace-border: var(--set-border, #81968b);
7
+ --edhspace-font: inherit;
8
+ min-height: 100%;
9
+ background: var(--edhspace-background);
10
+ color: var(--edhspace-foreground);
11
+ font-family: var(--edhspace-font);
12
+ line-height: 1.5;
13
+ accent-color: var(--edhspace-accent);
14
+ caret-color: var(--edhspace-accent);
15
+ scrollbar-color: var(--edhspace-border) var(--edhspace-background);
16
+ }
17
+ .edhspace-ui *,
18
+ .edhspace-ui *::before,
19
+ .edhspace-ui *::after {
20
+ box-sizing: border-box;
21
+ }
22
+ .edhspace-ui ::selection {
23
+ background: var(--edhspace-accent);
24
+ color: var(--edhspace-background);
25
+ }
26
+ .edhspace-panel {
27
+ padding: 1rem;
28
+ min-width: 0;
29
+ }
30
+ .edhspace-panel > header {
31
+ display: flex;
32
+ flex-wrap: wrap;
33
+ align-items: center;
34
+ gap: 0.65rem;
35
+ margin-bottom: 1rem;
36
+ }
37
+ .edhspace-panel h2 {
38
+ flex: 1 1 12rem;
39
+ font-size: 1.15rem;
40
+ margin: 0;
41
+ overflow-wrap: anywhere;
42
+ }
43
+ .edhspace-actions {
44
+ display: flex;
45
+ flex-wrap: wrap;
46
+ gap: 0.65rem;
47
+ align-items: center;
48
+ }
49
+ .edhspace-ui .edhspace-button,
50
+ .edhspace-ui .edhspace-field input {
51
+ margin: 0;
52
+ min-height: 44px;
53
+ max-width: 100%;
54
+ border: 1px solid var(--edhspace-border);
55
+ border-radius: 6px;
56
+ background: var(--edhspace-background);
57
+ color: var(--edhspace-foreground);
58
+ font: inherit;
59
+ padding: 0.5rem 0.75rem;
60
+ }
61
+ .edhspace-ui .edhspace-button {
62
+ cursor: pointer;
63
+ min-width: 44px;
64
+ overflow-wrap: anywhere;
65
+ }
66
+ .edhspace-ui .edhspace-button:hover:not(:disabled) {
67
+ background: color-mix(in srgb, var(--edhspace-accent) 12%, var(--edhspace-background));
68
+ }
69
+ .edhspace-ui .edhspace-button:disabled,
70
+ .edhspace-ui .edhspace-button[aria-disabled="true"] {
71
+ opacity: 0.55;
72
+ cursor: not-allowed;
73
+ }
74
+ .edhspace-ui :focus-visible {
75
+ outline: 2px solid var(--edhspace-accent);
76
+ outline-offset: 2px;
77
+ }
78
+ .edhspace-ui .edhspace-field {
79
+ display: grid;
80
+ gap: 0.4rem;
81
+ min-width: 0;
82
+ margin: 0;
83
+ }
84
+ .edhspace-notice {
85
+ color: var(--edhspace-muted);
86
+ overflow-wrap: anywhere;
87
+ }
88
+ .edhspace-notice[role="alert"] {
89
+ color: var(--edhspace-foreground);
90
+ font-weight: 600;
91
+ }
92
+ .edhspace-card-list {
93
+ padding: 0;
94
+ margin: 1rem 0;
95
+ list-style: none;
96
+ }
97
+ .edhspace-card-list > li {
98
+ display: flex;
99
+ align-items: center;
100
+ gap: 0.65rem;
101
+ padding: 0.25rem 0;
102
+ border-bottom: 1px solid var(--edhspace-border);
103
+ }
104
+ .edhspace-card-list > li > span:first-child {
105
+ min-width: 2ch;
106
+ font-variant-numeric: tabular-nums;
107
+ }
108
+ .edhspace-card-list .edhspace-button {
109
+ flex: 1;
110
+ min-width: 0;
111
+ border: 0;
112
+ text-align: start;
113
+ }
114
+ .edhspace-ui .mana-cost {
115
+ display: inline-flex;
116
+ flex-wrap: wrap;
117
+ align-items: center;
118
+ gap: 0.12rem;
119
+ max-width: 35%;
120
+ }
121
+ .edhspace-ui .mana-cost img {
122
+ display: block;
123
+ width: 1em;
124
+ height: 1em;
125
+ min-width: 14px;
126
+ min-height: 14px;
127
+ }
128
+ .edhspace-ui .oracle-symbol {
129
+ display: inline-block;
130
+ vertical-align: -0.12em;
131
+ margin-inline: 0.06em;
132
+ }
133
+ .edhspace-ui .oracle-symbol img {
134
+ width: 1em;
135
+ height: 1em;
136
+ }
137
+ .edhspace-filter-bar {
138
+ display: flex;
139
+ flex-wrap: wrap;
140
+ gap: 0.75rem;
141
+ align-items: end;
142
+ margin-block: 1rem;
143
+ }
144
+ .edhspace-filter-bar > * {
145
+ flex: 1 1 9rem;
146
+ }
147
+ .edhspace-filter-bar .edhspace-field input {
148
+ width: 100%;
149
+ }
150
+ .edhspace-stat {
151
+ display: inline-block;
152
+ margin-inline-end: 1rem;
153
+ font-variant-numeric: tabular-nums;
154
+ }
155
+ .edhspace-table-scroll {
156
+ overflow-x: auto;
157
+ margin-block: 1rem;
158
+ }
159
+ .edhspace-table-scroll table {
160
+ width: 100%;
161
+ border-collapse: collapse;
162
+ font-variant-numeric: tabular-nums;
163
+ }
164
+ .edhspace-table-scroll th,
165
+ .edhspace-table-scroll td {
166
+ padding: 0.55rem;
167
+ text-align: start;
168
+ border-bottom: 1px solid var(--edhspace-border);
169
+ }
170
+ .edhspace-card-list .inline-card-link {
171
+ flex: 1;
172
+ min-width: 0;
173
+ min-height: 44px;
174
+ display: inline-flex;
175
+ align-items: center;
176
+ color: var(--edhspace-accent);
177
+ text-underline-offset: 0.2em;
178
+ overflow-wrap: anywhere;
179
+ }
180
+ .edhspace-api-dialog {
181
+ width: min(36rem, calc(100vw - 2rem));
182
+ max-height: calc(100dvh - 2rem);
183
+ overflow: auto;
184
+ padding: 1.25rem;
185
+ border: 1px solid var(--edhspace-border);
186
+ border-radius: 6px;
187
+ background: var(--edhspace-background);
188
+ color: var(--edhspace-foreground);
189
+ font: inherit;
190
+ }
191
+ .edhspace-api-dialog::backdrop {
192
+ background: rgb(0 0 0 / 45%);
193
+ }
194
+ .edhspace-api-dialog:not([open]) {
195
+ display: none;
196
+ }
197
+ .edhspace-api-dialog h2 {
198
+ margin-block: 0 0.75rem;
199
+ font-size: 1.15rem;
200
+ }
201
+ .edhspace-api-dialog dl {
202
+ display: grid;
203
+ grid-template-columns: minmax(0, 1fr);
204
+ gap: 0.4rem 0.75rem;
205
+ }
206
+ .edhspace-api-dialog dt {
207
+ font-weight: 600;
208
+ }
209
+ .edhspace-api-dialog p {
210
+ overflow-wrap: anywhere;
211
+ }
212
+ @media (min-width: 600px) {
213
+ .edhspace-api-dialog dl {
214
+ grid-template-columns: auto minmax(0, 1fr);
215
+ }
216
+ }
217
+ .edhspace-api-dialog dd {
218
+ margin: 0;
219
+ overflow-wrap: anywhere;
220
+ }
221
+ .edhspace-api-dialog pre {
222
+ white-space: pre-wrap;
223
+ overflow-wrap: anywhere;
224
+ max-height: 12rem;
225
+ overflow: auto;
226
+ }
227
+ .edhspace-ui .edhspace-api-remember {
228
+ display: flex;
229
+ gap: 0.65rem;
230
+ align-items: center;
231
+ min-height: 44px;
232
+ margin-block: 1rem;
233
+ }
234
+ .edhspace-api-remember input {
235
+ width: 20px;
236
+ height: 20px;
237
+ flex-shrink: 0;
238
+ }
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
- "name": "@edhspace/ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@edhspace/ui",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "description": "Standalone themed React primitives for EDHspace and community extensions",
6
+ "license": "ISC",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/EDHspace/extensions.git",
10
+ "directory": "packages/ui"
11
+ },
12
+ "homepage": "https://github.com/EDHspace/extensions/tree/main/packages/ui#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/EDHspace/extensions/issues"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.cjs"
29
+ },
30
+ "./styles.css": "./dist/styles.css"
31
+ },
32
+ "sideEffects": [
33
+ "*.css"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "typecheck": "tsc --noEmit",
38
+ "test": "vitest run"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^19.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/react": "^19.2.18",
45
+ "@types/react-dom": "^19.2.4",
46
+ "react": "^19.2.8",
47
+ "react-dom": "^19.2.8",
48
+ "tsup": "^8.0.0",
49
+ "typescript": "^5.3.3",
50
+ "vitest": "3.2.7"
51
+ },
52
+ "engines": {
53
+ "node": ">=22.12.0"
54
+ }
55
+ }