@edhspace/ui 0.1.0 → 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/README.md +3 -0
- package/dist/index.cjs +43 -25
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +30 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,9 @@ Styles are opt-in and namespaced. Native usage inherits live `--set-*` tokens;
|
|
|
29
29
|
standalone ThemeProvider accepts background, foreground, muted, accent, border
|
|
30
30
|
and font. No theme reopen or animation is required. Mana images use
|
|
31
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.
|
|
32
35
|
|
|
33
36
|
Controls have 44px targets, visible focus, wrapper-based gaps and wrapping.
|
|
34
37
|
Fields associate labels with inputs; Notice announces status/errors.
|
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
Panel: () => Panel,
|
|
37
37
|
PanelLayout: () => Panel,
|
|
38
38
|
StatBadge: () => StatBadge,
|
|
39
|
+
SymbolRenderingProvider: () => SymbolRenderingProvider,
|
|
39
40
|
SymbolText: () => SymbolText,
|
|
40
41
|
ThemeProvider: () => ThemeProvider
|
|
41
42
|
});
|
|
@@ -115,12 +116,19 @@ function CardPreview({ card, onInspect }) {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
// src/components/symbol.tsx
|
|
119
|
+
var import_react5 = require("react");
|
|
120
|
+
|
|
121
|
+
// src/contexts/symbol-rendering.ts
|
|
118
122
|
var import_react4 = require("react");
|
|
123
|
+
var SymbolRenderingContext = (0, import_react4.createContext)("images");
|
|
124
|
+
|
|
125
|
+
// src/components/symbol.tsx
|
|
119
126
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
120
127
|
function Symbol2({ token, labeled = false }) {
|
|
121
|
-
const
|
|
128
|
+
const mode = (0, import_react5.useContext)(SymbolRenderingContext);
|
|
129
|
+
const [failed, setFailed] = (0, import_react5.useState)(false);
|
|
122
130
|
const name = token.slice(1, -1).replaceAll("/", "");
|
|
123
|
-
return failed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: token }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
131
|
+
return failed || mode === "text" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: token }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
124
132
|
"img",
|
|
125
133
|
{
|
|
126
134
|
src: `https://svgs.scryfall.io/card-symbols/${encodeURIComponent(name)}.svg`,
|
|
@@ -242,9 +250,18 @@ function SymbolText({ text }) {
|
|
|
242
250
|
) });
|
|
243
251
|
}
|
|
244
252
|
|
|
245
|
-
// src/components/
|
|
246
|
-
var import_react5 = require("react");
|
|
253
|
+
// src/components/symbol-rendering-provider.tsx
|
|
247
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");
|
|
248
265
|
function ApiRequestDialog({
|
|
249
266
|
extension,
|
|
250
267
|
url,
|
|
@@ -253,12 +270,12 @@ function ApiRequestDialog({
|
|
|
253
270
|
onAccept,
|
|
254
271
|
onCancel
|
|
255
272
|
}) {
|
|
256
|
-
const dialog = (0,
|
|
257
|
-
const cancel = (0,
|
|
258
|
-
const title = (0,
|
|
259
|
-
const description = (0,
|
|
260
|
-
const [remember, setRemember] = (0,
|
|
261
|
-
(0,
|
|
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)(() => {
|
|
262
279
|
const element = dialog.current;
|
|
263
280
|
const previous = element?.ownerDocument.activeElement;
|
|
264
281
|
element?.showModal();
|
|
@@ -268,7 +285,7 @@ function ApiRequestDialog({
|
|
|
268
285
|
if (previous instanceof HTMLElement && previous.isConnected) previous.focus();
|
|
269
286
|
};
|
|
270
287
|
}, []);
|
|
271
|
-
return /* @__PURE__ */ (0,
|
|
288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
272
289
|
"dialog",
|
|
273
290
|
{
|
|
274
291
|
ref: dialog,
|
|
@@ -298,21 +315,21 @@ function ApiRequestDialog({
|
|
|
298
315
|
}
|
|
299
316
|
},
|
|
300
317
|
children: [
|
|
301
|
-
/* @__PURE__ */ (0,
|
|
302
|
-
/* @__PURE__ */ (0,
|
|
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: [
|
|
303
320
|
extension,
|
|
304
321
|
" will send the shown data to this service."
|
|
305
322
|
] }),
|
|
306
|
-
/* @__PURE__ */ (0,
|
|
307
|
-
/* @__PURE__ */ (0,
|
|
308
|
-
/* @__PURE__ */ (0,
|
|
309
|
-
/* @__PURE__ */ (0,
|
|
310
|
-
/* @__PURE__ */ (0,
|
|
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 })
|
|
311
328
|
] }),
|
|
312
|
-
/* @__PURE__ */ (0,
|
|
313
|
-
/* @__PURE__ */ (0,
|
|
314
|
-
method === "GET" && /* @__PURE__ */ (0,
|
|
315
|
-
/* @__PURE__ */ (0,
|
|
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)(
|
|
316
333
|
"input",
|
|
317
334
|
{
|
|
318
335
|
type: "checkbox",
|
|
@@ -322,9 +339,9 @@ function ApiRequestDialog({
|
|
|
322
339
|
),
|
|
323
340
|
"Allow GET requests to this API for this session"
|
|
324
341
|
] }),
|
|
325
|
-
/* @__PURE__ */ (0,
|
|
326
|
-
/* @__PURE__ */ (0,
|
|
327
|
-
/* @__PURE__ */ (0,
|
|
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" })
|
|
328
345
|
] })
|
|
329
346
|
]
|
|
330
347
|
}
|
|
@@ -348,6 +365,7 @@ function ApiRequestDialog({
|
|
|
348
365
|
Panel,
|
|
349
366
|
PanelLayout,
|
|
350
367
|
StatBadge,
|
|
368
|
+
SymbolRenderingProvider,
|
|
351
369
|
SymbolText,
|
|
352
370
|
ThemeProvider
|
|
353
371
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -102,6 +102,11 @@ declare function SymbolText({ text }: {
|
|
|
102
102
|
text: string | null | undefined;
|
|
103
103
|
}): react.JSX.Element;
|
|
104
104
|
|
|
105
|
+
declare function SymbolRenderingProvider({ mode, children, }: {
|
|
106
|
+
mode: "images" | "text";
|
|
107
|
+
children: ReactNode;
|
|
108
|
+
}): react.JSX.Element;
|
|
109
|
+
|
|
105
110
|
declare function ApiRequestDialog({ extension, url, method, data, onAccept, onCancel, }: {
|
|
106
111
|
extension: string;
|
|
107
112
|
url: string;
|
|
@@ -111,4 +116,4 @@ declare function ApiRequestDialog({ extension, url, method, data, onAccept, onCa
|
|
|
111
116
|
onCancel(): void;
|
|
112
117
|
}): react.JSX.Element;
|
|
113
118
|
|
|
114
|
-
export { ActionBar, ActionPanel, ApiRequestDialog, Button, CardList, type CardListItem, CardPreview, CardPreviewProvider, DataTable, EmptyState, Field, FilterBar, ManaCost, Notice, Panel, Panel as PanelLayout, StatBadge, SymbolText, type Theme, ThemeProvider };
|
|
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.d.ts
CHANGED
|
@@ -102,6 +102,11 @@ declare function SymbolText({ text }: {
|
|
|
102
102
|
text: string | null | undefined;
|
|
103
103
|
}): react.JSX.Element;
|
|
104
104
|
|
|
105
|
+
declare function SymbolRenderingProvider({ mode, children, }: {
|
|
106
|
+
mode: "images" | "text";
|
|
107
|
+
children: ReactNode;
|
|
108
|
+
}): react.JSX.Element;
|
|
109
|
+
|
|
105
110
|
declare function ApiRequestDialog({ extension, url, method, data, onAccept, onCancel, }: {
|
|
106
111
|
extension: string;
|
|
107
112
|
url: string;
|
|
@@ -111,4 +116,4 @@ declare function ApiRequestDialog({ extension, url, method, data, onAccept, onCa
|
|
|
111
116
|
onCancel(): void;
|
|
112
117
|
}): react.JSX.Element;
|
|
113
118
|
|
|
114
|
-
export { ActionBar, ActionPanel, ApiRequestDialog, Button, CardList, type CardListItem, CardPreview, CardPreviewProvider, DataTable, EmptyState, Field, FilterBar, ManaCost, Notice, Panel, Panel as PanelLayout, StatBadge, SymbolText, type Theme, ThemeProvider };
|
|
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
CHANGED
|
@@ -72,12 +72,19 @@ function CardPreview({ card, onInspect }) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// src/components/symbol.tsx
|
|
75
|
-
import { useState } from "react";
|
|
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
|
|
76
82
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
77
83
|
function Symbol({ token, labeled = false }) {
|
|
84
|
+
const mode = useContext2(SymbolRenderingContext);
|
|
78
85
|
const [failed, setFailed] = useState(false);
|
|
79
86
|
const name = token.slice(1, -1).replaceAll("/", "");
|
|
80
|
-
return failed ? /* @__PURE__ */ jsx8("span", { children: token }) : /* @__PURE__ */ jsx8(
|
|
87
|
+
return failed || mode === "text" ? /* @__PURE__ */ jsx8("span", { children: token }) : /* @__PURE__ */ jsx8(
|
|
81
88
|
"img",
|
|
82
89
|
{
|
|
83
90
|
src: `https://svgs.scryfall.io/card-symbols/${encodeURIComponent(name)}.svg`,
|
|
@@ -199,9 +206,18 @@ function SymbolText({ text }) {
|
|
|
199
206
|
) });
|
|
200
207
|
}
|
|
201
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
|
+
|
|
202
218
|
// src/components/api-request-dialog.tsx
|
|
203
219
|
import { useEffect, useId as useId2, useRef, useState as useState2 } from "react";
|
|
204
|
-
import { jsx as
|
|
220
|
+
import { jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
205
221
|
function ApiRequestDialog({
|
|
206
222
|
extension,
|
|
207
223
|
url,
|
|
@@ -255,21 +271,21 @@ function ApiRequestDialog({
|
|
|
255
271
|
}
|
|
256
272
|
},
|
|
257
273
|
children: [
|
|
258
|
-
/* @__PURE__ */
|
|
274
|
+
/* @__PURE__ */ jsx19("h2", { id: title, children: "Allow API request?" }),
|
|
259
275
|
/* @__PURE__ */ jsxs7("p", { id: description, children: [
|
|
260
276
|
extension,
|
|
261
277
|
" will send the shown data to this service."
|
|
262
278
|
] }),
|
|
263
279
|
/* @__PURE__ */ jsxs7("dl", { children: [
|
|
264
|
-
/* @__PURE__ */
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
/* @__PURE__ */
|
|
267
|
-
/* @__PURE__ */
|
|
280
|
+
/* @__PURE__ */ jsx19("dt", { children: "Request" }),
|
|
281
|
+
/* @__PURE__ */ jsx19("dd", { children: method }),
|
|
282
|
+
/* @__PURE__ */ jsx19("dt", { children: "Destination" }),
|
|
283
|
+
/* @__PURE__ */ jsx19("dd", { children: url })
|
|
268
284
|
] }),
|
|
269
|
-
/* @__PURE__ */
|
|
270
|
-
/* @__PURE__ */
|
|
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." }),
|
|
271
287
|
method === "GET" && /* @__PURE__ */ jsxs7("label", { className: "edhspace-api-remember", children: [
|
|
272
|
-
/* @__PURE__ */
|
|
288
|
+
/* @__PURE__ */ jsx19(
|
|
273
289
|
"input",
|
|
274
290
|
{
|
|
275
291
|
type: "checkbox",
|
|
@@ -280,8 +296,8 @@ function ApiRequestDialog({
|
|
|
280
296
|
"Allow GET requests to this API for this session"
|
|
281
297
|
] }),
|
|
282
298
|
/* @__PURE__ */ jsxs7(ActionBar, { label: "API request approval", children: [
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ jsx19(Button, { ref: cancel, onClick: onCancel, children: "Cancel" }),
|
|
300
|
+
/* @__PURE__ */ jsx19(Button, { onClick: () => onAccept(remember), children: "Allow request" })
|
|
285
301
|
] })
|
|
286
302
|
]
|
|
287
303
|
}
|
|
@@ -304,6 +320,7 @@ export {
|
|
|
304
320
|
Panel,
|
|
305
321
|
Panel as PanelLayout,
|
|
306
322
|
StatBadge,
|
|
323
|
+
SymbolRenderingProvider,
|
|
307
324
|
SymbolText,
|
|
308
325
|
ThemeProvider
|
|
309
326
|
};
|