@agot/card-preview 1.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.
- package/README.md +16 -0
- package/dist/index.d.mts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +740 -0
- package/dist/index.mjs +707 -0
- package/package.json +33 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
// src/components/cardComponents.tsx
|
|
2
|
+
import classNames2 from "classnames";
|
|
3
|
+
|
|
4
|
+
// ../common/models/cards.ts
|
|
5
|
+
var challengeIcons = ["military", "intrigue", "power"];
|
|
6
|
+
var DefaultDeckLimit = /* @__PURE__ */ ((DefaultDeckLimit2) => {
|
|
7
|
+
DefaultDeckLimit2[DefaultDeckLimit2["character"] = 3] = "character";
|
|
8
|
+
DefaultDeckLimit2[DefaultDeckLimit2["attachment"] = 3] = "attachment";
|
|
9
|
+
DefaultDeckLimit2[DefaultDeckLimit2["location"] = 3] = "location";
|
|
10
|
+
DefaultDeckLimit2[DefaultDeckLimit2["event"] = 3] = "event";
|
|
11
|
+
DefaultDeckLimit2[DefaultDeckLimit2["plot"] = 2] = "plot";
|
|
12
|
+
DefaultDeckLimit2[DefaultDeckLimit2["agenda"] = 1] = "agenda";
|
|
13
|
+
return DefaultDeckLimit2;
|
|
14
|
+
})(DefaultDeckLimit || {});
|
|
15
|
+
|
|
16
|
+
// src/components/autoSize.tsx
|
|
17
|
+
import { useEffect, useRef } from "react";
|
|
18
|
+
|
|
19
|
+
// src/utils.ts
|
|
20
|
+
var px = (value) => `${value}px`;
|
|
21
|
+
var em = (value) => `${value}em`;
|
|
22
|
+
|
|
23
|
+
// src/components/autoSize.tsx
|
|
24
|
+
import { jsx } from "react/jsx-runtime";
|
|
25
|
+
var AutoSize = ({ children, className, style, height, rate = 0.01, minimum = 0.4 }) => {
|
|
26
|
+
const contentRef = useRef(null);
|
|
27
|
+
const dependencies = Array.isArray(children) ? children : [children];
|
|
28
|
+
const elements = useRef(/* @__PURE__ */ new Map());
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const content = contentRef.current;
|
|
31
|
+
if (!content) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let multiplier = 1;
|
|
35
|
+
const baseSizes = elements.current;
|
|
36
|
+
for (const [element, baseSize] of [...baseSizes.entries()]) {
|
|
37
|
+
element.style.fontSize = px(baseSize);
|
|
38
|
+
baseSizes.delete(element);
|
|
39
|
+
}
|
|
40
|
+
const shrink = (el) => {
|
|
41
|
+
if (el.style.fontSize) {
|
|
42
|
+
if (!baseSizes.has(el)) {
|
|
43
|
+
const currentSize = parseFloat(el.style.fontSize);
|
|
44
|
+
baseSizes.set(el, currentSize);
|
|
45
|
+
}
|
|
46
|
+
const baseSize = baseSizes.get(el);
|
|
47
|
+
el.style.fontSize = px(baseSize * multiplier);
|
|
48
|
+
}
|
|
49
|
+
for (const child of el.children) {
|
|
50
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
51
|
+
shrink(child);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const isOverflowing = () => content.scrollWidth > content.clientWidth || content.scrollHeight > content.clientHeight;
|
|
56
|
+
while (multiplier > minimum && isOverflowing()) {
|
|
57
|
+
content.style.fontSize = content.style.fontSize || window.getComputedStyle(content).fontSize;
|
|
58
|
+
multiplier -= rate;
|
|
59
|
+
shrink(content);
|
|
60
|
+
}
|
|
61
|
+
}, [...dependencies, minimum, rate]);
|
|
62
|
+
return /* @__PURE__ */ jsx("div", { ref: contentRef, className, style: { ...style, height: px(height) }, children });
|
|
63
|
+
};
|
|
64
|
+
var autoSize_default = AutoSize;
|
|
65
|
+
|
|
66
|
+
// src/components/cardComponents.tsx
|
|
67
|
+
import { memo, useMemo } from "react";
|
|
68
|
+
|
|
69
|
+
// ../client/src/components/thronesIcon.tsx
|
|
70
|
+
import classNames from "classnames";
|
|
71
|
+
|
|
72
|
+
// ../common/utils.ts
|
|
73
|
+
var thronesColors = {
|
|
74
|
+
"baratheon": "#e3d852",
|
|
75
|
+
"greyjoy": "#1d7a99",
|
|
76
|
+
"lannister": "#c00106",
|
|
77
|
+
"martell": "#e89521",
|
|
78
|
+
"thenightswatch": "#7a7a7a",
|
|
79
|
+
"stark": "#cfcfcf",
|
|
80
|
+
"targaryen": "#1c1c1c",
|
|
81
|
+
"tyrell": "#509f16",
|
|
82
|
+
"neutral": "#a99560",
|
|
83
|
+
"income": "#ffd240",
|
|
84
|
+
"initiative": "#bb9570",
|
|
85
|
+
"claim": "#afafaf",
|
|
86
|
+
"reserve": "#f0623f"
|
|
87
|
+
};
|
|
88
|
+
var abilityIcons = {
|
|
89
|
+
military: "\uE605",
|
|
90
|
+
intrigue: "\uE602",
|
|
91
|
+
power: "\uE607",
|
|
92
|
+
baratheon: "\uE600",
|
|
93
|
+
greyjoy: "\uE601",
|
|
94
|
+
lannister: "\uE603",
|
|
95
|
+
martell: "\uE604",
|
|
96
|
+
thenightswatch: "\uE606",
|
|
97
|
+
stark: "\uE608",
|
|
98
|
+
targaryen: "\uE609",
|
|
99
|
+
tyrell: "\uE60A"
|
|
100
|
+
};
|
|
101
|
+
var thronesIcons = {
|
|
102
|
+
...abilityIcons,
|
|
103
|
+
neutral: "\uE612",
|
|
104
|
+
unique: "\uE60B",
|
|
105
|
+
character: "\uE60F",
|
|
106
|
+
location: "\uE60E",
|
|
107
|
+
attachment: "\uE60D",
|
|
108
|
+
event: "\uE610",
|
|
109
|
+
plot: "\uE60C",
|
|
110
|
+
agenda: "\uE611"
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// ../client/src/components/thronesIcon.tsx
|
|
114
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
115
|
+
var ThronesIcon = ({ name, className, style, visible = true }) => {
|
|
116
|
+
return /* @__PURE__ */ jsx2("span", { className: classNames("font-thronesdb leading-none", { invisible: !visible, "leading-relaxed": name === "unique" }, className), style, children: thronesIcons[name] });
|
|
117
|
+
};
|
|
118
|
+
var thronesIcon_default = ThronesIcon;
|
|
119
|
+
|
|
120
|
+
// src/components/cardComponents.tsx
|
|
121
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
122
|
+
var defaultOrientation = (type) => type === "plot" ? "horizontal" : "vertical";
|
|
123
|
+
var Card = memo(({ children, card, orientation = defaultOrientation(card.type), scale = 1, rounded = true, className, classNames: classGroups, style, styles: styleGroups, ...props }) => {
|
|
124
|
+
const width = 240;
|
|
125
|
+
const height = 333;
|
|
126
|
+
const wrapperWidth = orientation === "horizontal" ? height : width;
|
|
127
|
+
const wrapperHeight = orientation === "horizontal" ? width : height;
|
|
128
|
+
const innerWidth = card.type === "plot" ? height : width;
|
|
129
|
+
const innerHeight = card.type === "plot" ? width : height;
|
|
130
|
+
const rotate = orientation !== defaultOrientation(card.type);
|
|
131
|
+
const innerStyle = useMemo(() => {
|
|
132
|
+
const style2 = {
|
|
133
|
+
borderColor: card.faction ? thronesColors[card.faction] : "white",
|
|
134
|
+
background: "white",
|
|
135
|
+
color: "black",
|
|
136
|
+
fontFamily: "Open Sans, sans-serif",
|
|
137
|
+
...scale !== 1 && { scale },
|
|
138
|
+
...(scale !== 1 || rotate) && { transformOrigin: "top left" },
|
|
139
|
+
...rotate && { position: "relative", rotate: "270deg", top: "100%" },
|
|
140
|
+
...styleGroups?.inner
|
|
141
|
+
};
|
|
142
|
+
return style2;
|
|
143
|
+
}, [card.faction, rotate, scale, styleGroups?.inner]);
|
|
144
|
+
return /* @__PURE__ */ jsx3(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
className: classNames2(className, classGroups?.wrapper),
|
|
148
|
+
style: {
|
|
149
|
+
overflow: "hidden",
|
|
150
|
+
width: px(wrapperWidth * scale),
|
|
151
|
+
height: px(wrapperHeight * scale),
|
|
152
|
+
...rounded && { borderRadius: px(12) },
|
|
153
|
+
...style,
|
|
154
|
+
...styleGroups?.wrapper
|
|
155
|
+
},
|
|
156
|
+
...props,
|
|
157
|
+
children: /* @__PURE__ */ jsx3(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
className: classGroups?.inner,
|
|
161
|
+
style: {
|
|
162
|
+
width: px(innerWidth),
|
|
163
|
+
height: px(innerHeight),
|
|
164
|
+
borderWidth: px(12),
|
|
165
|
+
...innerStyle
|
|
166
|
+
},
|
|
167
|
+
children
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
var Type = memo(({ children: type, className, style }) => {
|
|
174
|
+
return /* @__PURE__ */ jsx3("div", { className, style: { position: "relative", top: px(-5), left: px(2), fontSize: px(8), ...style }, children: type });
|
|
175
|
+
});
|
|
176
|
+
var Cost = memo(({ children, className, style }) => {
|
|
177
|
+
return /* @__PURE__ */ jsx3(
|
|
178
|
+
autoSize_default,
|
|
179
|
+
{
|
|
180
|
+
height: 35,
|
|
181
|
+
className,
|
|
182
|
+
style: {
|
|
183
|
+
top: px(-7.5),
|
|
184
|
+
left: px(-7.5),
|
|
185
|
+
width: px(35),
|
|
186
|
+
lineHeight: px(30),
|
|
187
|
+
fontSize: px(24),
|
|
188
|
+
borderWidth: px(2),
|
|
189
|
+
position: "relative",
|
|
190
|
+
borderRadius: "100%",
|
|
191
|
+
borderColor: "black",
|
|
192
|
+
borderStyle: "solid",
|
|
193
|
+
background: "white",
|
|
194
|
+
textAlign: "center",
|
|
195
|
+
...style
|
|
196
|
+
},
|
|
197
|
+
children
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
var ChallengeIcons = memo(({ children: icons = [], className, style }) => {
|
|
202
|
+
return /* @__PURE__ */ jsx3("div", { className, style: {
|
|
203
|
+
display: "flex",
|
|
204
|
+
flexDirection: "column",
|
|
205
|
+
flexGrow: 1,
|
|
206
|
+
...style
|
|
207
|
+
}, children: challengeIcons.map(
|
|
208
|
+
(icon) => /* @__PURE__ */ jsx3("span", { style: {
|
|
209
|
+
display: "flex",
|
|
210
|
+
flexDirection: "column",
|
|
211
|
+
flexGrow: 1,
|
|
212
|
+
justifyContent: "center",
|
|
213
|
+
alignItems: "center"
|
|
214
|
+
}, children: /* @__PURE__ */ jsx3(
|
|
215
|
+
thronesIcon_default,
|
|
216
|
+
{
|
|
217
|
+
name: icon,
|
|
218
|
+
style: {
|
|
219
|
+
height: "calc(1/3 * 100%)",
|
|
220
|
+
display: "flex",
|
|
221
|
+
justifyContent: "center",
|
|
222
|
+
alignItems: "center",
|
|
223
|
+
fontSize: px(20)
|
|
224
|
+
},
|
|
225
|
+
visible: icons.includes(icon)
|
|
226
|
+
}
|
|
227
|
+
) }, icon)
|
|
228
|
+
) });
|
|
229
|
+
});
|
|
230
|
+
var Loyalty = memo(({ children: loyal, className, style }) => {
|
|
231
|
+
return /* @__PURE__ */ jsx3(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
className,
|
|
235
|
+
style: {
|
|
236
|
+
display: "flex",
|
|
237
|
+
alignItems: "center",
|
|
238
|
+
justifyContent: "center",
|
|
239
|
+
width: px(35),
|
|
240
|
+
height: px(15),
|
|
241
|
+
fontSize: px(10),
|
|
242
|
+
...style
|
|
243
|
+
},
|
|
244
|
+
children: loyal && "Loyal"
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
var Strength = memo(({ children: strength, className, style }) => {
|
|
249
|
+
return /* @__PURE__ */ jsx3(
|
|
250
|
+
autoSize_default,
|
|
251
|
+
{
|
|
252
|
+
height: 35,
|
|
253
|
+
className,
|
|
254
|
+
style: {
|
|
255
|
+
display: "flex",
|
|
256
|
+
justifyContent: "center",
|
|
257
|
+
alignItems: "cneter",
|
|
258
|
+
boxSizing: "border-box",
|
|
259
|
+
backgroundColor: "#e5e7eb",
|
|
260
|
+
borderColor: "black",
|
|
261
|
+
borderWidth: px(2),
|
|
262
|
+
width: px(35),
|
|
263
|
+
fontSize: px(22),
|
|
264
|
+
...style
|
|
265
|
+
},
|
|
266
|
+
children: strength
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
});
|
|
270
|
+
var Name = memo(({ unique, height, children: name, className, style }) => {
|
|
271
|
+
return /* @__PURE__ */ jsxs(
|
|
272
|
+
autoSize_default,
|
|
273
|
+
{
|
|
274
|
+
height: height ?? 35,
|
|
275
|
+
className,
|
|
276
|
+
style: {
|
|
277
|
+
display: "flex",
|
|
278
|
+
justifyContent: "center",
|
|
279
|
+
alignItems: "center",
|
|
280
|
+
textAlign: "center",
|
|
281
|
+
fontSize: px(14),
|
|
282
|
+
paddingLeft: px(2),
|
|
283
|
+
paddingRight: px(2),
|
|
284
|
+
gap: px(2),
|
|
285
|
+
...style
|
|
286
|
+
},
|
|
287
|
+
children: [
|
|
288
|
+
unique && /* @__PURE__ */ jsx3(thronesIcon_default, { name: "unique" }),
|
|
289
|
+
/* @__PURE__ */ jsx3("span", { style: { display: "flex", alignItems: "center", justifyContent: "center" }, children: name })
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
});
|
|
294
|
+
var Faction = memo(({ children: faction, className, style }) => {
|
|
295
|
+
return /* @__PURE__ */ jsx3(
|
|
296
|
+
"div",
|
|
297
|
+
{
|
|
298
|
+
className,
|
|
299
|
+
style: {
|
|
300
|
+
display: "flex",
|
|
301
|
+
alignItems: "center",
|
|
302
|
+
justifyContent: "center",
|
|
303
|
+
boxSizing: "border-box",
|
|
304
|
+
borderColor: "black",
|
|
305
|
+
width: px(35),
|
|
306
|
+
height: px(35),
|
|
307
|
+
fontSize: px(22),
|
|
308
|
+
borderWidth: px(2),
|
|
309
|
+
...style
|
|
310
|
+
},
|
|
311
|
+
children: faction && /* @__PURE__ */ jsx3(thronesIcon_default, { name: faction })
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
});
|
|
315
|
+
var Traits = memo(({ children: traits = [], className, style }) => {
|
|
316
|
+
return /* @__PURE__ */ jsx3(
|
|
317
|
+
"div",
|
|
318
|
+
{
|
|
319
|
+
className,
|
|
320
|
+
style: {
|
|
321
|
+
fontStyle: "italic",
|
|
322
|
+
fontWeight: "700",
|
|
323
|
+
textAlign: "center",
|
|
324
|
+
height: px(16),
|
|
325
|
+
fontSize: px(12),
|
|
326
|
+
...style
|
|
327
|
+
},
|
|
328
|
+
children: traits.map((trait) => `${trait}.`).join(" ")
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
});
|
|
332
|
+
var TextBox = memo(({ children, className, style }) => {
|
|
333
|
+
return /* @__PURE__ */ jsx3("div", { className, style: {
|
|
334
|
+
display: "flex",
|
|
335
|
+
flexDirection: "column",
|
|
336
|
+
fontFamily: "Crimson Text, serif",
|
|
337
|
+
fontSize: px(12),
|
|
338
|
+
lineHeight: 1.1,
|
|
339
|
+
padding: `${px(5)} ${px(10)}`,
|
|
340
|
+
...style
|
|
341
|
+
}, children });
|
|
342
|
+
});
|
|
343
|
+
var Ability = memo(({ children: text, className, style }) => {
|
|
344
|
+
const convertToHtml = (htmlString) => {
|
|
345
|
+
const raw = htmlString.replace(/(?<=\n?)([^\n]+)(?=\n?)/g, "<p>$1</p>").replace(/\[([^\]]+)\]/g, '<icon name="$1"></icon>').replace(/<p>((?:\s*[+-]\d+ (?:Income|Initiative|Claim|Reserve)\.?\s*)+)<\/p>/gi, "<plotModifiers>$1</plotModifiers>").replace(/\s*([+-])(\d+) (Income|Initiative|Claim|Reserve)\.?\s*/gi, (_, modifier, value, plotStat) => `<plotModifier name="${plotStat.toLowerCase()}" modifier="${modifier}">${value}</plotModifier>`).replace(/((?:<p>-.*<\/p>\s*)+)/g, "<ul>$1</ul>").replace(/<p>-\s*(.*?)<\/p>/g, "<li>$1</li>").replace(/\n/g, "");
|
|
346
|
+
const parser = new DOMParser();
|
|
347
|
+
const body = parser.parseFromString(raw, "text/html").body;
|
|
348
|
+
const transformNode = (node, key) => {
|
|
349
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
350
|
+
return node.textContent;
|
|
351
|
+
}
|
|
352
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
353
|
+
const el = node;
|
|
354
|
+
const children = Array.from(el.childNodes).map((child, i) => transformNode(child, i));
|
|
355
|
+
switch (el.tagName.toLowerCase()) {
|
|
356
|
+
case "p":
|
|
357
|
+
return /* @__PURE__ */ jsx3("span", { children }, key);
|
|
358
|
+
case "b":
|
|
359
|
+
return /* @__PURE__ */ jsx3("b", { style: { fontWeight: "700" }, children }, key);
|
|
360
|
+
case "i":
|
|
361
|
+
return /* @__PURE__ */ jsx3("i", { style: { fontStyle: "italic", fontWeight: "700" }, children }, key);
|
|
362
|
+
case "ul":
|
|
363
|
+
return /* @__PURE__ */ jsx3("ul", { style: { listStyleType: "disc", marginBlockStart: em(0.25), marginBlockEnd: em(0.25), paddingInlineStart: em(2) }, children }, key);
|
|
364
|
+
case "li":
|
|
365
|
+
return /* @__PURE__ */ jsx3("li", { style: { paddingTop: em(0.1), paddingBottom: em(0.1) }, children }, key);
|
|
366
|
+
case "icon":
|
|
367
|
+
return /* @__PURE__ */ jsx3(thronesIcon_default, { name: el.getAttribute("name") }, key);
|
|
368
|
+
case "plotmodifiers":
|
|
369
|
+
return /* @__PURE__ */ jsx3("div", { style: { display: "flex", flexGrow: 1, justifyContent: "center", alignItems: "center", gap: em(0.25) }, children }, key);
|
|
370
|
+
case "plotmodifier":
|
|
371
|
+
return /* @__PURE__ */ jsx3(PlotModifier, { type: el.getAttribute("name"), modifier: el.getAttribute("modifier"), inline: true, children: parseInt(children[0]) }, key);
|
|
372
|
+
default:
|
|
373
|
+
return /* @__PURE__ */ jsx3("span", { children }, key);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return null;
|
|
377
|
+
};
|
|
378
|
+
return body ? Array.from(body.childNodes).map((node, i) => transformNode(node, i)) : [];
|
|
379
|
+
};
|
|
380
|
+
return /* @__PURE__ */ jsx3("div", { className, style: { display: "flex", flexDirection: "column", flexGrow: 1, gap: em(0.25), ...style }, children: text && convertToHtml(text) });
|
|
381
|
+
});
|
|
382
|
+
var Designer = memo(({ children: designer, className, style }) => {
|
|
383
|
+
return designer && /* @__PURE__ */ jsx3("div", { className, style: { flexGrow: 1, fontWeight: "700", fontSize: px(11), paddingTop: em(0.5), ...style }, children: designer });
|
|
384
|
+
});
|
|
385
|
+
var PlotModifier = memo(({ className, style, type, modifier, children: value }) => {
|
|
386
|
+
const actualValue = `${modifier}${value}`;
|
|
387
|
+
return value && /* @__PURE__ */ jsx3(PlotStat, { className, style, type, children: actualValue });
|
|
388
|
+
});
|
|
389
|
+
var PlotStat = memo(({ className, style, type, children: value }) => {
|
|
390
|
+
const getClipPath = () => {
|
|
391
|
+
switch (type) {
|
|
392
|
+
case "income":
|
|
393
|
+
return "circle(50%)";
|
|
394
|
+
case "initiative":
|
|
395
|
+
return "polygon(50% 0, 100% 50%, 50% 100%, 0 50%)";
|
|
396
|
+
case "claim":
|
|
397
|
+
return "polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%)";
|
|
398
|
+
case "reserve":
|
|
399
|
+
return "polygon(20% 0%, 80% 0%, 100% 20%, 100% 80%, 80% 100%, 20% 100%, 0% 80%, 0% 20%)";
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const clipPath = getClipPath();
|
|
403
|
+
return /* @__PURE__ */ jsx3(
|
|
404
|
+
autoSize_default,
|
|
405
|
+
{
|
|
406
|
+
height: 30,
|
|
407
|
+
className,
|
|
408
|
+
style: {
|
|
409
|
+
backgroundColor: thronesColors[type],
|
|
410
|
+
position: "relative",
|
|
411
|
+
textAlign: "center",
|
|
412
|
+
fontFamily: "Open sans, sans-serif",
|
|
413
|
+
width: px(30),
|
|
414
|
+
lineHeight: 1.35,
|
|
415
|
+
padding: em(0.15),
|
|
416
|
+
fontSize: px(18),
|
|
417
|
+
clipPath,
|
|
418
|
+
...style
|
|
419
|
+
},
|
|
420
|
+
children: value
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
});
|
|
424
|
+
var DeckLimit = memo(({ type, alignment = "left", children: limit, className, style }) => {
|
|
425
|
+
if (!type || limit === DefaultDeckLimit[type]) {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
return /* @__PURE__ */ jsx3(
|
|
429
|
+
"div",
|
|
430
|
+
{
|
|
431
|
+
className,
|
|
432
|
+
style: {
|
|
433
|
+
textAlign: "center",
|
|
434
|
+
...alignment === "left" && { rotate: "180deg" },
|
|
435
|
+
fontSize: px(8),
|
|
436
|
+
padding: px(5),
|
|
437
|
+
writingMode: "vertical-rl",
|
|
438
|
+
...style
|
|
439
|
+
},
|
|
440
|
+
children: limit && `Deck Limit: ${limit}`
|
|
441
|
+
}
|
|
442
|
+
);
|
|
443
|
+
});
|
|
444
|
+
var Watermark = memo(({ children: watermark, className, style }) => {
|
|
445
|
+
return /* @__PURE__ */ jsxs(
|
|
446
|
+
"div",
|
|
447
|
+
{
|
|
448
|
+
className,
|
|
449
|
+
style: {
|
|
450
|
+
display: "flex",
|
|
451
|
+
flexDirection: "column",
|
|
452
|
+
flexGrow: 1,
|
|
453
|
+
justifyContent: "center",
|
|
454
|
+
alignItems: "center",
|
|
455
|
+
textAlign: "center",
|
|
456
|
+
color: "#e5e7eb",
|
|
457
|
+
fontWeight: "700",
|
|
458
|
+
fontSize: px(14),
|
|
459
|
+
...style
|
|
460
|
+
},
|
|
461
|
+
children: [
|
|
462
|
+
/* @__PURE__ */ jsx3("span", { children: watermark?.top }),
|
|
463
|
+
/* @__PURE__ */ jsx3("span", { style: { fontSize: px(36), lineHeight: 1 }, children: watermark?.middle }),
|
|
464
|
+
/* @__PURE__ */ jsx3("span", { children: watermark?.bottom })
|
|
465
|
+
]
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// src/cardtypes/character.tsx
|
|
471
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
472
|
+
var Character = ({ card, scale, orientation, rounded, className, style, ...props }) => {
|
|
473
|
+
return /* @__PURE__ */ jsxs2(Card, { scale, card, orientation, rounded, className, styles: { inner: { display: "flex", flexDirection: "column" } }, style, ...props, children: [
|
|
474
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexGrow: 1 }, children: [
|
|
475
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", position: "relative", flexDirection: "column", width: px(35) }, children: [
|
|
476
|
+
/* @__PURE__ */ jsx4(Cost, { children: card.cost }),
|
|
477
|
+
/* @__PURE__ */ jsx4(Type, { children: "Character" }),
|
|
478
|
+
/* @__PURE__ */ jsx4(ChallengeIcons, { children: Object.entries(card.icons || {}).filter(([, value]) => value).map(([icon]) => icon) })
|
|
479
|
+
] }),
|
|
480
|
+
/* @__PURE__ */ jsx4(Watermark, { children: card.watermark }),
|
|
481
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", justifyContent: "flex-end" }, children: [
|
|
482
|
+
/* @__PURE__ */ jsx4(DeckLimit, { type: card.type, style: { flexGrow: 1 }, alignment: "right", children: card.deckLimit }),
|
|
483
|
+
/* @__PURE__ */ jsx4(Loyalty, { children: card.loyal })
|
|
484
|
+
] })
|
|
485
|
+
] }),
|
|
486
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex" }, children: [
|
|
487
|
+
/* @__PURE__ */ jsx4(Strength, { children: card.strength }),
|
|
488
|
+
/* @__PURE__ */ jsx4(Name, { unique: card.unique, style: {
|
|
489
|
+
alignSelf: "flex-end",
|
|
490
|
+
flexGrow: 1,
|
|
491
|
+
borderColor: "black",
|
|
492
|
+
fontSize: px(14),
|
|
493
|
+
lineHeight: "1.4",
|
|
494
|
+
display: "flex",
|
|
495
|
+
alignItems: "center",
|
|
496
|
+
justifyContent: "center",
|
|
497
|
+
height: px(30),
|
|
498
|
+
borderTopWidth: px(2),
|
|
499
|
+
borderBottomWidth: px(2)
|
|
500
|
+
}, children: card.name }),
|
|
501
|
+
/* @__PURE__ */ jsx4(Faction, { children: card.faction })
|
|
502
|
+
] }),
|
|
503
|
+
/* @__PURE__ */ jsxs2(TextBox, { children: [
|
|
504
|
+
/* @__PURE__ */ jsx4(Traits, { children: card.traits }),
|
|
505
|
+
/* @__PURE__ */ jsxs2(autoSize_default, { height: 95, style: { display: "flex", flexDirection: "column" }, children: [
|
|
506
|
+
/* @__PURE__ */ jsx4(Ability, { children: card.text }),
|
|
507
|
+
/* @__PURE__ */ jsx4(Designer, { children: card.designer })
|
|
508
|
+
] })
|
|
509
|
+
] })
|
|
510
|
+
] });
|
|
511
|
+
};
|
|
512
|
+
var character_default = Character;
|
|
513
|
+
|
|
514
|
+
// src/cardtypes/location.tsx
|
|
515
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
516
|
+
var Location = ({ card, scale, orientation, rounded, className, style, ...props }) => {
|
|
517
|
+
return /* @__PURE__ */ jsxs3(Card, { scale, card, orientation, rounded, className, styles: { inner: { display: "flex", flexDirection: "row" } }, style, ...props, children: [
|
|
518
|
+
/* @__PURE__ */ jsxs3("div", { style: { position: "relative", display: "flex", flexDirection: "column", width: px(35) }, children: [
|
|
519
|
+
/* @__PURE__ */ jsx5(Cost, { children: card.cost }),
|
|
520
|
+
/* @__PURE__ */ jsx5(Type, { children: "Location" }),
|
|
521
|
+
/* @__PURE__ */ jsx5(Name, { unique: card.unique, height: 150, style: {
|
|
522
|
+
width: px(35),
|
|
523
|
+
borderBottomWidth: px(2),
|
|
524
|
+
borderLeftWidth: px(2),
|
|
525
|
+
borderRightWidth: px(2),
|
|
526
|
+
borderStyle: "solid",
|
|
527
|
+
borderColor: "black",
|
|
528
|
+
rotate: "180deg",
|
|
529
|
+
paddingTop: px(5),
|
|
530
|
+
paddingBottom: px(5),
|
|
531
|
+
writingMode: "vertical-lr"
|
|
532
|
+
}, children: card.name }),
|
|
533
|
+
/* @__PURE__ */ jsx5(Faction, { children: card.faction }),
|
|
534
|
+
/* @__PURE__ */ jsx5(Loyalty, { children: card.loyal })
|
|
535
|
+
] }),
|
|
536
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", flexGrow: 1, justifyContent: "space-between" }, children: [
|
|
537
|
+
/* @__PURE__ */ jsxs3("div", { style: { position: "relative", display: "flex", flexDirection: "column", flexGrow: 1 }, children: [
|
|
538
|
+
/* @__PURE__ */ jsx5(DeckLimit, { type: card.type, style: { position: "absolute", alignSelf: "self-end", height: "100%" }, alignment: "right", children: card.deckLimit }),
|
|
539
|
+
/* @__PURE__ */ jsx5(Watermark, { children: card.watermark })
|
|
540
|
+
] }),
|
|
541
|
+
/* @__PURE__ */ jsxs3(TextBox, { children: [
|
|
542
|
+
/* @__PURE__ */ jsx5(Traits, { children: card.traits }),
|
|
543
|
+
/* @__PURE__ */ jsxs3(autoSize_default, { height: 130, style: { display: "flex", flexDirection: "column" }, children: [
|
|
544
|
+
/* @__PURE__ */ jsx5(Ability, { children: card.text }),
|
|
545
|
+
/* @__PURE__ */ jsx5(Designer, { children: card.designer })
|
|
546
|
+
] })
|
|
547
|
+
] })
|
|
548
|
+
] })
|
|
549
|
+
] });
|
|
550
|
+
};
|
|
551
|
+
var location_default = Location;
|
|
552
|
+
|
|
553
|
+
// src/cardtypes/attachment.tsx
|
|
554
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
555
|
+
var Attachment = ({ card, scale, orientation, rounded, className, style, ...props }) => {
|
|
556
|
+
return /* @__PURE__ */ jsxs4(Card, { scale, card, orientation, rounded, className, styles: { inner: { display: "flex", flexDirection: "column" } }, style, ...props, children: [
|
|
557
|
+
/* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexGrow: 1 }, children: [
|
|
558
|
+
/* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", width: px(35) }, children: [
|
|
559
|
+
/* @__PURE__ */ jsx6(Cost, { children: card.cost }),
|
|
560
|
+
/* @__PURE__ */ jsx6(Type, { children: "Attachment" }),
|
|
561
|
+
/* @__PURE__ */ jsx6(DeckLimit, { type: card.type, style: { flexGrow: 1 }, children: card.deckLimit })
|
|
562
|
+
] }),
|
|
563
|
+
/* @__PURE__ */ jsx6(Watermark, { style: { marginRight: px(35) }, children: card.watermark })
|
|
564
|
+
] }),
|
|
565
|
+
/* @__PURE__ */ jsxs4("div", { style: { position: "relative", display: "flex", flexDirection: "column", alignItems: "flex-end" }, children: [
|
|
566
|
+
/* @__PURE__ */ jsxs4(TextBox, { style: { width: "100%", paddingBottom: px(10) }, children: [
|
|
567
|
+
/* @__PURE__ */ jsx6(Traits, { children: card.traits }),
|
|
568
|
+
/* @__PURE__ */ jsxs4(autoSize_default, { height: 90, style: { display: "flex", flexDirection: "column" }, children: [
|
|
569
|
+
/* @__PURE__ */ jsx6(Ability, { children: card.text }),
|
|
570
|
+
/* @__PURE__ */ jsx6(Designer, { children: card.designer })
|
|
571
|
+
] })
|
|
572
|
+
] }),
|
|
573
|
+
/* @__PURE__ */ jsx6(Loyalty, { style: { position: "absolute", bottom: px(0) }, children: card.loyal })
|
|
574
|
+
] }),
|
|
575
|
+
/* @__PURE__ */ jsxs4("div", { style: { display: "flex" }, children: [
|
|
576
|
+
/* @__PURE__ */ jsx6(Name, { unique: card.unique, style: {
|
|
577
|
+
flexGrow: 1,
|
|
578
|
+
borderTopWidth: px(2),
|
|
579
|
+
borderBottomWidth: px(2),
|
|
580
|
+
borderLeftWidth: px(2)
|
|
581
|
+
}, children: card.name }),
|
|
582
|
+
/* @__PURE__ */ jsx6(Faction, { children: card.faction })
|
|
583
|
+
] })
|
|
584
|
+
] });
|
|
585
|
+
};
|
|
586
|
+
var attachment_default = Attachment;
|
|
587
|
+
|
|
588
|
+
// src/cardtypes/event.tsx
|
|
589
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
590
|
+
var Event = ({ card, scale, orientation, rounded, className, style, ...props }) => {
|
|
591
|
+
return /* @__PURE__ */ jsxs5(Card, { scale, card, orientation, rounded, className, styles: { inner: { display: "flex", flexDirection: "column" } }, style, ...props, children: [
|
|
592
|
+
/* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexGrow: 1 }, children: [
|
|
593
|
+
/* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexDirection: "column", width: px(35) }, children: [
|
|
594
|
+
/* @__PURE__ */ jsx7(Cost, { children: card.cost }),
|
|
595
|
+
/* @__PURE__ */ jsx7(Type, { children: "Event" }),
|
|
596
|
+
/* @__PURE__ */ jsx7(DeckLimit, { type: card.type, style: { flexGrow: 1 }, children: card.deckLimit })
|
|
597
|
+
] }),
|
|
598
|
+
/* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexDirection: "column", flexGrow: 1 }, children: [
|
|
599
|
+
/* @__PURE__ */ jsx7(Name, { style: {
|
|
600
|
+
borderTopWidth: px(2),
|
|
601
|
+
borderBottomWidth: px(2),
|
|
602
|
+
borderLeftWidth: px(2)
|
|
603
|
+
}, children: card.name }),
|
|
604
|
+
/* @__PURE__ */ jsx7(Watermark, { style: { flexGrow: 1 }, children: card.watermark })
|
|
605
|
+
] }),
|
|
606
|
+
/* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexDirection: "column", width: px(35) }, children: [
|
|
607
|
+
/* @__PURE__ */ jsx7(Faction, { children: card.faction }),
|
|
608
|
+
/* @__PURE__ */ jsx7(Loyalty, { children: card.loyal })
|
|
609
|
+
] })
|
|
610
|
+
] }),
|
|
611
|
+
/* @__PURE__ */ jsxs5(TextBox, { children: [
|
|
612
|
+
/* @__PURE__ */ jsx7(Traits, { children: card.traits }),
|
|
613
|
+
/* @__PURE__ */ jsxs5(autoSize_default, { height: 130, style: { display: "flex", flexDirection: "column" }, children: [
|
|
614
|
+
/* @__PURE__ */ jsx7(Ability, { children: card.text }),
|
|
615
|
+
/* @__PURE__ */ jsx7(Designer, { children: card.designer })
|
|
616
|
+
] })
|
|
617
|
+
] })
|
|
618
|
+
] });
|
|
619
|
+
};
|
|
620
|
+
var event_default = Event;
|
|
621
|
+
|
|
622
|
+
// src/cardtypes/plot.tsx
|
|
623
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
624
|
+
var Plot = ({ card, scale, orientation, rounded, className, style, ...props }) => {
|
|
625
|
+
return /* @__PURE__ */ jsxs6(Card, { scale, card, orientation, rounded, className, style, ...props, children: [
|
|
626
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "row", alignItems: "center", height: px(40) }, children: [
|
|
627
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: px(4), width: px(110) }, children: [
|
|
628
|
+
/* @__PURE__ */ jsx8(PlotStat, { type: "income", children: card.plotStats?.income }),
|
|
629
|
+
/* @__PURE__ */ jsx8(PlotStat, { type: "initiative", children: card.plotStats?.initiative }),
|
|
630
|
+
/* @__PURE__ */ jsx8(PlotStat, { type: "claim", children: card.plotStats?.claim })
|
|
631
|
+
] }),
|
|
632
|
+
/* @__PURE__ */ jsx8(Name, { style: { display: "flex", flexGrow: 1, fontSize: px(18) }, children: card.name })
|
|
633
|
+
] }),
|
|
634
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexGrow: 1 }, children: [
|
|
635
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", width: px(35) }, children: [
|
|
636
|
+
/* @__PURE__ */ jsx8(Type, { children: "Plot" }),
|
|
637
|
+
/* @__PURE__ */ jsx8(DeckLimit, { type: card.type, style: { flexGrow: 1 }, children: card.deckLimit })
|
|
638
|
+
] }),
|
|
639
|
+
/* @__PURE__ */ jsx8(Watermark, { children: card.watermark }),
|
|
640
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", width: px(35), paddingRight: px(5) }, children: [
|
|
641
|
+
/* @__PURE__ */ jsx8(Faction, { style: { borderColor: "transparent" }, children: card.faction }),
|
|
642
|
+
/* @__PURE__ */ jsx8(Loyalty, { children: card.loyal }),
|
|
643
|
+
/* @__PURE__ */ jsx8(PlotStat, { type: "reserve", children: card.plotStats?.reserve })
|
|
644
|
+
] })
|
|
645
|
+
] }),
|
|
646
|
+
/* @__PURE__ */ jsxs6(TextBox, { style: { paddingBottom: px(0) }, children: [
|
|
647
|
+
/* @__PURE__ */ jsx8(Traits, { children: card.traits }),
|
|
648
|
+
/* @__PURE__ */ jsxs6(autoSize_default, { height: 60, style: { display: "flex", flexDirection: "column" }, children: [
|
|
649
|
+
/* @__PURE__ */ jsx8(Ability, { children: card.text }),
|
|
650
|
+
/* @__PURE__ */ jsx8(Designer, { children: card.designer })
|
|
651
|
+
] })
|
|
652
|
+
] })
|
|
653
|
+
] });
|
|
654
|
+
};
|
|
655
|
+
var plot_default = Plot;
|
|
656
|
+
|
|
657
|
+
// src/cardtypes/agenda.tsx
|
|
658
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
659
|
+
var Agenda = ({ card, scale, orientation, rounded, className, style, ...props }) => {
|
|
660
|
+
return /* @__PURE__ */ jsxs7(Card, { scale, card, orientation, rounded, className, styles: { inner: { display: "flex", flexDirection: "column" } }, style, ...props, children: [
|
|
661
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
662
|
+
/* @__PURE__ */ jsx9(Name, { children: card.name }),
|
|
663
|
+
/* @__PURE__ */ jsx9(Type, { style: { display: "flex", alignItems: "center", justifyContent: "center" }, children: "Agenda" })
|
|
664
|
+
] }),
|
|
665
|
+
/* @__PURE__ */ jsxs7("div", { style: { flexGrow: 1, position: "relative", display: "flex" }, children: [
|
|
666
|
+
/* @__PURE__ */ jsx9(DeckLimit, { type: card.type, style: { position: "absolute", height: "100%" }, children: card.deckLimit }),
|
|
667
|
+
/* @__PURE__ */ jsx9(Watermark, { children: card.watermark })
|
|
668
|
+
] }),
|
|
669
|
+
/* @__PURE__ */ jsxs7(TextBox, { children: [
|
|
670
|
+
/* @__PURE__ */ jsx9(Traits, { children: card.traits }),
|
|
671
|
+
/* @__PURE__ */ jsxs7(autoSize_default, { height: 130, style: { display: "flex", flexDirection: "column" }, children: [
|
|
672
|
+
/* @__PURE__ */ jsx9(Ability, { children: card.text }),
|
|
673
|
+
/* @__PURE__ */ jsx9(Designer, { children: card.designer })
|
|
674
|
+
] })
|
|
675
|
+
] })
|
|
676
|
+
] });
|
|
677
|
+
};
|
|
678
|
+
var agenda_default = Agenda;
|
|
679
|
+
|
|
680
|
+
// src/index.tsx
|
|
681
|
+
import { useMemo as useMemo2 } from "react";
|
|
682
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
683
|
+
var CardPreview = ({ card, scale, orientation, rounded, className, style, ...props }) => {
|
|
684
|
+
const CardComponent = useMemo2(() => {
|
|
685
|
+
switch (card.type) {
|
|
686
|
+
case "character":
|
|
687
|
+
return character_default;
|
|
688
|
+
case "location":
|
|
689
|
+
return location_default;
|
|
690
|
+
case "attachment":
|
|
691
|
+
return attachment_default;
|
|
692
|
+
case "event":
|
|
693
|
+
return event_default;
|
|
694
|
+
case "plot":
|
|
695
|
+
return plot_default;
|
|
696
|
+
case "agenda":
|
|
697
|
+
return agenda_default;
|
|
698
|
+
default:
|
|
699
|
+
return Card;
|
|
700
|
+
}
|
|
701
|
+
}, [card.type]);
|
|
702
|
+
return /* @__PURE__ */ jsx10(CardComponent, { card, scale, orientation, rounded, className, style, ...props });
|
|
703
|
+
};
|
|
704
|
+
var index_default = CardPreview;
|
|
705
|
+
export {
|
|
706
|
+
index_default as default
|
|
707
|
+
};
|