@spawnite/ui 0.1.0-beta.16

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.
@@ -0,0 +1,425 @@
1
+ import { a as LogomarkProps, i as Logomark, n as WordmarkProps, r as platformName, t as Wordmark } from "./public-DMivBp7u.js";
2
+ import { a as Slider, c as Select, d as NumberField, f as NumberFieldProps, i as TextFieldProps, l as SelectOption, n as ToggleProps, o as SliderProps, r as TextField, s as SliderStyle, t as Toggle, u as SelectProps } from "./public-CGV4pFD1.js";
3
+ import { Tooltip, TooltipProps } from "./tooltip.js";
4
+ import { press, springs, tap } from "./motion.js";
5
+ import { CSSProperties, ElementType, HTMLAttributes, ReactNode, Ref } from "react";
6
+ import { LucideIcon } from "lucide-react";
7
+ import { Vector2 } from "three";
8
+ import { HTMLMotionProps } from "motion/react";
9
+ import { QualityLevel } from "@spawnite/schema";
10
+ /** A cooldown a slot shows: the engine's `Cooldown` has this shape.
11
+ * @category UI */
12
+ interface ActionCooldown {
13
+ /** Seconds it runs for, start to end. */
14
+ seconds: number;
15
+ /** Seconds left of them. */
16
+ left: number;
17
+ }
18
+ /** The outline of every button on a bar.
19
+ * @category UI */
20
+ export declare enum ActionBarShape {
21
+ Circle = "circle",
22
+ Square = "square"
23
+ }
24
+ /** @category UI */
25
+ interface ActionSlot {
26
+ /** What `onPress` names the slot by. */
27
+ id: string;
28
+ /** The accessible name, such as "Bolt". */
29
+ label: string;
30
+ /** The key that presses it, as the badge shows it: "1", "E". The game
31
+ * binds the key; the bar only shows it, and only where the pointer is
32
+ * fine: a phone has no key, so it shows no badge. */
33
+ hotkey?: string;
34
+ /** One Icon. */
35
+ icon: ReactNode;
36
+ /** The cooldown it runs. Left out, the slot takes a press. */
37
+ cooldown?: ActionCooldown;
38
+ /** The cast winding up, in the cooldown's shape: the rim fills over
39
+ * it and every other slot dims. The engine's `CastingTrait` gives `left`
40
+ * and the ability's `castSeconds` gives `seconds`. */
41
+ casting?: ActionCooldown;
42
+ /** Whether the target stands beyond the ability's range: the icon
43
+ * tints red. The slot still takes a press. */
44
+ outOfRange?: boolean;
45
+ /** The cost she cannot pay, such as `25` for 25 mana: the icon tints
46
+ * blue and the button shows it. Left out while she can pay. The slot
47
+ * still takes a press, and the rules say why they refuse it. */
48
+ noResource?: number;
49
+ /** Draws the slot pressed, as a pointer's press does. Set it while the
50
+ * slot's hotkey is held, so a key press shows on the button. */
51
+ pressed?: boolean;
52
+ /** Takes no press and draws nothing for it: dim, with no rim, no
53
+ * number and no pop. For a lock that is not the slot's own, such as
54
+ * the global cooldown another ability started, so the one button the
55
+ * player pressed is the one that moves. A `cooldown` shows instead. */
56
+ locked?: boolean;
57
+ }
58
+ /** @category UI */
59
+ interface ActionBarProps {
60
+ /** One to four abilities, in key order. A fifth is left out: the arc
61
+ * holds four. */
62
+ slots: readonly ActionSlot[];
63
+ /** The ability on the arc's centre, drawn larger than the fan. */
64
+ primary?: ActionSlot;
65
+ /** The buttons' outline. Left out, a circle. */
66
+ shape?: ActionBarShape;
67
+ /** Called once for each press, with the slot's `id`. */
68
+ onPress: (id: string) => void;
69
+ /** An override that shows in the diff. */
70
+ className?: string;
71
+ }
72
+ /** @category UI */
73
+ export declare function ActionBar({ slots, primary, shape, onPress, className }: ActionBarProps): import("react").JSX.Element;
74
+ /** @inline */
75
+ interface BarProps {
76
+ /** The accessible name, such as "Health". */
77
+ label: string;
78
+ /** The current value. The bar clamps it between 0 and `maximum`. */
79
+ value: number;
80
+ /** The full value. It must be positive. */
81
+ maximum: number;
82
+ /** A CSS colour the fill draws in, such as a resource's. Left out, it
83
+ * is the health tone, which a game restyles through its token.
84
+ * @defaultValue the `--color-health-fill` token */
85
+ color?: string;
86
+ /** How much of the maximum is held back past `value`, such as the mana
87
+ * a cast has reserved: drawn after the fill as a lighter band of its
88
+ * colour.
89
+ * @defaultValue `0` */
90
+ reserved?: number;
91
+ /** Reads the value out beside the bar, `12 / 40`, tabular and small.
92
+ * @defaultValue `false` */
93
+ showValue?: boolean;
94
+ /** The size, and any other override on the track. Left out, the bar
95
+ * is `h-2 w-40`.
96
+ * @defaultValue `"h-2 w-40"` */
97
+ className?: string;
98
+ /** An override per part, over `className` for the track. */
99
+ classNames?: BarClassNames;
100
+ }
101
+ /** The parts of a Bar a game restyles apart.
102
+ * @category UI */
103
+ interface BarClassNames {
104
+ /** The row around the track and the value, with `showValue`. */
105
+ root?: string;
106
+ track?: string;
107
+ fill?: string;
108
+ /** The lighter band `reserved` draws. */
109
+ reserved?: string;
110
+ /** The `12 / 40` beside the track, with `showValue`. */
111
+ value?: string;
112
+ }
113
+ /** @category UI */
114
+ export declare function Bar({ label, value, maximum, color, reserved, showValue, className, classNames }: BarProps): import("react").JSX.Element;
115
+ /** The looks a Button comes in. Glass is the default, over the world;
116
+ * the other two draw on the menu tokens, so a game that sets its accent
117
+ * sets them with it, as Godot's theme overrides reach every button.
118
+ * @category UI */
119
+ export declare enum ButtonVariant {
120
+ /** Glass over the world: the default. */
121
+ Glass = "glass",
122
+ /** Filled with the menu accent, with its ink: the one action a screen
123
+ * leads with. */
124
+ Accent = "accent",
125
+ /** On the menu's pane: a step back or a lesser choice. */
126
+ Pane = "pane"
127
+ }
128
+ /** @inline */
129
+ interface ButtonProps {
130
+ /** The look. @defaultValue `ButtonVariant.Glass` */
131
+ variant?: ButtonVariant;
132
+ /** Off: dimmed, no press lands, and Tab passes it, as a browser's own
133
+ * disabled button. */
134
+ disabled?: boolean;
135
+ /** The accessible name, which a button of text takes from its text and
136
+ * a button of one icon needs spelled out. */
137
+ label?: string;
138
+ /** A toggle's state; off dims the button. Left out by a button that
139
+ * holds none: a press that jumps the sun is over when it lands, so
140
+ * there is nothing to report. */
141
+ pressed?: boolean;
142
+ /** The press. The component does not know what the state becomes: the
143
+ * caller owns it, and `pressed` is how it comes back. */
144
+ onPress: () => void;
145
+ /** The key that presses it too, which the caller binds, written as
146
+ * `aria-keyshortcuts` writes one, such as `"R"` or `"Shift+E"`. A
147
+ * screen reader announces it, and the engine's development warning
148
+ * knows a player reaches the button while the cursor is captured. */
149
+ keyShortcuts?: string;
150
+ /** One icon, or a word or two. */
151
+ children: ReactNode;
152
+ /** An override that shows in the diff. */
153
+ className?: string;
154
+ /** An override per part, over `className` for the root. */
155
+ classNames?: ButtonClassNames;
156
+ /** A style that comes from data, such as an item's rarity colour or a
157
+ * place on a grid. A look that is the same every time is a class. */
158
+ style?: CSSProperties;
159
+ }
160
+ /** The parts of a Button a game restyles apart.
161
+ * @category UI */
162
+ interface ButtonClassNames {
163
+ root?: string;
164
+ /** The span around the icon or the word. */
165
+ icon?: string;
166
+ }
167
+ /** @category UI */
168
+ export declare function Button({ variant, disabled, label, pressed, onPress, keyShortcuts, children, className, classNames, style, ref }: ButtonProps & {
169
+ ref?: Ref<HTMLButtonElement>;
170
+ }): import("react").JSX.Element;
171
+ interface CompletionRingProps {
172
+ className?: string;
173
+ }
174
+ export declare function CompletionRing({ className }: CompletionRingProps): import("react").JSX.Element;
175
+ declare const levels: {
176
+ 1: string;
177
+ 2: string;
178
+ 3: string;
179
+ 4: string;
180
+ };
181
+ /** @inline */
182
+ interface HeadingProps {
183
+ /** The outline level: `h1` to `h4`, each with its own size and weight. */
184
+ level: keyof typeof levels;
185
+ /** An override that shows in the diff. */
186
+ className?: string;
187
+ children: ReactNode;
188
+ }
189
+ /** A title drawn over the world, with Text's white and dark edge.
190
+ * @category UI */
191
+ export declare function Heading({ level, className, children }: HeadingProps): import("react").JSX.Element;
192
+ /** The icons a game names without importing anything: a HUD's usual set.
193
+ * @category UI */
194
+ type IconName = "arrow-big-down" | "arrow-big-left" | "arrow-big-right" | "arrow-big-up" | "check" | "coins" | "crosshair" | "crown" | "droplet" | "flag" | "flame" | "gem" | "gift" | "heart" | "house" | "key" | "lock" | "map" | "menu" | "moon" | "mic" | "mic-off" | "pause" | "play" | "rotate-ccw" | "settings" | "shield" | "skull" | "snowflake" | "star" | "swords" | "target" | "timer" | "trophy" | "user" | "users" | "volume-2" | "volume-x" | "x" | "zap";
195
+ /** @category UI */
196
+ interface IconProps {
197
+ /** An icon from the set by its lucide name, such as `"coins"` or
198
+ * `"heart"`, where a typo does not compile. Or any other lucide icon,
199
+ * imported from `lucide-react` by the game itself. */
200
+ name: IconName | LucideIcon;
201
+ /** The accessible name. Left out, the icon is decoration beside text
202
+ * that already says what it means, and a screen reader skips it. */
203
+ label?: string;
204
+ /** The size, such as `"size-8"`, and any other override. */
205
+ className?: string;
206
+ }
207
+ /** @category UI */
208
+ export declare function Icon({ name, label, className }: IconProps): import("react").JSX.Element;
209
+ /** @inline */
210
+ interface ImageProps {
211
+ /** The picture's address, as an import of the file or a path the game
212
+ * serves gives it. */
213
+ src: string;
214
+ /** What the picture shows, for a screen reader; empty for a picture
215
+ * that only decorates, which a screen reader then passes over. */
216
+ label: string;
217
+ /** Its size and fit, such as `size-10 object-contain`, and
218
+ * `[image-rendering:pixelated]` for pixel art. */
219
+ className?: string;
220
+ /** A style that comes from data, such as a place on a grid. */
221
+ style?: CSSProperties;
222
+ }
223
+ /** A picture from a file, such as an item's sprite. An icon from the
224
+ * engine's set is an `Icon`.
225
+ * @category UI */
226
+ export declare function Image({ src, label, className, style }: ImageProps): import("react").JSX.Element;
227
+ /** @category UI */
228
+ interface JoystickProps {
229
+ /** Where the thumb is, on the unit disc: `x` right, `y` up the screen.
230
+ * `(0, 0)` while nothing holds it, and on release. A fresh vector each
231
+ * time, so the caller may keep one. */
232
+ onSteer: (direction: Vector2) => void;
233
+ /** How far past the drawn ring a thumb still catches the stick, in the
234
+ * ring's own units. The ring grows to fill it on the grab, which is
235
+ * what tells the player what they caught.
236
+ * @defaultValue `8` */
237
+ grabMargin?: number;
238
+ /** Placement and visibility, such as showing it only on touch
239
+ * screens. */
240
+ className?: string;
241
+ }
242
+ /** @category UI */
243
+ export declare function Joystick({ onSteer, grabMargin, className }: JoystickProps): import("react").JSX.Element;
244
+ interface LoadingRingProps {
245
+ /** How much has loaded, from 0 to 1. */
246
+ value: number;
247
+ className?: string;
248
+ }
249
+ export declare function LoadingRing({ value, className }: LoadingRingProps): import("react").JSX.Element;
250
+ interface MadeWithNoticeProps {
251
+ /** Where it sits, such as a fixed place on the loading screen. */
252
+ className?: string;
253
+ }
254
+ /** The licence's Required Notice on screen: one small line, "Made with
255
+ * Spawnite", whose name opens spawnite.com in a new tab.
256
+ * @category UI */
257
+ export declare function MadeWithNotice({ className }: MadeWithNoticeProps): import("react").JSX.Element;
258
+ /** The `palette` entry a ProgressBar's fill draws in. */
259
+ export declare enum ProgressBarVariant {
260
+ HealthFill = "healthFill",
261
+ LoadingBar = "loadingBar"
262
+ }
263
+ interface ProgressBarProps extends Omit<HTMLMotionProps<"div">, "children" | "color"> {
264
+ /** How full, from 0 to 1. */
265
+ value: number;
266
+ variant: ProgressBarVariant;
267
+ /** A CSS colour the fill draws in, in place of the variant's. */
268
+ color?: string;
269
+ /** Drawn over the fill, inside the track's clip. */
270
+ children?: ReactNode;
271
+ /** An override on the fill. */
272
+ fillClassName?: string;
273
+ }
274
+ export declare function ProgressBar({ value, variant, color, className, children, fillClassName, ...rest }: ProgressBarProps): import("react").JSX.Element;
275
+ interface QualityButtonProps {
276
+ level: QualityLevel;
277
+ /** Whether the player set a feature row apart from the level, which
278
+ * the button names Custom. */
279
+ custom?: boolean;
280
+ onPress: () => void;
281
+ }
282
+ export declare function QualityButton({ level, custom, onPress }: QualityButtonProps): import("react").JSX.Element;
283
+ /** @inline */
284
+ interface CounterProps {
285
+ /** The icon that says what the number is. */
286
+ icon: IconProps["name"];
287
+ /** The accessible name, such as "Coins". */
288
+ label: string;
289
+ value: number | string;
290
+ /** The size, the icon's and the number's together.
291
+ * @defaultValue `"base"` */
292
+ size?: keyof typeof sizes$1;
293
+ /** An override that shows in the diff, on the row. */
294
+ className?: string;
295
+ /** An override per part, over `className` for the row. */
296
+ classNames?: CounterClassNames;
297
+ }
298
+ /** The parts of a Counter a game restyles apart.
299
+ * @category UI */
300
+ interface CounterClassNames {
301
+ root?: string;
302
+ icon?: string;
303
+ value?: string;
304
+ }
305
+ declare const sizes$1: {
306
+ readonly sm: {
307
+ readonly icon: "size-4";
308
+ readonly text: "sm";
309
+ };
310
+ readonly base: {
311
+ readonly icon: "size-5";
312
+ readonly text: "base";
313
+ };
314
+ readonly lg: {
315
+ readonly icon: "size-7";
316
+ readonly text: "lg";
317
+ };
318
+ readonly xl: {
319
+ readonly icon: "size-8";
320
+ readonly text: "xl";
321
+ };
322
+ };
323
+ /** @category UI */
324
+ export declare function Counter({ icon, label, value, size, className, classNames }: CounterProps): import("react").JSX.Element;
325
+ /** @category UI */
326
+ interface TapProps {
327
+ /** The accessible name. A Tap shows an icon, not text. */
328
+ label: string;
329
+ /** Called once for each press. */
330
+ onTap: () => void;
331
+ /** Called as the finger or the button that pressed it lets go, slides
332
+ * off, or the browser takes the touch: what a held control, a sprint
333
+ * or a block, ends on. */
334
+ onRelease?: () => void;
335
+ /** One Icon. */
336
+ children: ReactNode;
337
+ /** An override that shows in the diff. */
338
+ className?: string;
339
+ }
340
+ /** @category UI */
341
+ export declare function Tap({ label, onTap, onRelease, children, className }: TapProps): import("react").JSX.Element;
342
+ /** What this puts on whichever element it is given. Naming it is what keeps
343
+ * `as` usable: an element type with no props to satisfy resolves every one of
344
+ * them to `never`, and no caller can then pass a class. */
345
+ type TextElementProps = Pick<HTMLAttributes<HTMLElement>, "aria-label" | "className" | "style" | "title" | "children">;
346
+ declare const sizes: {
347
+ xs: string;
348
+ sm: string;
349
+ base: string;
350
+ lg: string;
351
+ xl: string;
352
+ };
353
+ /** @inline */
354
+ interface TextProps {
355
+ /** The element to draw. Rows of named values are a list, one value is an
356
+ * output, and a span is the fallback for text that is only text. A
357
+ * wrapper of this component's own would be an element with nothing to
358
+ * say, so the caller's is the one that is drawn.
359
+ * @defaultValue `"span"` */
360
+ as?: ElementType<TextElementProps>;
361
+ /** The accessible name, where the element the caller chose takes one.
362
+ * Spelled as the attribute it becomes, so there is no second name for a
363
+ * caller to learn and none for this to quietly drop. */
364
+ "aria-label"?: string;
365
+ /** The font size, from Tailwind's scale. Small by default, the size of
366
+ * a readout over the world.
367
+ * @defaultValue `"sm"` */
368
+ size?: keyof typeof sizes;
369
+ /** Draws every digit the same width, so a number that counts does not
370
+ * shift the text beside it or the pane around it.
371
+ * @defaultValue `false` */
372
+ tabular?: boolean;
373
+ /** What the browser shows in a tooltip while the pointer rests on it,
374
+ * such as what a stat does. */
375
+ title?: string;
376
+ /** An override that shows in the diff. */
377
+ className?: string;
378
+ /** A style that comes from data, such as an item's rarity colour or a
379
+ * place on a grid. A look that is the same every time is a class. */
380
+ style?: CSSProperties;
381
+ children: ReactNode;
382
+ }
383
+ /** @category UI */
384
+ export declare function Text({ as, "aria-label": label, size, tabular, title, className, style, children }: TextProps): import("react").JSX.Element;
385
+ export declare const palette: {
386
+ readonly healthFill: "bg-health-fill";
387
+ readonly healthTrack: "bg-health-track";
388
+ readonly healthLoss: "bg-health-loss";
389
+ readonly loadingBackground: "bg-loading-background";
390
+ readonly loadingLabel: "text-loading-label";
391
+ readonly loadingIndicator: "text-loading-indicator";
392
+ readonly loadingBar: "bg-loading-bar";
393
+ readonly errorText: "text-neutral-200";
394
+ readonly stickRing: "border-stick-ring";
395
+ readonly stickKnob: "bg-stick-knob";
396
+ readonly stickKnobShadow: "shadow-black/25";
397
+ readonly glassSurface: "text-pane-ink bg-pane-surface bg-linear-to-b from-pane-sheen to-pane-sheen-end backdrop-blur-(--blur-pane) backdrop-saturate-[1.7] inset-shadow-[0_1px_0] inset-shadow-pane-edge/70";
398
+ readonly glassBorder: "border-pane-edge";
399
+ readonly glassIconEdge: "[filter:drop-shadow(0_0_1px_black)_drop-shadow(0_0_1px_black)]";
400
+ readonly glassChildIconEdge: "[&_svg]:[filter:drop-shadow(0_0_1px_black)_drop-shadow(0_0_1px_black)]";
401
+ readonly glassShadow: "shadow-pane-shadow";
402
+ readonly glassFocusRing: "ring-pane-ink";
403
+ readonly glassFocusRingOffset: "ring-offset-neutral-950";
404
+ readonly outlinedText: "text-white [text-shadow:1px_1px_0_black,-1px_1px_0_black,1px_-1px_0_black,-1px_-1px_0_black]";
405
+ readonly dangerText: "text-danger";
406
+ readonly fieldBox: "pointer-events-auto h-9 rounded-(--radius-field) border border-menu-edge bg-menu-raised px-2 text-(length:--text-field) text-menu-ink transition-colors hover:border-menu-muted/60 motion-reduce:transition-none disabled:cursor-not-allowed disabled:opacity-40";
407
+ readonly controlFocusRing: "outline-none focus-visible:ring-2 focus-visible:ring-white/90 focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-950";
408
+ };
409
+ interface PointerGripOptions {
410
+ /** `HTMLElement` rather than `Element`, because only its event map names
411
+ * the pointer events. */
412
+ host: HTMLElement;
413
+ /** Defaults to the global window; a test hands in its own. */
414
+ window?: Window;
415
+ /** A finger took the control. */
416
+ onGrab?: (event: PointerEvent) => void;
417
+ /** The gripping finger moved. */
418
+ onMove?: (event: PointerEvent) => void;
419
+ /** The grip ended, whichever way it ended. */
420
+ onRelease: () => void;
421
+ }
422
+ /** Binds the grip to `host`. Returns the unbind, which also lets go. */
423
+ export declare function gripPointer({ host, window, onGrab, onMove, onRelease }: PointerGripOptions): () => void;
424
+ export declare function trackPageHide(target: Window, hide: () => void): () => void;
425
+ export { type ActionBarProps, type ActionCooldown, type ActionSlot, type BarClassNames, type ButtonClassNames, type ButtonProps, type CounterClassNames, type IconName, type IconProps, type ImageProps, type JoystickProps, Logomark, type LogomarkProps, NumberField, type NumberFieldProps, type PointerGripOptions, Select, type SelectOption, type SelectProps, Slider, type SliderProps, type SliderStyle, type TapProps, TextField, type TextFieldProps, Toggle, type ToggleProps, Tooltip, type TooltipProps, Wordmark, type WordmarkProps, platformName, press, springs, tap };