@zumer/orbit 1.6.0 → 2.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.
@@ -0,0 +1,107 @@
1
+ /** Ending of an arc or progress band. */
2
+ export type OrbitShape =
3
+ | 'none'
4
+ | 'rounded'
5
+ | 'circle'
6
+ | 'circle-a'
7
+ | 'circle-b'
8
+ | 'bullet'
9
+ | 'arrow'
10
+ | 'slash'
11
+ | 'backslash'
12
+ | 'zigzag';
13
+
14
+ type Numeric = number | `${number}`;
15
+ type BooleanAttribute = boolean | '' | undefined;
16
+
17
+ /** Attributes of `<o-arc>`. */
18
+ export interface OrbitArcAttributes {
19
+ /** Share of the ring's range, relative to `max`. Without it, sibling arcs split the range equally. */
20
+ value?: Numeric;
21
+ /** Value that fills the whole range. Default `100`. */
22
+ max?: Numeric;
23
+ shape?: OrbitShape;
24
+ /**
25
+ * Where curved text sits on the arc. Default `middle`.
26
+ * With `range="auto"`, an explicit value also anchors the arc at its angle:
27
+ * `middle` centers it there, `end` ends it there.
28
+ */
29
+ 'text-anchor'?: 'start' | 'middle' | 'end';
30
+ /** Reverse the direction of curved text. */
31
+ flip?: BooleanAttribute;
32
+ /** Squeeze curved text to the length of the arc. */
33
+ 'fit-range'?: BooleanAttribute;
34
+ /** Size the arc to its text. Consecutive `range="auto"` arcs follow each other. */
35
+ range?: 'auto';
36
+ /** Let the band receive pointer events, even where it is transparent. Arcs are decorative by default. */
37
+ interactive?: BooleanAttribute;
38
+ /** Extra touch area in px on each side of an interactive band. */
39
+ 'hit-width'?: Numeric;
40
+ }
41
+
42
+ /** Attributes of `<o-progress>`. */
43
+ export interface OrbitProgressAttributes {
44
+ /** Progress relative to `max`. `--o-progress` overrides it. */
45
+ value?: Numeric;
46
+ /** Value that fills the whole range. Default `100`. */
47
+ max?: Numeric;
48
+ shape?: OrbitShape;
49
+ /** `stroke` draws open lines colored by `--o-stroke` and `--o-back-stroke`. */
50
+ variant?: 'stroke';
51
+ /** Let the whole track receive pointer events, whatever its colors. Progress is decorative by default. */
52
+ interactive?: BooleanAttribute;
53
+ /** Extra touch area in px on each side of an interactive track. */
54
+ 'hit-width'?: Numeric;
55
+ }
56
+
57
+ export declare class OrbitArc extends HTMLElement {
58
+ /** Mirrors the `value` attribute; null when it is not set. Setting it redraws. */
59
+ value: number | null;
60
+ /** Mirrors the `max` attribute (default 100). Setting it redraws. */
61
+ max: number;
62
+ /** Redraw now. The runtime calls this when the arc or its layout changes. */
63
+ update(): void;
64
+ }
65
+
66
+ export declare class OrbitProgress extends HTMLElement {
67
+ /** Mirrors the `value` attribute; null when it is not set. Setting it redraws. */
68
+ value: number | null;
69
+ /** Mirrors the `max` attribute (default 100). Setting it redraws. */
70
+ max: number;
71
+ /** Redraw now. The runtime calls this when the progress or its layout changes. */
72
+ update(): void;
73
+ }
74
+
75
+ export interface OrbitApi {
76
+ /** Update layouts now, after changes Orbit cannot observe (for example CSSOM edits). Defaults to the document. */
77
+ refresh(root?: Element | Document | ShadowRoot): void;
78
+ /**
79
+ * Resolves when pending layouts of `root` (default: the document) are drawn.
80
+ * Each `<o-arc>` and `<o-progress>` also fires a bubbling `o-rendered` event after it redraws.
81
+ */
82
+ ready(root?: Element | Document | ShadowRoot): Promise<void>;
83
+ /**
84
+ * Scale systems that set a fixed px `--o-force` with a container's width (500px = 1).
85
+ * Not needed for the default `--o-force`, which follows its `.bigbang`.
86
+ * Returns a function that stops observing.
87
+ */
88
+ resize(target: string | Element): () => void;
89
+ }
90
+
91
+ export declare const Orbit: OrbitApi;
92
+
93
+ /** Define `<o-arc>` and `<o-progress>`. Runs on import; repeated calls are safe. */
94
+ export declare function registerOrbit(): void;
95
+
96
+ declare global {
97
+ interface HTMLElementTagNameMap {
98
+ 'o-arc': OrbitArc;
99
+ 'o-progress': OrbitProgress;
100
+ }
101
+ interface Window {
102
+ Orbit: OrbitApi;
103
+ }
104
+ interface HTMLElementEventMap {
105
+ 'o-rendered': Event;
106
+ }
107
+ }