@514sid/signagekit 0.0.0-stage → 0.0.2
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/CHANGELOG.md +39 -0
- package/LICENSE +44 -0
- package/README.md +106 -2
- package/bin/signagekit.js +4 -0
- package/dist/chunks/chart-WERjiRho.js +2 -0
- package/dist/chunks/empty--6iNLsra.js +2 -0
- package/dist/chunks/icon-paths-Dl0Rqja7.js +2 -0
- package/dist/chunks/lists-qOUpM5us.js +2 -0
- package/dist/chunks/measures-D0av_G5P.js +2 -0
- package/dist/chunks/media-DI35kQ5D.js +3 -0
- package/dist/chunks/qr-size-Dq23do6_.js +2 -0
- package/dist/chunks/ready-Boq20M-G.js +2 -0
- package/dist/chunks/share-D64VSp1B.js +2 -0
- package/dist/chunks/stat-DEE3meII.js +2 -0
- package/dist/chunks/time-KYYBrpD9.js +2 -0
- package/dist/cli.js +10 -0
- package/dist/index.js +3 -0
- package/dist/style.css +2 -0
- package/dist/types/alert.d.ts +20 -0
- package/dist/types/binds.d.ts +6 -0
- package/dist/types/chart.d.ts +16 -0
- package/dist/types/check.d.ts +31 -0
- package/dist/types/checks.d.ts +36 -0
- package/dist/types/colors.d.ts +18 -0
- package/dist/types/components.d.ts +13 -0
- package/dist/types/cycle-fit.d.ts +6 -0
- package/dist/types/data.d.ts +19 -0
- package/dist/types/empty.d.ts +6 -0
- package/dist/types/fit.d.ts +3 -0
- package/dist/types/flow.d.ts +7 -0
- package/dist/types/icon-paths.d.ts +2 -0
- package/dist/types/icon.d.ts +7 -0
- package/dist/types/icons.d.ts +3 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/lists.d.ts +29 -0
- package/dist/types/measure.d.ts +4 -0
- package/dist/types/measures.d.ts +22 -0
- package/dist/types/media.d.ts +15 -0
- package/dist/types/mount.d.ts +45 -0
- package/dist/types/parse.d.ts +11 -0
- package/dist/types/qr-size.d.ts +2 -0
- package/dist/types/ready.d.ts +3 -0
- package/dist/types/share.d.ts +33 -0
- package/dist/types/sizes.d.ts +15 -0
- package/dist/types/specs.d.ts +7 -0
- package/dist/types/stat.d.ts +38 -0
- package/dist/types/table-fit.d.ts +8 -0
- package/dist/types/table.d.ts +11 -0
- package/dist/types/time.d.ts +28 -0
- package/dist/types/trend-fit.d.ts +14 -0
- package/dist/types/type-scale.d.ts +10 -0
- package/dist/types/types.d.ts +271 -0
- package/dist/types/validate-layout.d.ts +2 -0
- package/dist/types/validate.d.ts +7 -0
- package/dist/types/version.d.ts +24 -0
- package/dist/types/views.d.ts +29 -0
- package/docs/api.md +106 -0
- package/docs/assistants.md +55 -0
- package/docs/format.md +183 -0
- package/docs/getting-started.md +77 -0
- package/docs/preview.md +84 -0
- package/examples/clinic-queue/data.json +17 -0
- package/examples/clinic-queue/layout.yml +43 -0
- package/examples/fire-alarm/data.yml +23 -0
- package/examples/fire-alarm/layout.yml +30 -0
- package/examples/gym-classes/data.yml +17 -0
- package/examples/gym-classes/layout.yml +47 -0
- package/examples/hotel-lobby/data.yml +2 -0
- package/examples/hotel-lobby/layout.yml +29 -0
- package/examples/lunch/data.yml +16 -0
- package/examples/lunch/layout.yml +43 -0
- package/examples/meeting-room/data.json +19 -0
- package/examples/meeting-room/layout.json +107 -0
- package/examples/noc-wall/data.yml +18 -0
- package/examples/noc-wall/layout.yml +63 -0
- package/examples/oee-line/data.yml +25 -0
- package/examples/oee-line/layout.yml +55 -0
- package/examples/office-air/data.yml +25 -0
- package/examples/office-air/layout.yml +71 -0
- package/examples/sales-today/data.json +28 -0
- package/examples/sales-today/layout.json +62 -0
- package/examples/snow-closure/data.yml +28 -0
- package/examples/snow-closure/layout.json +35 -0
- package/examples/station-departures/data.json +24 -0
- package/examples/station-departures/layout.json +34 -0
- package/examples/store-promo/data.yml +18 -0
- package/examples/store-promo/layout.yml +54 -0
- package/examples/storm-banner/data.json +20 -0
- package/examples/storm-banner/layout.json +33 -0
- package/examples/trading-floor/data.json +23 -0
- package/examples/trading-floor/layout.json +65 -0
- package/examples/warehouse/data.json +20 -0
- package/examples/warehouse/layout.json +50 -0
- package/package.json +100 -4
- package/schema.json +962 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const COLOR_KEYS: readonly ["background", "surface", "text", "muted", "line", "accent", "on_accent", "good", "warning", "danger"];
|
|
2
|
+
export type ColorKey = (typeof COLOR_KEYS)[number];
|
|
3
|
+
export type Scheme = 'dark' | 'light';
|
|
4
|
+
export type Palette = Record<ColorKey, string>;
|
|
5
|
+
export type Colors = Partial<Palette> & {
|
|
6
|
+
scheme?: Scheme;
|
|
7
|
+
};
|
|
8
|
+
export declare const SCHEMES: Record<Scheme, Omit<Palette, 'accent' | 'on_accent'>>;
|
|
9
|
+
export declare const SERIES: Record<Scheme, string[]>;
|
|
10
|
+
export declare const HEX: RegExp;
|
|
11
|
+
/** WCAG contrast ratio, from 1 to 21. */
|
|
12
|
+
export declare function contrast(a: string, b: string): number;
|
|
13
|
+
export declare function resolveColors(colors: Colors | undefined, fallbackScheme: Scheme, fallbackAccent: string): Palette;
|
|
14
|
+
/** White or near-black, whichever reads better on a state fill. */
|
|
15
|
+
export declare function inkOn(fill: string): string;
|
|
16
|
+
export declare function contrastWarnings(p: Palette): string[];
|
|
17
|
+
/** Applies the palette as CSS variables, plus the chart series for its scheme. */
|
|
18
|
+
export declare function applyColors(p: Palette, target?: HTMLElement): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from 'preact';
|
|
2
|
+
import type { Alert, Component, Data, GridLayout } from './types';
|
|
3
|
+
export declare function gridStyle(l: GridLayout): Record<string, string>;
|
|
4
|
+
export declare function Screen({ zones, layout, data, alert, }: {
|
|
5
|
+
zones: Record<string, Component>;
|
|
6
|
+
layout: GridLayout;
|
|
7
|
+
data: Data;
|
|
8
|
+
alert?: Alert;
|
|
9
|
+
}): JSX.Element;
|
|
10
|
+
export declare function Problems({ errors, warnings, }: {
|
|
11
|
+
errors: string[];
|
|
12
|
+
warnings: string[];
|
|
13
|
+
}): JSX.Element | null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sizes a cycle to its longest message, so the size never jumps between
|
|
3
|
+
* messages. One line suits a banner; a tall, narrow zone wraps instead,
|
|
4
|
+
* whichever lets the text be larger.
|
|
5
|
+
*/
|
|
6
|
+
export declare function fitMessages(el: HTMLElement, messages: string[]): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Data, Value } from './types';
|
|
2
|
+
/** Reads "/menu/0/price" from the data. Missing paths give undefined. */
|
|
3
|
+
export declare function getPath(data: unknown, path: string): unknown;
|
|
4
|
+
export declare function isBind(v: unknown): v is {
|
|
5
|
+
bind: string;
|
|
6
|
+
fallback?: string | number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a value to display text. A bind that is missing or empty in the
|
|
10
|
+
* data shows its `fallback`; without one it resolves to "" and the component
|
|
11
|
+
* shows its own empty state.
|
|
12
|
+
*/
|
|
13
|
+
export declare function text(v: Value | undefined, data: Data): string;
|
|
14
|
+
/** Resolves a value that should be a list, literal or bound. */
|
|
15
|
+
export declare function items<T>(v: T[] | {
|
|
16
|
+
bind: string;
|
|
17
|
+
}, data: Data): unknown[];
|
|
18
|
+
/** Deep merge: objects merge key by key, arrays and values are replaced. */
|
|
19
|
+
export declare function merge(base: unknown, over: unknown): unknown;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Stands in for a missing single value: a stat, a meter, a table cell. */
|
|
2
|
+
export declare const DASH = "\u2014";
|
|
3
|
+
/** Shown instead of an empty list, table, chart or image. */
|
|
4
|
+
export declare function Empty({ text }: {
|
|
5
|
+
text?: string;
|
|
6
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FlowLayout, GridLayout, Layout } from './types';
|
|
2
|
+
export declare const COLUMNS = 12;
|
|
3
|
+
/** Reference canvas: 1080 px on the short side, the long side follows the screen. */
|
|
4
|
+
export declare function canvasSize(viewW: number, viewH: number): [number, number];
|
|
5
|
+
export declare const isFlow: (l: Layout) => l is FlowLayout;
|
|
6
|
+
export declare function flowGrid(l: FlowLayout, width: number): GridLayout;
|
|
7
|
+
export declare function toGrid(l: Layout, width: number): GridLayout;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IconName } from './icons';
|
|
2
|
+
export declare function loadIcons(): Promise<Record<string, string>>;
|
|
3
|
+
/** A named icon from the set in icons.ts, drawn in the current text color. */
|
|
4
|
+
export declare function Icon({ name, cls }: {
|
|
5
|
+
name: IconName;
|
|
6
|
+
cls?: string;
|
|
7
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const ICON_NAMES: readonly ["info", "check", "warning", "danger", "fire", "evacuate", "assembly", "medical", "first-aid", "storm", "wind", "snow", "flood", "heat", "lockdown", "shelter", "security", "power", "water", "network", "closed", "delay", "maintenance", "announcement", "phone", "biohazard", "radiation", "chemical", "event", "location", "accessibility"];
|
|
2
|
+
export type IconName = (typeof ICON_NAMES)[number];
|
|
3
|
+
export declare const isIcon: (v: unknown) => v is IconName;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
export { mount } from './mount';
|
|
3
|
+
export type { MountOptions, ScreenHandle, Update } from './mount';
|
|
4
|
+
export { check } from './check';
|
|
5
|
+
export type { CheckOptions, CheckResult, Source } from './check';
|
|
6
|
+
export { validate } from './validate';
|
|
7
|
+
export type { Result as ValidateResult } from './validate';
|
|
8
|
+
export { canvasSize } from './flow';
|
|
9
|
+
export { COLOR_KEYS, SCHEMES } from './colors';
|
|
10
|
+
export type { ColorKey, Colors, Palette, Scheme } from './colors';
|
|
11
|
+
export { ICON_NAMES } from './icons';
|
|
12
|
+
export type { IconName } from './icons';
|
|
13
|
+
export { LEVELS } from './alert';
|
|
14
|
+
export type { Level } from './alert';
|
|
15
|
+
export type * from './types';
|
|
16
|
+
export { pack, previewUrl, unpack, PREVIEW_BASE } from './share';
|
|
17
|
+
export type { PreviewOptions, Shared } from './share';
|
|
18
|
+
export { FORMAT } from './version';
|
|
19
|
+
export { DEFAULT_SIZES, parseSize, SIZES } from './sizes';
|
|
20
|
+
export type { Size } from './sizes';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type TimeOptions } from './time';
|
|
2
|
+
import type { Clocks, Data, Queue, Schedule, Status } from './types';
|
|
3
|
+
export declare function StatusView({ c, data }: {
|
|
4
|
+
c: Status;
|
|
5
|
+
data: Data;
|
|
6
|
+
}): import("preact").JSX.Element;
|
|
7
|
+
export interface Entry {
|
|
8
|
+
start: string;
|
|
9
|
+
title: string;
|
|
10
|
+
detail: string;
|
|
11
|
+
tag: 'now' | 'next' | '';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Entries from the current one onward. An entry ends at its `end`, else when
|
|
15
|
+
* the next later entry of the same kind starts, else an hour after it starts.
|
|
16
|
+
*/
|
|
17
|
+
export declare function upcoming(raw: unknown[], data: Data, now: Date, limit: number, time?: TimeOptions): Entry[];
|
|
18
|
+
export declare function ScheduleView({ c, data }: {
|
|
19
|
+
c: Schedule;
|
|
20
|
+
data: Data;
|
|
21
|
+
}): import("preact").JSX.Element;
|
|
22
|
+
export declare function QueueView({ c, data }: {
|
|
23
|
+
c: Queue;
|
|
24
|
+
data: Data;
|
|
25
|
+
}): import("preact").JSX.Element;
|
|
26
|
+
export declare function ClocksView({ c, data }: {
|
|
27
|
+
c: Clocks;
|
|
28
|
+
data: Data;
|
|
29
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Bars, Data, Meter, Meters, Split } from './types';
|
|
2
|
+
export declare function MeterView({ c, data }: {
|
|
3
|
+
c: Meter;
|
|
4
|
+
data: Data;
|
|
5
|
+
}): import("preact").JSX.Element;
|
|
6
|
+
export declare function MetersView({ c, data }: {
|
|
7
|
+
c: Meters;
|
|
8
|
+
data: Data;
|
|
9
|
+
}): import("preact").JSX.Element;
|
|
10
|
+
/** Ranked bars, largest first, all against the largest value. */
|
|
11
|
+
export declare function BarsView({ c, data }: {
|
|
12
|
+
c: Bars;
|
|
13
|
+
data: Data;
|
|
14
|
+
}): import("preact").JSX.Element;
|
|
15
|
+
/**
|
|
16
|
+
* One whole split into parts. Each block prints its share when it is wide
|
|
17
|
+
* enough; the legend repeats name and share, so no value is lost.
|
|
18
|
+
*/
|
|
19
|
+
export declare function SplitView({ c, data }: {
|
|
20
|
+
c: Split;
|
|
21
|
+
data: Data;
|
|
22
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Data, Qr, Slideshow } from './types';
|
|
2
|
+
/** Swaps images instantly on a timer and preloads the next one. */
|
|
3
|
+
export declare function SlideshowView({ c, data }: {
|
|
4
|
+
c: Slideshow;
|
|
5
|
+
data: Data;
|
|
6
|
+
}): import("preact").JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* One SVG path for all dark modules, with a four-module quiet zone. Always
|
|
9
|
+
* black on white: many phone scanners fail on inverted codes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function qrPath(grid: boolean[][]): string;
|
|
12
|
+
export declare function QrView({ c, data }: {
|
|
13
|
+
c: Qr;
|
|
14
|
+
data: Data;
|
|
15
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Source } from './check';
|
|
2
|
+
import { type Colors, type Scheme } from './colors';
|
|
3
|
+
export interface MountOptions {
|
|
4
|
+
/** The screen document: JSON or YAML text, or a parsed object. */
|
|
5
|
+
layout: Source;
|
|
6
|
+
/** Values that binds read: JSON or YAML text, or an object. */
|
|
7
|
+
data?: Source;
|
|
8
|
+
/** Scheme used when the document doesn't set one. Default dark. */
|
|
9
|
+
scheme?: Scheme;
|
|
10
|
+
/** Accent used when the document doesn't set one. Default #2563eb. */
|
|
11
|
+
accent?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Colors that win over the document's own, like `{ scheme: 'light' }` to
|
|
14
|
+
* see a screen in the other scheme.
|
|
15
|
+
*/
|
|
16
|
+
colors?: Colors;
|
|
17
|
+
/** IANA time zone for clocks and schedules. Default the device's. */
|
|
18
|
+
timeZone?: string;
|
|
19
|
+
/** BCP 47 locale for dates and times. Default the device's. */
|
|
20
|
+
locale?: string;
|
|
21
|
+
/** Show errors and warnings over the screen. Default false. */
|
|
22
|
+
showProblems?: boolean;
|
|
23
|
+
/** Freezes the clock at this time, for screenshots and tests. */
|
|
24
|
+
now?: Date;
|
|
25
|
+
}
|
|
26
|
+
export interface Update {
|
|
27
|
+
layout?: Source;
|
|
28
|
+
data?: Source;
|
|
29
|
+
}
|
|
30
|
+
export interface ScreenHandle {
|
|
31
|
+
/** Errors from the last check, plus any reported with report(). */
|
|
32
|
+
readonly errors: string[];
|
|
33
|
+
readonly warnings: string[];
|
|
34
|
+
/** Replaces the layout, the data or both, and renders again. */
|
|
35
|
+
update(changes: Update): Promise<void>;
|
|
36
|
+
/** Adds an error, shown over the screen when showProblems is on. */
|
|
37
|
+
report(message: string): void;
|
|
38
|
+
/** Stops watching the element's size and removes the screen. */
|
|
39
|
+
destroy(): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Renders a screen document into `container` and resolves once it is drawn,
|
|
43
|
+
* charts included. The container sets the size; the screen fills it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function mount(container: HTMLElement, options: MountOptions): Promise<ScreenHandle>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Parsed {
|
|
2
|
+
value: unknown;
|
|
3
|
+
error?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* `layout` uses the YAML core schema, so `fit: true` and `gap: 24` keep their
|
|
7
|
+
* types. `data` uses the failsafe schema, which reads every scalar as a
|
|
8
|
+
* string: a price written as 4.50 stays "4.50" instead of becoming 4.5.
|
|
9
|
+
*/
|
|
10
|
+
export type Mode = 'layout' | 'data';
|
|
11
|
+
export declare function parseText(src: string, mode: Mode): Promise<Parsed>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const PREVIEW_BASE = "https://signagekit.514sid.com/preview/";
|
|
2
|
+
export interface PreviewOptions {
|
|
3
|
+
/** `screen` (default), `sizes`, `schemes` or `edit`. */
|
|
4
|
+
mode?: 'screen' | 'sizes' | 'schemes' | 'edit';
|
|
5
|
+
/**
|
|
6
|
+
* Resolution: a name like `fullhd` or `portrait`, or `WIDTHxHEIGHT`. One
|
|
7
|
+
* for `screen` and `schemes`, a list for `sizes`.
|
|
8
|
+
*/
|
|
9
|
+
size?: string | string[];
|
|
10
|
+
scheme?: 'dark' | 'light';
|
|
11
|
+
accent?: string;
|
|
12
|
+
timeZone?: string;
|
|
13
|
+
locale?: string;
|
|
14
|
+
/** Show errors and warnings over the screen. */
|
|
15
|
+
problems?: boolean;
|
|
16
|
+
/** Freeze the clock at this ISO time, like 2026-11-14T09:30. */
|
|
17
|
+
now?: string;
|
|
18
|
+
/** Preview page to link to. Default the public site. */
|
|
19
|
+
base?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Shared {
|
|
22
|
+
layout: string;
|
|
23
|
+
data?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Packs layout and data text into the `s` value of a preview link. */
|
|
26
|
+
export declare function pack(shared: Shared): Promise<string>;
|
|
27
|
+
/** Reverses pack(). Throws on a damaged value. */
|
|
28
|
+
export declare function unpack(s: string): Promise<Shared>;
|
|
29
|
+
/**
|
|
30
|
+
* A link to the preview page showing this layout and data. Pass the text as
|
|
31
|
+
* written, JSON or YAML, or objects, which are sent as JSON.
|
|
32
|
+
*/
|
|
33
|
+
export declare function previewUrl(layout: string | object, data?: string | object, options?: PreviewOptions): Promise<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Size {
|
|
2
|
+
name: string;
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
/** Every named resolution, keyed by name. */
|
|
8
|
+
export declare const SIZES: Record<string, Size>;
|
|
9
|
+
/** The sizes the preview compares when none are given. */
|
|
10
|
+
export declare const DEFAULT_SIZES: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Reads `fullhd`, `1080p` or `1366x768` (also `1366×768`). Returns null for
|
|
13
|
+
* anything else, or for sizes under 64 or over 16384 px.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseSize(text: string): Size | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Component, Data, Stat as StatSpec, Thresholds, Value } from './types';
|
|
2
|
+
type Props = {
|
|
3
|
+
c: StatSpec;
|
|
4
|
+
data: Data;
|
|
5
|
+
};
|
|
6
|
+
export declare const STATE_WORDS: Record<string, string>;
|
|
7
|
+
/** good, warning or danger; anything else, unknown included, is neutral. */
|
|
8
|
+
export declare function stateText(v: Value | undefined, data: Data): string;
|
|
9
|
+
/**
|
|
10
|
+
* A state from thresholds: past danger is danger, past warning is warning,
|
|
11
|
+
* anything else neutral. With danger below warning, lower values are worse.
|
|
12
|
+
*/
|
|
13
|
+
export declare function thresholdState(n: number, t: Thresholds | undefined): string;
|
|
14
|
+
/**
|
|
15
|
+
* The state that marks a whole zone. Only stats and meters set one: an
|
|
16
|
+
* explicit `state` wins, else `thresholds` decide from the value.
|
|
17
|
+
*/
|
|
18
|
+
export declare function stateOf(c: Component, data: Data): string;
|
|
19
|
+
export declare function StateIcon({ state }: {
|
|
20
|
+
state: string;
|
|
21
|
+
}): import("preact").JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* up, down or flat, or none. With good_when set, a move that way is good
|
|
24
|
+
* (green) and the opposite is bad (red); without it the arrow stays neutral,
|
|
25
|
+
* since a rising number is not always good news.
|
|
26
|
+
*/
|
|
27
|
+
export declare function trendOf(c: StatSpec, data: Data): {
|
|
28
|
+
dir: string;
|
|
29
|
+
tone: string;
|
|
30
|
+
} | null;
|
|
31
|
+
/**
|
|
32
|
+
* Numbers of 10,000 and up are shortened (1M, 12.9K) unless format is full,
|
|
33
|
+
* so a big value doesn't shrink every stat in its row. Smaller numbers get
|
|
34
|
+
* thousands separators; text that isn't a number is shown as written.
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatValue(raw: string, format?: 'compact' | 'full'): string;
|
|
37
|
+
export declare function Stat({ c, data }: Props): import("preact").JSX.Element;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function tableOverflow(el: HTMLElement): void;
|
|
2
|
+
/**
|
|
3
|
+
* Shows every row a table could show at once, all of them or the first
|
|
4
|
+
* page_rows, and hides its pager, so fitting and paging measure the same
|
|
5
|
+
* content on every pass. Returns a function that hands rows back to the
|
|
6
|
+
* table's own paging.
|
|
7
|
+
*/
|
|
8
|
+
export declare function showAllRows(root: ParentNode): () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Data, Table as TableSpec } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A table that sizes its text to fit. Rows that don't fit at a readable size
|
|
4
|
+
* are shown a page at a time, flipping instantly; page_rows caps the page
|
|
5
|
+
* size by hand. Rows off the page are collapsed, not removed, so column widths
|
|
6
|
+
* stay the same on every page and nothing jumps.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Table({ c, data }: {
|
|
9
|
+
c: TableSpec;
|
|
10
|
+
data: Data;
|
|
11
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type Listener = (now: Date) => void;
|
|
2
|
+
export declare function onMinute(fn: Listener): () => void;
|
|
3
|
+
/**
|
|
4
|
+
* Time zone, locale and an optional frozen clock for one mounted screen.
|
|
5
|
+
* Each mount() provides its own, so screens on one page don't share them.
|
|
6
|
+
*/
|
|
7
|
+
export interface TimeOptions {
|
|
8
|
+
timeZone?: string;
|
|
9
|
+
locale?: string;
|
|
10
|
+
/**
|
|
11
|
+
* A fixed time stops the clock, so screenshots of clocks, schedules and
|
|
12
|
+
* countdowns come out the same on every run.
|
|
13
|
+
*/
|
|
14
|
+
now?: Date;
|
|
15
|
+
}
|
|
16
|
+
export declare const TimeContext: import("preact").Context<TimeOptions>;
|
|
17
|
+
export declare const useTimeOptions: () => TimeOptions;
|
|
18
|
+
/** The current time, updated each minute, or the screen's fixed time. */
|
|
19
|
+
export declare function useMinute(): Date;
|
|
20
|
+
/** The time in another zone, for world clocks. */
|
|
21
|
+
export declare function formatClockIn(now: Date, zone: string, hour12: boolean | undefined, t?: TimeOptions): string;
|
|
22
|
+
/** Minutes since midnight on the screen's clock, for "HH:MM" schedules. */
|
|
23
|
+
export declare function minutesOfDay(now: Date, t?: TimeOptions): number;
|
|
24
|
+
export declare function formatClock(now: Date, hour12: boolean | undefined, t?: TimeOptions): string;
|
|
25
|
+
export declare function formatDate(now: Date, t?: TimeOptions): string;
|
|
26
|
+
/** "3 d 4 h", "4 h 12 min", "12 min", or "" once the time has passed. */
|
|
27
|
+
export declare function formatCountdown(to: Date, now: Date): string;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fits a stat in each arrangement it can take, using `fitLine`, which returns
|
|
3
|
+
* the size the element fits at as it stands, or less than `floor` by how far
|
|
4
|
+
* it is from fitting at all. Leaves the best one in place
|
|
5
|
+
* and remembers every size for the row pass. Returns false when there is
|
|
6
|
+
* nothing to choose, so the caller fits the stat normally.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fitTrend(el: HTMLElement, fitLine: () => number, floor: number): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Picks one arrangement for a row of figures: the one whose smallest size is
|
|
11
|
+
* largest. A stat that can't take an arrangement keeps its own nearest one.
|
|
12
|
+
* Returns the size the row shares.
|
|
13
|
+
*/
|
|
14
|
+
export declare function alignTrends(group: HTMLElement[], sizeOf: (el: HTMLElement) => number, floor?: number): number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const RANGES: Record<string, [number, number]>;
|
|
2
|
+
/** The type scale every fitted size snaps down to. */
|
|
3
|
+
export declare const STEPS: number[];
|
|
4
|
+
/** Components made of rows; they share one body size across the screen. */
|
|
5
|
+
export declare const BODY: string[];
|
|
6
|
+
/** Display text kept within this many times the body size. */
|
|
7
|
+
export declare const DISPLAY: string[];
|
|
8
|
+
export declare const DISPLAY_RATIO = 3.5;
|
|
9
|
+
/** List-like components may grow this much past the shared body size. */
|
|
10
|
+
export declare const BODY_SPREAD = 1.4;
|