@ntmats/hc-ui 0.4.0 → 0.6.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 +27 -14
- package/dist/index.d.ts +184 -101
- package/dist/index.js +206 -187
- package/dist/styles.css +151 -74
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { type ButtonHTMLAttributes, type Dispatch, type HTMLAttributes, type InputHTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode, type Ref, type SetStateAction } from 'react';
|
|
2
|
-
export type SurfaceTone = 'page' | 'main' | 'content' | 'elevated' | 'overlay' | 'card';
|
|
3
|
-
|
|
1
|
+
import { type ButtonHTMLAttributes, type Dispatch, type ForwardRefExoticComponent, type RefAttributes, type HTMLAttributes, type InputHTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode, type Ref, type SetStateAction } from 'react';
|
|
2
|
+
export type SurfaceTone = 'page' | 'main' | 'content' | 'elevated' | 'overlay' | 'card' | 'muted';
|
|
3
|
+
/** Elements a `Surface` may render as. */
|
|
4
|
+
export type SurfaceElement = 'div' | 'section' | 'article' | 'aside' | 'ul' | 'ol' | 'li';
|
|
5
|
+
export interface SurfaceProps extends HTMLAttributes<HTMLElement> {
|
|
4
6
|
tone?: SurfaceTone;
|
|
5
|
-
/** Corner radius of the rounded tones (`content`, `elevated`, `overlay`, `card`): 16, 20 or 24px.
|
|
6
|
-
* Defaults to `md` (16px), and to `lg` (20px) for `card`, as HCUI's `surface` mixin. */
|
|
7
|
+
/** Corner radius of the rounded tones (`content`, `elevated`, `overlay`, `card`, `muted`): 16, 20 or 24px.
|
|
8
|
+
* Defaults to `md` (16px), and to `lg` (20px) for `card` and `muted`, as HCUI's `surface` mixin. */
|
|
7
9
|
radius?: 'md' | 'lg' | 'xl';
|
|
10
|
+
/** Element to render: `div` (default), or `section`, `article`, `aside`, `ul`, `ol`, `li`
|
|
11
|
+
* (a list drawn as a card). Lists keep the browser's margin, padding and markers: reset them in the caller's class. */
|
|
12
|
+
as?: SurfaceElement;
|
|
8
13
|
}
|
|
9
14
|
/** Semantic color role only; placement, elevation and overlay behavior stay local. */
|
|
10
|
-
export declare function Surface({ tone, radius, className, ...props }: SurfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function Surface({ tone, radius, as: Element, className, ...props }: SurfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
export interface SegmentedOption<T extends string> {
|
|
12
17
|
value: T;
|
|
13
18
|
label: string;
|
|
@@ -31,12 +36,24 @@ export interface SegmentedControlProps<T extends string> extends Omit<HTMLAttrib
|
|
|
31
36
|
equalWidth?: boolean;
|
|
32
37
|
/** Fixed width of each option in px; implies `equalWidth`. */
|
|
33
38
|
optionWidth?: number;
|
|
39
|
+
/** Minimum width of each option in px (HCUI's 92px Coleções/Unidades toggle); a longer label still widens its option. */
|
|
40
|
+
optionMinWidth?: number;
|
|
34
41
|
}
|
|
35
42
|
/** Controlled, single-choice control with radio semantics and roving focus. */
|
|
36
|
-
export declare function SegmentedControl<T extends string>({ label, value, options, onChange, density, orientation, hideLabels, indicator, equalWidth, optionWidth, className, style, ...props }: SegmentedControlProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
37
|
-
export type ButtonVariant = 'secondary' | 'primary' | 'outline' | 'danger';
|
|
43
|
+
export declare function SegmentedControl<T extends string>({ label, value, options, onChange, density, orientation, hideLabels, indicator, equalWidth, optionWidth, optionMinWidth, className, style, ...props }: SegmentedControlProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export type ButtonVariant = 'secondary' | 'primary' | 'outline' | 'danger' | 'ghost';
|
|
38
45
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
46
|
+
/**
|
|
47
|
+
* `secondary` (default, muted fill), `primary`, `outline`, `danger` (filled) or `ghost`
|
|
48
|
+
* (no fill, only the hover and press veil). A popup trigger (`aria-haspopup`) that is open
|
|
49
|
+
* (`aria-expanded="true"`) draws a 1.5px ring in the text color, as `Chip` (not on `primary` and `danger`).
|
|
50
|
+
*/
|
|
39
51
|
variant?: ButtonVariant;
|
|
52
|
+
/**
|
|
53
|
+
* Text color of the unfilled variants (`secondary`, `outline`, `ghost`): `default` or `danger`
|
|
54
|
+
* (HCUI's "Fechar e descartar alterações": `variant="ghost" tone="danger"`). Ignored by `primary` and `danger`.
|
|
55
|
+
*/
|
|
56
|
+
tone?: 'default' | 'danger';
|
|
40
57
|
/** 36, 44 or 52px. */
|
|
41
58
|
size?: 'sm' | 'md' | 'lg';
|
|
42
59
|
/** Decorative icon before the label; pass it already sized (18px in HCUI). */
|
|
@@ -46,19 +63,26 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
46
63
|
fullWidth?: boolean;
|
|
47
64
|
/** Busy state: keeps focus and label, shows a spinner and ignores clicks. */
|
|
48
65
|
loading?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Opt-in: a long label wraps onto more lines (the button grows taller) instead of
|
|
68
|
+
* being cut with an ellipsis, which stays the default.
|
|
69
|
+
*/
|
|
70
|
+
wrap?: boolean;
|
|
49
71
|
}
|
|
50
72
|
/** Pill button. The caller supplies the label text and handles the action. */
|
|
51
|
-
export declare const Button:
|
|
73
|
+
export declare const Button: ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>;
|
|
52
74
|
export interface IconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'aria-label'> {
|
|
53
75
|
/** Accessible name and tooltip; required because the button has no text. */
|
|
54
76
|
label: string;
|
|
55
77
|
icon: ReactNode;
|
|
56
|
-
/** 36, 40 or 44px.
|
|
57
|
-
size?: 'sm' | 'md' | 'lg';
|
|
58
|
-
|
|
78
|
+
/** 28 (`xs`, dense toolbars and ⋯ triggers), 36, 40 or 44px. `xs` and `sm` keep a 44px touch target. */
|
|
79
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
80
|
+
/** Icon color: `primary` (default), `secondary` or `muted` (text-muted, HCUI's ⋯ triggers). */
|
|
81
|
+
tone?: 'primary' | 'secondary' | 'muted';
|
|
59
82
|
/** Fill: `muted` (default, HCUI `icon-button`), `surface` (surface with the card ring
|
|
60
83
|
* and shadow, HCUI's mobile theme button), `outline` (surface with a 1px border ring,
|
|
61
|
-
* HCUI's mobile sort button) or `ghost` (no fill until hover
|
|
84
|
+
* HCUI's mobile sort button) or `ghost` (no fill until hover; an open popup trigger,
|
|
85
|
+
* `aria-haspopup` with `aria-expanded="true"`, keeps the hover look). */
|
|
62
86
|
variant?: 'muted' | 'surface' | 'outline' | 'ghost';
|
|
63
87
|
/** `circle` (default) or `rounded` (a 12px-radius square, HCUI's desktop utilities). */
|
|
64
88
|
shape?: 'circle' | 'rounded';
|
|
@@ -69,7 +93,7 @@ export interface IconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonEle
|
|
|
69
93
|
iconKey?: string | number;
|
|
70
94
|
}
|
|
71
95
|
/** Round icon-only button (back, close, options). */
|
|
72
|
-
export declare const IconButton:
|
|
96
|
+
export declare const IconButton: ForwardRefExoticComponent<IconButtonProps & RefAttributes<HTMLButtonElement>>;
|
|
73
97
|
interface ChipBaseProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
74
98
|
/** Toggle state for filters; omit for a plain action chip. */
|
|
75
99
|
selected?: boolean;
|
|
@@ -80,8 +104,12 @@ interface ChipBaseProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
80
104
|
* desktop quick filters and chosen-value tags); selected turns to the contrast fill.
|
|
81
105
|
*/
|
|
82
106
|
size?: 'md' | 'sm' | 'xs';
|
|
83
|
-
/**
|
|
84
|
-
|
|
107
|
+
/**
|
|
108
|
+
* `outline` (default); `quiet`: lighter ring and secondary text, bolder once applied (HCUI's rule
|
|
109
|
+
* filter pills); `muted`: gray fill without ring (HCUI's search conditions). With `onClear`, a
|
|
110
|
+
* `muted` chip of `md` or `sm` draws its × at 26px, concentric with the pill's end.
|
|
111
|
+
*/
|
|
112
|
+
variant?: 'outline' | 'quiet' | 'muted';
|
|
85
113
|
/** A filter with values applied: a 1.5px ring in the primary text color (and primary, bolder text when `quiet`). */
|
|
86
114
|
applied?: boolean;
|
|
87
115
|
/**
|
|
@@ -94,6 +122,17 @@ interface ChipBaseProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
94
122
|
* `undefined` (e.g. `badge={n || undefined}`) to hide it when nothing is applied.
|
|
95
123
|
*/
|
|
96
124
|
badge?: ReactNode;
|
|
125
|
+
/**
|
|
126
|
+
* Where the badge goes: `inline` (default, after the label) or `corner` (on the top right
|
|
127
|
+
* corner, in the brand color with a ring of `--hc-chip-badge-ring`, default `bg-page`; HCUI's
|
|
128
|
+
* mobile Meta filter button). A chip with an `icon` and no label is a circle.
|
|
129
|
+
*/
|
|
130
|
+
badgePlacement?: 'inline' | 'corner';
|
|
131
|
+
/**
|
|
132
|
+
* Information, not an action: the chip cannot be pressed (the button is disabled) but keeps
|
|
133
|
+
* its full color instead of dimming (HCUI's Meta era chip when only one era fits the format).
|
|
134
|
+
*/
|
|
135
|
+
informative?: boolean;
|
|
97
136
|
/**
|
|
98
137
|
* Down chevron at the end. On by default when the chip opens a popup (`aria-haspopup`,
|
|
99
138
|
* which `Menu` and `Popover` give their trigger); `aria-expanded="true"` draws the ring.
|
|
@@ -122,7 +161,7 @@ export type ChipProps = ChipBaseProps & ({
|
|
|
122
161
|
* trigger it takes a `badge` with the number of values applied, `applied`, and the
|
|
123
162
|
* chevron and ring of an open popup; `onClear` adds a remove button.
|
|
124
163
|
*/
|
|
125
|
-
export declare const Chip:
|
|
164
|
+
export declare const Chip: ForwardRefExoticComponent<ChipProps & RefAttributes<HTMLButtonElement>>;
|
|
126
165
|
export interface FilterBarProps extends HTMLAttributes<HTMLDivElement> {
|
|
127
166
|
/** Accessible name of the group (e.g. "Filtros"). */
|
|
128
167
|
label: string;
|
|
@@ -142,13 +181,25 @@ export interface FilterBarProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
142
181
|
density?: 'comfortable' | 'compact';
|
|
143
182
|
/** A band that sticks to the top of the scrolling panel, with the surface fill and 8px above and below (HCUI's desktop filter bar). The offset is `--hc-filter-bar-top`. */
|
|
144
183
|
sticky?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* The bar reaches the panel's edges: a negative margin of `--hc-filter-bar-bleed-start` and
|
|
186
|
+
* `--hc-filter-bar-bleed-end` (both default to `--hc-filter-bar-bleed`, else 0) given back as
|
|
187
|
+
* padding, so the content stays in place and a sticky band covers the full width (HCUI's
|
|
188
|
+
* `.desktop-filter-bar`, which content bleeding to the edge passes under).
|
|
189
|
+
*/
|
|
190
|
+
bleed?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Class of the row that holds the filters. The row is `position: relative`, so a popup the
|
|
193
|
+
* caller places with `position: absolute` inside it is anchored to the row (HCUI's "Mais filtros").
|
|
194
|
+
*/
|
|
195
|
+
rowClassName?: string;
|
|
145
196
|
}
|
|
146
197
|
/**
|
|
147
198
|
* Layout of a row of filters (`Chip`s) with optional `start`, `end` and `footer` slots.
|
|
148
199
|
* Presentation only: which filters exist, their values, the search rules and persistence
|
|
149
200
|
* are the caller's. A scrolling row bleeds into the page gutter by `--hc-filter-bar-bleed`.
|
|
150
201
|
*/
|
|
151
|
-
export declare const FilterBar:
|
|
202
|
+
export declare const FilterBar: ForwardRefExoticComponent<FilterBarProps & RefAttributes<HTMLDivElement>>;
|
|
152
203
|
export interface FieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
153
204
|
/** Accessible name. Visible above the field unless `hideLabel` is set. */
|
|
154
205
|
label: string;
|
|
@@ -164,7 +215,7 @@ export interface FieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
164
215
|
error?: ReactNode;
|
|
165
216
|
}
|
|
166
217
|
/** Filled pill text field. Value, validation and messages stay with the caller. */
|
|
167
|
-
export declare const Field:
|
|
218
|
+
export declare const Field: ForwardRefExoticComponent<FieldProps & RefAttributes<HTMLInputElement>>;
|
|
168
219
|
export interface SkeletonProps extends HTMLAttributes<HTMLSpanElement> {
|
|
169
220
|
width?: string | number;
|
|
170
221
|
height?: string | number;
|
|
@@ -213,7 +264,7 @@ export type MeterProps = MeterOwnProps & (
|
|
|
213
264
|
* Bar of a value against a limit (`role="meter"`), with an over-the-limit tone. It
|
|
214
265
|
* renders only spans, so it fits inside a button. Placement (absolute, grid) is the caller's.
|
|
215
266
|
*/
|
|
216
|
-
export declare const Meter:
|
|
267
|
+
export declare const Meter: ForwardRefExoticComponent<MeterProps & RefAttributes<HTMLSpanElement>>;
|
|
217
268
|
export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> {
|
|
218
269
|
/** 20px (touch lists, sheets) or 16px (dense desktop lists). */
|
|
219
270
|
size?: 'sm' | 'md';
|
|
@@ -225,7 +276,7 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement
|
|
|
225
276
|
* and `<label>` behave as usual. Wrap it in a `<label>` (the whole row becomes the
|
|
226
277
|
* target) or pass `aria-label`; the caller supplies the text.
|
|
227
278
|
*/
|
|
228
|
-
export declare const Checkbox:
|
|
279
|
+
export declare const Checkbox: ForwardRefExoticComponent<CheckboxProps & RefAttributes<HTMLInputElement>>;
|
|
229
280
|
export interface DialogProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title' | 'open' | 'onClose' | 'onCancel'> {
|
|
230
281
|
/** Controlled: the dialog shows while `open` is true and plays its exit before unmounting. */
|
|
231
282
|
open: boolean;
|
|
@@ -249,17 +300,17 @@ export interface DialogProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'ti
|
|
|
249
300
|
size?: 'sm' | 'md';
|
|
250
301
|
/** Esc and a backdrop click ask to close. Default true. */
|
|
251
302
|
dismissible?: boolean;
|
|
303
|
+
/** Class of the body that holds the children (and scrolls in `md`), e.g. to reserve the scrollbar's gutter. */
|
|
304
|
+
bodyClassName?: string;
|
|
252
305
|
}
|
|
253
306
|
/**
|
|
254
307
|
* Centered modal dialog on the native `<dialog>` and `showModal()`: the browser
|
|
255
308
|
* keeps it in the top layer, makes the rest of the page inert and traps Tab.
|
|
256
309
|
* The caller owns `open` and the texts; the dialog only asks to close.
|
|
257
310
|
*/
|
|
258
|
-
export declare const Dialog:
|
|
311
|
+
export declare const Dialog: ForwardRefExoticComponent<DialogProps & RefAttributes<HTMLDialogElement>>;
|
|
259
312
|
export type SheetPresentation = 'bottom' | 'center' | 'auto';
|
|
260
|
-
|
|
261
|
-
/** Accessible name of the close button, which every sheet shows. */
|
|
262
|
-
closeLabel: string;
|
|
313
|
+
interface SheetBaseProps extends Omit<DialogProps, 'size' | 'actions' | 'description' | 'closeLabel' | 'title'> {
|
|
263
314
|
/** Slot under the scrolling body, for the buttons (Clear | Done). */
|
|
264
315
|
footer?: ReactNode;
|
|
265
316
|
/**
|
|
@@ -271,6 +322,25 @@ export interface SheetProps extends Omit<DialogProps, 'size' | 'actions' | 'desc
|
|
|
271
322
|
/** Maximum width of the centered panel, in px. Default 440. */
|
|
272
323
|
width?: number;
|
|
273
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* `Sheet` props. By default the sheet has a header with the title (its accessible name) and a
|
|
327
|
+
* close button. `header={false}` drops both: the content brings its own heading and floating
|
|
328
|
+
* close button (HCUI's unit sheet), and `aria-label` names the dialog. The body then has no
|
|
329
|
+
* padding, and at the bottom the grabber (drawn above the content) covers its top 16px.
|
|
330
|
+
*/
|
|
331
|
+
export type SheetProps = SheetBaseProps & ({
|
|
332
|
+
header?: true;
|
|
333
|
+
/** Visible heading; it names the sheet. */
|
|
334
|
+
title: ReactNode;
|
|
335
|
+
/** Accessible name of the close button, which every sheet with a header shows. */
|
|
336
|
+
closeLabel: string;
|
|
337
|
+
} | {
|
|
338
|
+
header: false;
|
|
339
|
+
'aria-label': string;
|
|
340
|
+
title?: never;
|
|
341
|
+
closeLabel?: never;
|
|
342
|
+
closeIcon?: never;
|
|
343
|
+
});
|
|
274
344
|
/**
|
|
275
345
|
* Modal sheet on the `Dialog` base (native `<dialog>`, `showModal()`): the same focus,
|
|
276
346
|
* Tab trap, Esc, focus return, scroll lock, stacking and controlled `open`/`onClose`.
|
|
@@ -278,7 +348,7 @@ export interface SheetProps extends Omit<DialogProps, 'size' | 'actions' | 'desc
|
|
|
278
348
|
* flick) and drag up from the grabber or header to full height; content that has
|
|
279
349
|
* scrolled down scrolls back before the sheet moves.
|
|
280
350
|
*/
|
|
281
|
-
export declare const Sheet:
|
|
351
|
+
export declare const Sheet: ForwardRefExoticComponent<SheetProps & RefAttributes<HTMLDialogElement>>;
|
|
282
352
|
export interface SheetOption<T extends string> {
|
|
283
353
|
value: T;
|
|
284
354
|
label: ReactNode;
|
|
@@ -298,24 +368,23 @@ interface SheetChoiceProps<T extends string> extends Omit<HTMLAttributes<HTMLDiv
|
|
|
298
368
|
}
|
|
299
369
|
export interface SheetOptionsProps<T extends string> extends SheetChoiceProps<T> {
|
|
300
370
|
options: readonly SheetOption<T>[];
|
|
301
|
-
/**
|
|
302
|
-
* `card` (default): rows on a `bg-muted-2` card, as HCUI's SheetOptions. `list`: plain
|
|
303
|
-
* 48px rows divided by a line, the chosen one bolder with a 20px check in the text color,
|
|
304
|
-
* as the list of HCUI's mobile sort sheet (`SortButton`).
|
|
305
|
-
*/
|
|
306
|
-
variant?: 'card' | 'list';
|
|
307
371
|
}
|
|
308
|
-
/**
|
|
309
|
-
|
|
372
|
+
/**
|
|
373
|
+
* Single-choice list of rows with a check on a `bg-muted-2` card (HCUI's SheetOptions),
|
|
374
|
+
* for inside a sheet. It is also the phone's sort list (decision of 2026-11-07).
|
|
375
|
+
*/
|
|
376
|
+
export declare function SheetOptions<T extends string>({ label, options, value, onChange, className, ...props }: SheetOptionsProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
310
377
|
export interface SheetChipsProps<T extends string> extends SheetChoiceProps<T> {
|
|
311
378
|
options: readonly {
|
|
312
379
|
value: T;
|
|
313
380
|
label: ReactNode;
|
|
314
381
|
disabled?: boolean;
|
|
315
382
|
}[];
|
|
383
|
+
/** Size of every chip, as `Chip`'s: `md` (default), `sm` or `xs`. */
|
|
384
|
+
size?: ChipProps['size'];
|
|
316
385
|
}
|
|
317
386
|
/** Single-choice group of `Chip`s that wrap (HCUI's SheetChips), for inside a sheet. */
|
|
318
|
-
export declare function SheetChips<T extends string>({ label, options, value, onChange, className, ...props }: SheetChipsProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
387
|
+
export declare function SheetChips<T extends string>({ label, options, value, onChange, size, className, ...props }: SheetChipsProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
319
388
|
export type PopupSide = 'bottom' | 'top';
|
|
320
389
|
export type PopupAlign = 'start' | 'end';
|
|
321
390
|
/** Props a trigger receives: spread them on the element that opens the popup. */
|
|
@@ -366,6 +435,14 @@ export declare function placePopup(trigger: Rect, size: {
|
|
|
366
435
|
side: PopupSide;
|
|
367
436
|
align: PopupAlign;
|
|
368
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Where to portal something that floats over `node` (a tip, a tooltip): the open `<dialog>`
|
|
440
|
+
* around it, else `document.body`. A modal dialog (`Dialog`, `Sheet`) is in the top layer and
|
|
441
|
+
* makes the rest of the page inert, so a tip portaled to `body` from inside it would stay
|
|
442
|
+
* behind it and get no touches; inside the dialog it shows above it. `Menu` and `Popover`
|
|
443
|
+
* with `portal` already do this. On the server (no document) it returns null.
|
|
444
|
+
*/
|
|
445
|
+
export declare function portalContainerFor(node: Element | null | undefined): HTMLElement | null;
|
|
369
446
|
export interface MenuProps extends PopupBaseProps, Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'children'> {
|
|
370
447
|
/** Accessible name of the menu (`aria-label`). */
|
|
371
448
|
label: string;
|
|
@@ -379,7 +456,7 @@ export interface MenuProps extends PopupBaseProps, Omit<HTMLAttributes<HTMLDivEl
|
|
|
379
456
|
* typing move between items; Enter/Space choose; Esc closes and returns focus to the
|
|
380
457
|
* trigger; Tab closes and moves on; a press outside closes.
|
|
381
458
|
*/
|
|
382
|
-
export declare const Menu:
|
|
459
|
+
export declare const Menu: ForwardRefExoticComponent<MenuProps & RefAttributes<HTMLDivElement>>;
|
|
383
460
|
interface MenuItemBaseProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'role' | 'onSelect'> {
|
|
384
461
|
/** Decorative icon at the end of the row; pass it already sized (15px in HCUI). */
|
|
385
462
|
icon?: ReactNode;
|
|
@@ -393,7 +470,7 @@ export interface MenuItemProps extends MenuItemBaseProps {
|
|
|
393
470
|
onSelect?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
394
471
|
}
|
|
395
472
|
/** An action (`menuitem`). It closes the menu; focus returns to the trigger unless the action moved it. */
|
|
396
|
-
export declare const MenuItem:
|
|
473
|
+
export declare const MenuItem: ForwardRefExoticComponent<MenuItemProps & RefAttributes<HTMLButtonElement>>;
|
|
397
474
|
export interface MenuRadioGroupProps<T extends string> extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'onChange'> {
|
|
398
475
|
value: T;
|
|
399
476
|
onValueChange: (value: NoInfer<T>) => void;
|
|
@@ -406,7 +483,7 @@ export interface MenuItemRadioProps extends MenuItemBaseProps {
|
|
|
406
483
|
value: string;
|
|
407
484
|
}
|
|
408
485
|
/** A `menuitemradio`: the chosen one is bold with a check. Choosing closes the menu and returns focus to the trigger. */
|
|
409
|
-
export declare const MenuItemRadio:
|
|
486
|
+
export declare const MenuItemRadio: ForwardRefExoticComponent<MenuItemRadioProps & RefAttributes<HTMLButtonElement>>;
|
|
410
487
|
export interface MenuItemCheckboxProps extends MenuItemBaseProps {
|
|
411
488
|
checked: boolean;
|
|
412
489
|
onCheckedChange: (checked: boolean) => void;
|
|
@@ -414,7 +491,7 @@ export interface MenuItemCheckboxProps extends MenuItemBaseProps {
|
|
|
414
491
|
closeOnSelect?: boolean;
|
|
415
492
|
}
|
|
416
493
|
/** A `menuitemcheckbox`: toggles in place, with a check while on. */
|
|
417
|
-
export declare const MenuItemCheckbox:
|
|
494
|
+
export declare const MenuItemCheckbox: ForwardRefExoticComponent<MenuItemCheckboxProps & RefAttributes<HTMLButtonElement>>;
|
|
418
495
|
/** A line between groups of items. */
|
|
419
496
|
export declare function MenuSeparator({ className, ...props }: Omit<HTMLAttributes<HTMLDivElement>, 'role'>): import("react/jsx-runtime").JSX.Element;
|
|
420
497
|
/** Plain text inside the menu, such as a question before a destructive choice. Not focusable. */
|
|
@@ -442,7 +519,7 @@ export interface SortMenuProps<T extends string> extends Omit<MenuProps, 'label'
|
|
|
442
519
|
/**
|
|
443
520
|
* Sort control: a `Chip` showing the current choice that opens a `Menu` with a
|
|
444
521
|
* `MenuRadioGroup` (HCUI's `DesktopSortMenu`). Options and value come from the caller.
|
|
445
|
-
* On phones, compose `Sheet` with `SheetOptions` behind an `IconButton` instead.
|
|
522
|
+
* On phones, compose `Sheet` with `SheetOptions` (its card look) behind an `IconButton` instead.
|
|
446
523
|
*/
|
|
447
524
|
export declare function SortMenu<T extends string>({ label, value, options, onChange, applied, size, triggerClassName, ...props }: SortMenuProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
448
525
|
export interface PopoverProps extends PopupBaseProps, Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'children'> {
|
|
@@ -463,7 +540,7 @@ export interface PopoverProps extends PopupBaseProps, Omit<HTMLAttributes<HTMLDi
|
|
|
463
540
|
* not trapped. The caller supplies the content and its texts. Esc is taken before it
|
|
464
541
|
* reaches the content (so an enclosing Dialog stays open): a field inside cannot use it.
|
|
465
542
|
*/
|
|
466
|
-
export declare const Popover:
|
|
543
|
+
export declare const Popover: ForwardRefExoticComponent<PopoverProps & RefAttributes<HTMLDivElement>>;
|
|
467
544
|
export type TableSortDirection = 'ascending' | 'descending';
|
|
468
545
|
export interface TableColumn<Row> {
|
|
469
546
|
/** Stable id of the column; it is what `sort.key` and `onSort` name. */
|
|
@@ -528,7 +605,7 @@ export interface PageHeaderProps extends Omit<HTMLAttributes<HTMLElement>, 'titl
|
|
|
528
605
|
visuallyHidden?: boolean;
|
|
529
606
|
}
|
|
530
607
|
/** Desktop page header: one line with the title (22px, semibold) and actions at the end. */
|
|
531
|
-
export declare const PageHeader:
|
|
608
|
+
export declare const PageHeader: ForwardRefExoticComponent<PageHeaderProps & RefAttributes<HTMLElement>>;
|
|
532
609
|
export interface PanelHeaderStep {
|
|
533
610
|
label: string;
|
|
534
611
|
/** Goes back to this step. The last step is the current one and is never a button. */
|
|
@@ -567,14 +644,14 @@ export interface PanelHeaderProps extends Omit<HTMLAttributes<HTMLElement>, 'tit
|
|
|
567
644
|
closeIcon?: ReactNode;
|
|
568
645
|
}
|
|
569
646
|
/** Header of a panel or section: title (or a trail), optional eyebrow, subtitle, icon, actions and close button. */
|
|
570
|
-
export declare const PanelHeader:
|
|
647
|
+
export declare const PanelHeader: ForwardRefExoticComponent<PanelHeaderProps & RefAttributes<HTMLElement>>;
|
|
571
648
|
export type ListRowProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
572
649
|
/**
|
|
573
650
|
* A tappable list row (HCUI's `list-row` mixin): full width, at least 56px, 8px 16px of padding,
|
|
574
651
|
* a 12px gap between its children, a translucent veil on hover and press and the focus ring inside.
|
|
575
652
|
* The content and its semantics (`aria-pressed`, `role="option"`) are the caller's.
|
|
576
653
|
*/
|
|
577
|
-
export declare const ListRow:
|
|
654
|
+
export declare const ListRow: ForwardRefExoticComponent<ListRowProps & RefAttributes<HTMLButtonElement>>;
|
|
578
655
|
export interface CommandPaletteItem {
|
|
579
656
|
/** Unique among all items. */
|
|
580
657
|
key: string;
|
|
@@ -638,7 +715,7 @@ export interface CommandPaletteProps extends Omit<HTMLAttributes<HTMLDialogEleme
|
|
|
638
715
|
* into view; Enter selects, ⌘/Ctrl+Enter takes the alternative; the pointer activates the
|
|
639
716
|
* item under it. Texts, results and actions come from the caller.
|
|
640
717
|
*/
|
|
641
|
-
export declare const CommandPalette:
|
|
718
|
+
export declare const CommandPalette: ForwardRefExoticComponent<CommandPaletteProps & RefAttributes<HTMLDialogElement>>;
|
|
642
719
|
/**
|
|
643
720
|
* Walks a list of image addresses: starts at the first and moves to the next on
|
|
644
721
|
* each load error. Starts over when the list changes. `src` is `undefined` once
|
|
@@ -680,7 +757,7 @@ export interface MiniDialViewProps {
|
|
|
680
757
|
* The dial summarized in small squares: one column per click, one row per value
|
|
681
758
|
* (speed, attack, defense, damage). The cell size is `--hc-mini-dial-cell` (7px).
|
|
682
759
|
*/
|
|
683
|
-
export declare const MiniDialView:
|
|
760
|
+
export declare const MiniDialView: ForwardRefExoticComponent<MiniDialViewProps & RefAttributes<HTMLSpanElement>>;
|
|
684
761
|
export interface PowerIconViewProps {
|
|
685
762
|
/** Power color (the circle's fill). */
|
|
686
763
|
color: string;
|
|
@@ -691,7 +768,7 @@ export interface PowerIconViewProps {
|
|
|
691
768
|
size?: number;
|
|
692
769
|
}
|
|
693
770
|
/** Power icon: a circle in the power color with the value symbol on top. */
|
|
694
|
-
export declare const PowerIconView:
|
|
771
|
+
export declare const PowerIconView: ForwardRefExoticComponent<PowerIconViewProps & RefAttributes<HTMLSpanElement>>;
|
|
695
772
|
export interface StatGlyphViewProps {
|
|
696
773
|
/** Address of the symbol, already built. */
|
|
697
774
|
src: string;
|
|
@@ -700,7 +777,7 @@ export interface StatGlyphViewProps {
|
|
|
700
777
|
size?: number;
|
|
701
778
|
}
|
|
702
779
|
/** The value symbol alone (no circle), in neutral gray. Used in the dial legend. */
|
|
703
|
-
export declare const StatGlyphView:
|
|
780
|
+
export declare const StatGlyphView: ForwardRefExoticComponent<StatGlyphViewProps & RefAttributes<HTMLImageElement>>;
|
|
704
781
|
export interface SpecialIconViewProps {
|
|
705
782
|
/** Round white background (the image server's `sp/white.svg`), already built. */
|
|
706
783
|
backgroundSrc: string;
|
|
@@ -709,7 +786,7 @@ export interface SpecialIconViewProps {
|
|
|
709
786
|
size?: number;
|
|
710
787
|
}
|
|
711
788
|
/** Special power and trait icon: a white circle with a symbol in the middle. */
|
|
712
|
-
export declare const SpecialIconView:
|
|
789
|
+
export declare const SpecialIconView: ForwardRefExoticComponent<SpecialIconViewProps & RefAttributes<HTMLSpanElement>>;
|
|
713
790
|
export interface EquipmentIconProps {
|
|
714
791
|
size?: number;
|
|
715
792
|
}
|
|
@@ -750,7 +827,7 @@ export interface AvatarViewProps {
|
|
|
750
827
|
* `fallbackSrc` (with `data-fallback` and the muted fill). The image cannot be
|
|
751
828
|
* dragged, selected or opened in a context menu.
|
|
752
829
|
*/
|
|
753
|
-
export declare const AvatarView:
|
|
830
|
+
export declare const AvatarView: ForwardRefExoticComponent<AvatarViewProps & RefAttributes<HTMLImageElement>>;
|
|
754
831
|
export interface SetIconViewProps {
|
|
755
832
|
/** Addresses of the set icon, in the order to try. Empty: renders nothing. */
|
|
756
833
|
sources: readonly string[];
|
|
@@ -759,7 +836,7 @@ export interface SetIconViewProps {
|
|
|
759
836
|
title?: string;
|
|
760
837
|
}
|
|
761
838
|
/** Set icon. Tries each address in order and disappears when none loads. Decorative: the set name is next to it. */
|
|
762
|
-
export declare const SetIconView:
|
|
839
|
+
export declare const SetIconView: ForwardRefExoticComponent<SetIconViewProps & RefAttributes<HTMLImageElement>>;
|
|
763
840
|
/** Value rows of the dial, top to bottom (the top row is the click number). */
|
|
764
841
|
export declare const COMBAT_DIAL_STATS: readonly ["speed", "attack", "defense", "damage"];
|
|
765
842
|
export type CombatDialStat = (typeof COMBAT_DIAL_STATS)[number];
|
|
@@ -864,6 +941,12 @@ export interface CombatDialViewProps {
|
|
|
864
941
|
labels: CombatDialLabels;
|
|
865
942
|
/** `printed`: the physical card's dial, without the header, in rows of 12 clicks. */
|
|
866
943
|
presentation?: 'default' | 'printed';
|
|
944
|
+
/**
|
|
945
|
+
* `comfortable` (default): 40px cells. `compact`: 34px cells, 6px gaps, 13px numbers and
|
|
946
|
+
* tighter point chips, for dense lists (HCUI's compact dial of the unit view on phones).
|
|
947
|
+
* The printed presentation keeps its own measures.
|
|
948
|
+
*/
|
|
949
|
+
density?: 'comfortable' | 'compact';
|
|
867
950
|
/** Without it the dial is static: it neither marks nor changes the click; only cells with a tip react. */
|
|
868
951
|
onClickChange?: (click: number) => void;
|
|
869
952
|
onSelectPoint: (point: CombatDialPoint) => void;
|
|
@@ -880,12 +963,12 @@ export interface CombatDialViewProps {
|
|
|
880
963
|
* printed card, the header with the point values. Hover, touch and keyboard on
|
|
881
964
|
* the cells open the tip through `onTipChange`; the caller draws the tip.
|
|
882
965
|
*/
|
|
883
|
-
export declare const CombatDialView:
|
|
884
|
-
export declare const
|
|
885
|
-
export declare const
|
|
886
|
-
export declare const
|
|
966
|
+
export declare const CombatDialView: ForwardRefExoticComponent<CombatDialViewProps & RefAttributes<HTMLElement>>;
|
|
967
|
+
export declare const PHYSICAL_CARD_WIDTH = 375;
|
|
968
|
+
export declare const PHYSICAL_CARD_HEIGHT = 525;
|
|
969
|
+
export declare const PHYSICAL_CARD_BACK_TABLE_HEIGHT = 440;
|
|
887
970
|
/** Position of each value of the bystander's dial: every row goes 24px down and 7px right. */
|
|
888
|
-
export declare const
|
|
971
|
+
export declare const PHYSICAL_CARD_BYSTANDER_DIAL_STEP: {
|
|
889
972
|
x: number;
|
|
890
973
|
y: number;
|
|
891
974
|
};
|
|
@@ -898,11 +981,11 @@ export declare const BYSTANDER_DIAL_STEP: {
|
|
|
898
981
|
* `overflowing(table)` tells whether that column overflows with the current split.
|
|
899
982
|
* Returns the next split, or `null` once it is stable.
|
|
900
983
|
*/
|
|
901
|
-
export declare function
|
|
984
|
+
export declare function nextPhysicalCardDistribution(pages: number[], overflowing: (table: number) => boolean): number[] | null;
|
|
902
985
|
/** How many backs the split needs (each back has two columns). There is always one. */
|
|
903
|
-
export declare function
|
|
986
|
+
export declare function physicalCardBackCount(pages: number[]): number;
|
|
904
987
|
/** Cursor position on the card (0 to 1) → tilt, parallax (-1 to 1) and shine (%). */
|
|
905
|
-
export declare function
|
|
988
|
+
export declare function physicalCardTiltAt(x: number, y: number, damping?: number): {
|
|
906
989
|
rotateX: number;
|
|
907
990
|
rotateY: number;
|
|
908
991
|
parallaxX: number;
|
|
@@ -910,16 +993,16 @@ export declare function tiltAt(x: number, y: number, damping?: number): {
|
|
|
910
993
|
shineX: number;
|
|
911
994
|
shineY: number;
|
|
912
995
|
};
|
|
913
|
-
type CardTilt = ReturnType<typeof
|
|
996
|
+
type CardTilt = ReturnType<typeof physicalCardTiltAt>;
|
|
914
997
|
/** The finished values each moving part of the card takes, ready for `style`. */
|
|
915
|
-
export declare function
|
|
998
|
+
export declare function physicalCardTiltStyles(tilt: CardTilt): {
|
|
916
999
|
card: string;
|
|
917
1000
|
art: string;
|
|
918
1001
|
header: string;
|
|
919
1002
|
shine: string;
|
|
920
1003
|
};
|
|
921
1004
|
/** Sensor reading relative to the reference pose → position on the card (0 to 1). */
|
|
922
|
-
export declare function
|
|
1005
|
+
export declare function physicalCardDevicePosition(beta: number, gamma: number, baseline: {
|
|
923
1006
|
beta: number;
|
|
924
1007
|
gamma: number;
|
|
925
1008
|
}, screenAngle?: number): {
|
|
@@ -932,7 +1015,7 @@ export declare function devicePosition(beta: number, gamma: number, baseline: {
|
|
|
932
1015
|
* it; outside iOS it does nothing. A touch the browser refuses leaves the request
|
|
933
1016
|
* for the next one.
|
|
934
1017
|
*/
|
|
935
|
-
export declare function
|
|
1018
|
+
export declare function requestPhysicalCardMotionAccess(): void;
|
|
936
1019
|
/** Value rows of the dial, top to bottom. */
|
|
937
1020
|
export declare const PHYSICAL_CARD_STATS: readonly ["speed", "attack", "defense", "damage"];
|
|
938
1021
|
export type PhysicalCardStat = (typeof PHYSICAL_CARD_STATS)[number];
|
|
@@ -1217,20 +1300,20 @@ export declare function PhysicalCardFocusView({ label, onClose, children }: Phys
|
|
|
1217
1300
|
* holding to open the focus view and flipping in it, and opens the tips through
|
|
1218
1301
|
* `onTipChange`; drawing the tip, translating and copying are the caller's.
|
|
1219
1302
|
*/
|
|
1220
|
-
export declare const PhysicalCardView:
|
|
1303
|
+
export declare const PhysicalCardView: ForwardRefExoticComponent<PhysicalCardViewProps & RefAttributes<HTMLDivElement>>;
|
|
1221
1304
|
/**
|
|
1222
1305
|
* A faithful port of hcmaps.net's map drawing engine (map.js / tile.js / edge.js /
|
|
1223
1306
|
* wall.js), the same engine HCUnits uses to draw the map's canvas. It reads the
|
|
1224
1307
|
* same JSON (the piece's map) and draws it 1:1 locally, with no runtime
|
|
1225
1308
|
* dependency on their scripts. Credit: hcmaps.net (original engine in JS).
|
|
1226
1309
|
*/
|
|
1227
|
-
export declare const
|
|
1228
|
-
export declare const
|
|
1229
|
-
export declare const
|
|
1230
|
-
export declare const
|
|
1231
|
-
export declare const
|
|
1232
|
-
export declare const
|
|
1233
|
-
export declare const
|
|
1310
|
+
export declare const MAP_TILE_SIZE = 64;
|
|
1311
|
+
export declare const MAP_ELEVATION_TILE_COLORS: string[];
|
|
1312
|
+
export declare const MAP_TERRAIN_TILE_COLORS: Record<string, string>;
|
|
1313
|
+
export declare const MAP_TERRAIN_EDGE_COLORS: Record<string, string>;
|
|
1314
|
+
export declare const MAP_ELEVATION_EDGE_COLOR = "#FF0000";
|
|
1315
|
+
export declare const MAP_INDOOR_EDGE_COLOR = "#FFFF00";
|
|
1316
|
+
export declare const MAP_WALL_COLORS: Record<string, string>;
|
|
1234
1317
|
interface JsonLabel {
|
|
1235
1318
|
text: string;
|
|
1236
1319
|
color?: string;
|
|
@@ -1299,7 +1382,7 @@ export declare function mapSquare(map: HCMapJson, x: number, y: number): {
|
|
|
1299
1382
|
};
|
|
1300
1383
|
export type MapSquare = ReturnType<typeof mapSquare>;
|
|
1301
1384
|
/** A text elevation exists in the hcmaps format; the 2D drawing treats it as an elevated level. */
|
|
1302
|
-
export declare function
|
|
1385
|
+
export declare function mapElevationLevel(elevation: number | string): number;
|
|
1303
1386
|
export declare function mapMaxLevel(map: HCMapJson): number;
|
|
1304
1387
|
export interface MapInspection {
|
|
1305
1388
|
square: MapSquare;
|
|
@@ -1314,7 +1397,7 @@ export interface MapInspection {
|
|
|
1314
1397
|
}
|
|
1315
1398
|
/** Coordinates are in squares; wall tolerance is based on screen pixels by the caller. */
|
|
1316
1399
|
export declare function inspectMap(map: HCMapJson, x: number, y: number, tolerance?: number): MapInspection | null;
|
|
1317
|
-
export declare function
|
|
1400
|
+
export declare function mapSquareCoordinate(square: Pick<MapSquare, 'x' | 'y'>): string;
|
|
1318
1401
|
/**
|
|
1319
1402
|
* The 3D model's scene, with no drawing. It uses only what the map JSON has:
|
|
1320
1403
|
* terrain, elevation, environment, walls, ramps and ziplines. Blocking follows
|
|
@@ -1322,15 +1405,15 @@ export declare function squareCoordinate(square: Pick<MapSquare, 'x' | 'y'>): st
|
|
|
1322
1405
|
* one elevation. Walls, water and obscuring have no height in the data: those
|
|
1323
1406
|
* are conventions.
|
|
1324
1407
|
*/
|
|
1325
|
-
export declare const
|
|
1326
|
-
export declare const
|
|
1327
|
-
export interface
|
|
1408
|
+
export declare const MAP_SCENE_LEVEL_HEIGHT = 0.62;
|
|
1409
|
+
export declare const MAP_SCENE_BASE_Z = -0.34;
|
|
1410
|
+
export interface MapSceneCell extends MapSquare {
|
|
1328
1411
|
level: number;
|
|
1329
1412
|
/** The square's floor, without the terrain's volume. */
|
|
1330
1413
|
floor: number;
|
|
1331
1414
|
top: number;
|
|
1332
1415
|
}
|
|
1333
|
-
export interface
|
|
1416
|
+
export interface MapSceneWall {
|
|
1334
1417
|
x0: number;
|
|
1335
1418
|
y0: number;
|
|
1336
1419
|
x1: number;
|
|
@@ -1339,7 +1422,7 @@ export interface SceneWall {
|
|
|
1339
1422
|
z0: number;
|
|
1340
1423
|
z1: number;
|
|
1341
1424
|
}
|
|
1342
|
-
export interface
|
|
1425
|
+
export interface MapSceneRamp {
|
|
1343
1426
|
x: number;
|
|
1344
1427
|
y: number;
|
|
1345
1428
|
dx: number;
|
|
@@ -1347,7 +1430,7 @@ export interface SceneRamp {
|
|
|
1347
1430
|
from: number;
|
|
1348
1431
|
to: number;
|
|
1349
1432
|
}
|
|
1350
|
-
export interface
|
|
1433
|
+
export interface MapSceneLine {
|
|
1351
1434
|
x0: number;
|
|
1352
1435
|
y0: number;
|
|
1353
1436
|
x1: number;
|
|
@@ -1357,13 +1440,13 @@ export interface SceneLine {
|
|
|
1357
1440
|
export interface MapScene {
|
|
1358
1441
|
width: number;
|
|
1359
1442
|
height: number;
|
|
1360
|
-
cells:
|
|
1361
|
-
walls:
|
|
1362
|
-
ramps:
|
|
1363
|
-
ziplines:
|
|
1443
|
+
cells: MapSceneCell[];
|
|
1444
|
+
walls: MapSceneWall[];
|
|
1445
|
+
ramps: MapSceneRamp[];
|
|
1446
|
+
ziplines: MapSceneLine[];
|
|
1364
1447
|
maxTop: number;
|
|
1365
1448
|
}
|
|
1366
|
-
export declare function
|
|
1449
|
+
export declare function mapSceneCell(scene: Pick<MapScene, 'width' | 'height' | 'cells'>, x: number, y: number): MapSceneCell | null;
|
|
1367
1450
|
export declare function buildMapScene(map: HCMapJson): MapScene;
|
|
1368
1451
|
export interface MapCamera {
|
|
1369
1452
|
azimuth: number;
|
|
@@ -1372,16 +1455,16 @@ export interface MapCamera {
|
|
|
1372
1455
|
panX: number;
|
|
1373
1456
|
panY: number;
|
|
1374
1457
|
}
|
|
1375
|
-
export interface
|
|
1458
|
+
export interface MapViewport {
|
|
1376
1459
|
width: number;
|
|
1377
1460
|
height: number;
|
|
1378
1461
|
}
|
|
1379
|
-
export declare const
|
|
1462
|
+
export declare const MAP_DEFAULT_CAMERA: MapCamera;
|
|
1380
1463
|
/** 90 is the flat view from above. Below the minimum the board becomes a line. */
|
|
1381
|
-
export declare const
|
|
1382
|
-
export declare const
|
|
1383
|
-
export declare const
|
|
1384
|
-
export interface
|
|
1464
|
+
export declare const MAP_TILT_RANGE: readonly [6, 90];
|
|
1465
|
+
export declare const MAP_ZOOM_RANGE: readonly [1, 6];
|
|
1466
|
+
export declare const clampMapValue: (value: number, min: number, max: number) => number;
|
|
1467
|
+
export interface MapProjection {
|
|
1385
1468
|
scale: number;
|
|
1386
1469
|
sin: number;
|
|
1387
1470
|
cos: number;
|
|
@@ -1391,16 +1474,16 @@ export interface Projection {
|
|
|
1391
1474
|
/** From the screen to the map, on a plane at height `z`. */
|
|
1392
1475
|
ground(px: number, py: number, z: number): [number, number];
|
|
1393
1476
|
}
|
|
1394
|
-
export declare function
|
|
1477
|
+
export declare function makeMapProjection(scene: MapScene, camera: MapCamera, viewport: MapViewport): MapProjection;
|
|
1395
1478
|
/** The map's center may go as far as any of its corners reaches the middle of the screen. */
|
|
1396
|
-
export declare function
|
|
1479
|
+
export declare function clampMapPan(scene: MapScene, camera: MapCamera, viewport: MapViewport): MapCamera;
|
|
1397
1480
|
/** Zooms keeping the point at `anchor` (measured from the screen's center) still. */
|
|
1398
|
-
export declare function
|
|
1481
|
+
export declare function zoomMapCamera(scene: MapScene, camera: MapCamera, viewport: MapViewport, factor: number, anchor?: {
|
|
1399
1482
|
x: number;
|
|
1400
1483
|
y: number;
|
|
1401
1484
|
}): MapCamera;
|
|
1402
1485
|
/** A square's four sides: the edge's points, the neighbor and the normal. */
|
|
1403
|
-
export declare const
|
|
1486
|
+
export declare const MAP_CELL_SIDES: readonly [{
|
|
1404
1487
|
readonly ax: 0;
|
|
1405
1488
|
readonly ay: 1;
|
|
1406
1489
|
readonly bx: 0;
|
|
@@ -1433,7 +1516,7 @@ export declare const CELL_SIDES: readonly [{
|
|
|
1433
1516
|
* From the screen to map coordinates, testing from front to back. Returns the
|
|
1434
1517
|
* point in `inspectMap`'s terms, so the tooltip and selection match the 2D board.
|
|
1435
1518
|
*/
|
|
1436
|
-
export declare function
|
|
1519
|
+
export declare function pickMapScene(scene: MapScene, view: MapProjection, px: number, py: number): {
|
|
1437
1520
|
x: number;
|
|
1438
1521
|
y: number;
|
|
1439
1522
|
} | null;
|
|
@@ -1442,7 +1525,7 @@ type Point = readonly [number, number];
|
|
|
1442
1525
|
* The target's squares inside the board and their outer outline, in map coordinates.
|
|
1443
1526
|
* Corners are where the outline turns or ends: the volume's edges rise there.
|
|
1444
1527
|
*/
|
|
1445
|
-
export declare function
|
|
1528
|
+
export declare function mapFootprintOutline({ x, y, width, height, cells }: {
|
|
1446
1529
|
x: number;
|
|
1447
1530
|
y: number;
|
|
1448
1531
|
width: number;
|
|
@@ -1453,7 +1536,7 @@ export declare function footprintOutline({ x, y, width, height, cells }: {
|
|
|
1453
1536
|
edges: [Point, Point][];
|
|
1454
1537
|
corners: Point[];
|
|
1455
1538
|
};
|
|
1456
|
-
export interface
|
|
1539
|
+
export interface MapSceneFootprint {
|
|
1457
1540
|
x: number;
|
|
1458
1541
|
y: number;
|
|
1459
1542
|
width: number;
|
|
@@ -1463,7 +1546,7 @@ export interface SceneFootprint {
|
|
|
1463
1546
|
/** Occupied squares (`cells[y][x]`, from the corner); without it, the whole rectangle. */
|
|
1464
1547
|
cells?: readonly (readonly boolean[])[] | null;
|
|
1465
1548
|
}
|
|
1466
|
-
export interface
|
|
1549
|
+
export interface MapSceneHighlight {
|
|
1467
1550
|
square?: {
|
|
1468
1551
|
x: number;
|
|
1469
1552
|
y: number;
|
|
@@ -1475,9 +1558,9 @@ export interface SceneHighlight {
|
|
|
1475
1558
|
y1: number;
|
|
1476
1559
|
};
|
|
1477
1560
|
/** The target of a piece being moved: floor and volume, cut to the board. */
|
|
1478
|
-
footprint?:
|
|
1561
|
+
footprint?: MapSceneFootprint;
|
|
1479
1562
|
}
|
|
1480
|
-
export declare function drawMapScene(ctx: CanvasRenderingContext2D, scene: MapScene, view:
|
|
1563
|
+
export declare function drawMapScene(ctx: CanvasRenderingContext2D, scene: MapScene, view: MapProjection, texture: HTMLCanvasElement, highlight?: MapSceneHighlight | null, { tufts }?: {
|
|
1481
1564
|
tufts?: boolean;
|
|
1482
1565
|
}): void;
|
|
1483
1566
|
/** The thumbnail's default height, in pixels. */
|
|
@@ -1508,7 +1591,7 @@ export interface MapBoardViewProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
1508
1591
|
* the tooltip shows are the caller's. Other attributes (role, focus, keyboard,
|
|
1509
1592
|
* `aria-*`, `data-*`) go to the container.
|
|
1510
1593
|
*/
|
|
1511
|
-
export declare const MapBoardView:
|
|
1594
|
+
export declare const MapBoardView: ForwardRefExoticComponent<MapBoardViewProps & RefAttributes<HTMLDivElement>>;
|
|
1512
1595
|
export interface MapBoardPlaceholderProps {
|
|
1513
1596
|
/** Read by screen readers while the map loads (e.g. "Loading map"). */
|
|
1514
1597
|
label: string;
|