@ohmygame/plugin-ui 0.0.0-stage → 2.3.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,518 @@
1
+ // Generated by scripts/plugin-ui-contract.ts from the components' doc comments; run `bun run plugin-ui:contract` after changing them.
2
+
3
+ /** `<omg-button variant="secondary|primary|ghost|danger" disabled busy>`: the app's button. Primary is ink; there is one per view. A busy button shows a spinner and takes no clicks. */
4
+ export interface OmgButtonElement extends HTMLElement {
5
+ /** The `busy` attribute. */
6
+ busy: boolean;
7
+ /** The `disabled` attribute. */
8
+ disabled: boolean;
9
+ }
10
+
11
+ /** The attributes of `<omg-button>`, as a page writes them. */
12
+ export interface OmgButtonAttributes {
13
+ /** Shows a spinner and takes no clicks. */
14
+ busy?: boolean;
15
+ /** Takes no clicks. */
16
+ disabled?: boolean;
17
+ /** Secondary by default. */
18
+ variant?: "secondary" | "primary" | "ghost" | "danger";
19
+ }
20
+
21
+ /** `<omg-command-button command input variant concurrent quiet>`: runs one of the plugin's commands, by its manifest id, when clicked. `input` is JSON, or set the `input` property. While it runs, the button is busy and shows the command's progress beside it, and other command buttons wait unless they are `concurrent`. A failure shows beside it unless it is `quiet`, and is its `error` attribute until the next run, so a page that draws the button again can pass it on. Events: `omg-command-start` (cancelable, before it runs), `omg-command-result` with `detail.result`, and `omg-command-error` with `detail.error`, cancelable to show the failure yourself. */
22
+ export interface OmgCommandButtonElement extends OmgButtonElement {
23
+ /** The command's input; it takes the place of the attribute. */
24
+ input: unknown;
25
+ /** Runs the command, as a click does; resolves to its result, or undefined when it didn't run or failed. */
26
+ run(): Promise<unknown>;
27
+ }
28
+
29
+ /** The attributes of `<omg-command-button>`, as a page writes them. */
30
+ export interface OmgCommandButtonAttributes {
31
+ /** Shows a spinner and takes no clicks. */
32
+ busy?: boolean;
33
+ /** The command's id in the manifest. */
34
+ command?: string;
35
+ /** Runs while other command buttons run, and doesn't make them wait. */
36
+ concurrent?: boolean;
37
+ /** Takes no clicks. */
38
+ disabled?: boolean;
39
+ /** The last run's failure, until the next run. */
40
+ error?: string;
41
+ /** The command's input, as JSON. */
42
+ input?: string;
43
+ /** Doesn't show a failure beside it. */
44
+ quiet?: boolean;
45
+ /** Secondary by default. */
46
+ variant?: "secondary" | "primary" | "ghost" | "danger";
47
+ }
48
+
49
+ /** `<omg-status tone="neutral|good|warning|bad|busy">`: a short state, such as "Running", after a coloured dot, or a spinner while busy. It is a live region, so a change is read out. */
50
+ export interface OmgStatusElement extends HTMLElement {}
51
+
52
+ /** The attributes of `<omg-status>`, as a page writes them. */
53
+ export interface OmgStatusAttributes {
54
+ /** Neutral by default. */
55
+ tone?: "neutral" | "good" | "warning" | "bad" | "busy";
56
+ }
57
+
58
+ /** `<omg-banner tone="info|good|warning|bad" heading>`: a message across the page, such as a failure and what to do about it. Slots: the message, and `actions`. A `bad` banner is an alert; the others are a status. */
59
+ export interface OmgBannerElement extends HTMLElement {}
60
+
61
+ /** The attributes of `<omg-banner>`, as a page writes them. */
62
+ export interface OmgBannerAttributes {
63
+ /** A title above the message. */
64
+ heading?: string;
65
+ /** Plain by default. */
66
+ tone?: "info" | "good" | "warning" | "bad";
67
+ }
68
+
69
+ /** `<omg-log empty="No lines yet." follow>`: lines of output in the app's monospace type, scrolling past `--omg-log-height` (280px). Its text is its content, or set `text`. With `follow`, it keeps the latest line in view unless the person scrolled up. */
70
+ export interface OmgLogElement extends HTMLElement {
71
+ /** Its lines. */
72
+ text: string;
73
+ }
74
+
75
+ /** The attributes of `<omg-log>`, as a page writes them. */
76
+ export interface OmgLogAttributes {
77
+ /** What it says with no lines. */
78
+ empty?: string;
79
+ /** Keeps the latest line in view. */
80
+ follow?: boolean;
81
+ }
82
+
83
+ /** `<omg-steps>`: the steps of a flow, numbered in order. Each is an `<omg-step heading state="pending|current|done|error" open>`; a current or failed step shows its content, and `open` shows it in any state. Slots of a step: `summary`, always shown under its heading, and its content. */
84
+ export interface OmgStepsElement extends HTMLElement {}
85
+
86
+ /** The attributes of `<omg-steps>`, as a page writes them. */
87
+ export interface OmgStepsAttributes {
88
+ }
89
+
90
+ /** `<omg-step heading state open>`: one step of an `omg-steps` flow. */
91
+ export interface OmgStepElement extends HTMLElement {}
92
+
93
+ /** The attributes of `<omg-step>`, as a page writes them. */
94
+ export interface OmgStepAttributes {
95
+ /** What the step does. */
96
+ heading?: string;
97
+ /** Its place in the flow, which `omg-steps` sets. */
98
+ number?: string;
99
+ /** Shows its content in any state. */
100
+ open?: boolean;
101
+ /** Pending by default. */
102
+ state?: "pending" | "current" | "done" | "error";
103
+ }
104
+
105
+ /** `<omg-badge tone>`: a short label for what something is or how it stands. */
106
+ export interface OmgBadgeElement extends HTMLElement {}
107
+
108
+ /** The attributes of `<omg-badge>`, as a page writes them. */
109
+ export interface OmgBadgeAttributes {
110
+ /** Its colour; neutral by default. */
111
+ tone?: "neutral" | "info" | "good" | "warning" | "bad";
112
+ }
113
+
114
+ /** `<omg-progress value max label>`: how far something has got, or a moving bar while nobody knows yet. */
115
+ export interface OmgProgressElement extends HTMLElement {}
116
+
117
+ /** The attributes of `<omg-progress>`, as a page writes them. */
118
+ export interface OmgProgressAttributes {
119
+ /** What is in progress, above the bar and for screen readers. */
120
+ label?: string;
121
+ /** What finished means; 100 by default. */
122
+ max?: number;
123
+ /** How far it has got; without one, the bar just moves. */
124
+ value?: number;
125
+ }
126
+
127
+ /** `<omg-input label value type placeholder hint error>`: one line of text. */
128
+ export interface OmgInputElement extends HTMLElement {
129
+ /** Its text. */
130
+ value: string;
131
+ }
132
+
133
+ /** The attributes of `<omg-input>`, as a page writes them. */
134
+ export interface OmgInputAttributes {
135
+ /** Its name, without a label. */
136
+ "aria-label"?: string;
137
+ /** Can't be changed. */
138
+ disabled?: boolean;
139
+ /** What's wrong with its value. */
140
+ error?: string;
141
+ /** A line under it; an error takes its place. */
142
+ hint?: string;
143
+ /** Shown with it. */
144
+ label?: string;
145
+ /** Shown while it is empty. */
146
+ placeholder?: string;
147
+ /** Can be read and copied, not changed. */
148
+ readonly?: boolean;
149
+ /** What it holds; text by default. */
150
+ type?: "text" | "search" | "password" | "number" | "email" | "url";
151
+ /** Its text; setting it replaces what was typed. */
152
+ value?: string;
153
+ }
154
+
155
+ /** `<omg-textarea label value rows placeholder hint error>`: several lines of text. */
156
+ export interface OmgTextareaElement extends HTMLElement {
157
+ /** Its text. */
158
+ value: string;
159
+ }
160
+
161
+ /** The attributes of `<omg-textarea>`, as a page writes them. */
162
+ export interface OmgTextareaAttributes {
163
+ /** Its name, without a label. */
164
+ "aria-label"?: string;
165
+ /** Can't be changed. */
166
+ disabled?: boolean;
167
+ /** What's wrong with its value. */
168
+ error?: string;
169
+ /** A line under it; an error takes its place. */
170
+ hint?: string;
171
+ /** Shown with it. */
172
+ label?: string;
173
+ /** Shown while it is empty. */
174
+ placeholder?: string;
175
+ /** Can be read and copied, not changed. */
176
+ readonly?: boolean;
177
+ /** How many lines it shows; 3 by default. */
178
+ rows?: number;
179
+ /** Its text; setting it replaces what was typed. */
180
+ value?: string;
181
+ }
182
+
183
+ /** `<omg-switch label checked hint>`: turns a setting on or off at once, with its label at the row's start and the switch at its end. */
184
+ export interface OmgSwitchElement extends HTMLElement {
185
+ /** It is on. */
186
+ checked: boolean;
187
+ }
188
+
189
+ /** The attributes of `<omg-switch>`, as a page writes them. */
190
+ export interface OmgSwitchAttributes {
191
+ /** Its name, without a label. */
192
+ "aria-label"?: string;
193
+ /** It is on. */
194
+ checked?: boolean;
195
+ /** Can't be changed. */
196
+ disabled?: boolean;
197
+ /** What's wrong with its value. */
198
+ error?: string;
199
+ /** A line under it; an error takes its place. */
200
+ hint?: string;
201
+ /** Shown with it. */
202
+ label?: string;
203
+ }
204
+
205
+ /** `<omg-checkbox label checked hint>`: a choice that takes effect with the rest of a form, with the box before its label. */
206
+ export interface OmgCheckboxElement extends HTMLElement {
207
+ /** It is on. */
208
+ checked: boolean;
209
+ }
210
+
211
+ /** The attributes of `<omg-checkbox>`, as a page writes them. */
212
+ export interface OmgCheckboxAttributes {
213
+ /** Its name, without a label. */
214
+ "aria-label"?: string;
215
+ /** It is on. */
216
+ checked?: boolean;
217
+ /** Can't be changed. */
218
+ disabled?: boolean;
219
+ /** What's wrong with its value. */
220
+ error?: string;
221
+ /** A line under it; an error takes its place. */
222
+ hint?: string;
223
+ /** Shown with it. */
224
+ label?: string;
225
+ }
226
+
227
+ /** `<omg-select label value hint error disabled>` with `<option>` children: the app's dropdown. Its list stays inside the panel and scrolls. */
228
+ export interface OmgSelectElement extends HTMLElement {
229
+ /** The chosen option's value. */
230
+ value: string;
231
+ }
232
+
233
+ /** The attributes of `<omg-select>`, as a page writes them. */
234
+ export interface OmgSelectAttributes {
235
+ /** Its name, without a label. */
236
+ "aria-label"?: string;
237
+ /** Can't be changed. */
238
+ disabled?: boolean;
239
+ /** What's wrong with its value. */
240
+ error?: string;
241
+ /** A line under it; an error takes its place. */
242
+ hint?: string;
243
+ /** Shown with it. */
244
+ label?: string;
245
+ /** The chosen option's value. */
246
+ value?: string;
247
+ }
248
+
249
+ /** `<omg-segmented label value hint error disabled>` with `<option>` children: a few choices side by side, all in view. Arrow keys move between them. */
250
+ export interface OmgSegmentedElement extends HTMLElement {
251
+ /** The chosen option's value. */
252
+ value: string;
253
+ }
254
+
255
+ /** The attributes of `<omg-segmented>`, as a page writes them. */
256
+ export interface OmgSegmentedAttributes {
257
+ /** Its name, without a label. */
258
+ "aria-label"?: string;
259
+ /** Can't be changed. */
260
+ disabled?: boolean;
261
+ /** What's wrong with its value. */
262
+ error?: string;
263
+ /** A line under it; an error takes its place. */
264
+ hint?: string;
265
+ /** Shown with it. */
266
+ label?: string;
267
+ /** The chosen option's value. */
268
+ value?: string;
269
+ }
270
+
271
+ /** `<omg-page heading description wide>`: the page's column, centred and at most 720px wide, or the panel's whole width when `wide`. Slots: `brand` (a logo before the heading), `actions`, and the page's sections. */
272
+ export interface OmgPageElement extends HTMLElement {}
273
+
274
+ /** The attributes of `<omg-page>`, as a page writes them. */
275
+ export interface OmgPageAttributes {
276
+ /** A line under the title. */
277
+ description?: string;
278
+ /** The page's title. */
279
+ heading?: string;
280
+ /** Fills the panel's width, for a page with a sidebar or a grid. */
281
+ wide?: boolean;
282
+ }
283
+
284
+ /** `<omg-section heading description>`: a titled group of content. Slots: `actions` beside the heading, and the section's content. */
285
+ export interface OmgSectionElement extends HTMLElement {}
286
+
287
+ /** The attributes of `<omg-section>`, as a page writes them. */
288
+ export interface OmgSectionAttributes {
289
+ /** A line under the title. */
290
+ description?: string;
291
+ /** The section's title, which names it. */
292
+ heading?: string;
293
+ }
294
+
295
+ /** `<omg-stack direction="row|column" gap="1|2|3|4|6" align justify wrap>`: lays its children out in a row or a column, spaced by the app's steps. */
296
+ export interface OmgStackElement extends HTMLElement {}
297
+
298
+ /** The attributes of `<omg-stack>`, as a page writes them. */
299
+ export interface OmgStackAttributes {
300
+ /** How children line up across it. */
301
+ align?: "start" | "center" | "end" | "stretch" | "baseline";
302
+ /** Column by default. */
303
+ direction?: "column" | "row";
304
+ /** A space token; 2 by default. */
305
+ gap?: "0" | "1" | "2" | "3" | "4" | "6";
306
+ /** How children are spread along it. */
307
+ justify?: "start" | "center" | "end" | "between";
308
+ /** Lets a row wrap. */
309
+ wrap?: boolean;
310
+ }
311
+
312
+ /** `<omg-empty heading description>`: what a page shows when it has nothing yet. Slots: `icon`, and actions as its content. */
313
+ export interface OmgEmptyElement extends HTMLElement {}
314
+
315
+ /** The attributes of `<omg-empty>`, as a page writes them. */
316
+ export interface OmgEmptyAttributes {
317
+ /** What to do about it. */
318
+ description?: string;
319
+ /** What is missing. */
320
+ heading?: string;
321
+ }
322
+
323
+ /** `<omg-grid min columns gap>`: lays its children out in equal columns, as many as fit at `min` pixels wide each, or exactly `columns`. */
324
+ export interface OmgGridElement extends HTMLElement {}
325
+
326
+ /** The attributes of `<omg-grid>`, as a page writes them. */
327
+ export interface OmgGridAttributes {
328
+ /** A fixed number of columns, in place of as many as fit. */
329
+ columns?: number;
330
+ /** A space token; 3 by default. */
331
+ gap?: "0" | "1" | "2" | "3" | "4" | "6";
332
+ /** The narrowest a column gets, in pixels; 240 by default. */
333
+ min?: number;
334
+ }
335
+
336
+ /** `<omg-split side side-width>`: a sidebar beside the main content, which go one above the other when there isn't room for both. */
337
+ export interface OmgSplitElement extends HTMLElement {}
338
+
339
+ /** The attributes of `<omg-split>`, as a page writes them. */
340
+ export interface OmgSplitAttributes {
341
+ /** Which side the sidebar is on; the start by default. */
342
+ side?: "start" | "end";
343
+ /** The sidebar's width in pixels; 240 by default. */
344
+ "side-width"?: number;
345
+ }
346
+
347
+ /** `<omg-card heading description>`: a raised surface that groups its content. */
348
+ export interface OmgCardElement extends HTMLElement {}
349
+
350
+ /** The attributes of `<omg-card>`, as a page writes them. */
351
+ export interface OmgCardAttributes {
352
+ /** A line under the title. */
353
+ description?: string;
354
+ /** The card's title. */
355
+ heading?: string;
356
+ }
357
+
358
+ /** `<omg-list>`: rows of `omg-list-item`, with a hairline between them. */
359
+ export interface OmgListElement extends HTMLElement {}
360
+
361
+ /** The attributes of `<omg-list>`, as a page writes them. */
362
+ export interface OmgListAttributes {
363
+ }
364
+
365
+ /** `<omg-list-item heading description>`: a row: an icon, a title and a line under it, then a value and buttons at its end. */
366
+ export interface OmgListItemElement extends HTMLElement {}
367
+
368
+ /** The attributes of `<omg-list-item>`, as a page writes them. */
369
+ export interface OmgListItemAttributes {
370
+ /** A line under the title. */
371
+ description?: string;
372
+ /** The row's title. */
373
+ heading?: string;
374
+ }
375
+
376
+ /** `<omg-divider label>`: a hairline between groups, with an optional label on it. */
377
+ export interface OmgDividerElement extends HTMLElement {}
378
+
379
+ /** The attributes of `<omg-divider>`, as a page writes them. */
380
+ export interface OmgDividerAttributes {
381
+ /** Text on the line. */
382
+ label?: string;
383
+ }
384
+
385
+ /** `<omg-image src file alt ratio fit pixelated checker>`: a picture, on a raised surface until it loads and with a mark when it can't. With `ratio` it fills a frame of that shape; without, it is drawn at its own size, at most as wide as its place. */
386
+ export interface OmgImageElement extends HTMLElement {
387
+ /** It has loaded, or failed to. */
388
+ readonly complete: boolean;
389
+ /** The picture's own height in pixels; 0 until it loads. */
390
+ readonly naturalHeight: number;
391
+ /** The picture's own width in pixels; 0 until it loads. */
392
+ readonly naturalWidth: number;
393
+ }
394
+
395
+ /** The attributes of `<omg-image>`, as a page writes them. */
396
+ export interface OmgImageAttributes {
397
+ /** What it shows, for people who can't see it; leave it empty for a decoration. */
398
+ alt?: string;
399
+ /** Draws a checkerboard behind it, to show where it is transparent. */
400
+ checker?: boolean;
401
+ /** A picture in the project, by its path there, in place of `src`; the plugin needs the `project.files` capability. Set it again to show the file as it is now. */
402
+ file?: string;
403
+ /** How the picture fills a frame of another shape: whole, or cropped to fill it. Whole by default. */
404
+ fit?: "contain" | "cover";
405
+ /** Scales pixel art without smoothing it. */
406
+ pixelated?: boolean;
407
+ /** The frame's shape, such as `16/9` or `1`; the picture's own by default. */
408
+ ratio?: string;
409
+ /** The picture's address: a file in the plugin's package, or a `data:` or `blob:` URL. */
410
+ src?: string;
411
+ }
412
+
413
+ /** `<omg-tile heading description badge src file ratio selected disabled>`: a picture with its name and a line under it, such as an asset in a grid. It is a button: a click on it is the person picking it, and `selected` marks the one picked. */
414
+ export interface OmgTileElement extends HTMLElement {
415
+ /** The `disabled` attribute. */
416
+ disabled: boolean;
417
+ /** The `selected` attribute. */
418
+ selected: boolean;
419
+ }
420
+
421
+ /** The attributes of `<omg-tile>`, as a page writes them. */
422
+ export interface OmgTileAttributes {
423
+ /** What the picture shows, when the name doesn't say; empty by default. */
424
+ alt?: string;
425
+ /** A few words over the picture's corner, such as a duration. */
426
+ badge?: string;
427
+ /** As for `omg-image`. */
428
+ checker?: boolean;
429
+ /** A line under the name, such as its size or kind. */
430
+ description?: string;
431
+ /** It can't be picked. */
432
+ disabled?: boolean;
433
+ /** A picture in the project, as for `omg-image`. */
434
+ file?: string;
435
+ /** As for `omg-image`; cropped to fill by default. */
436
+ fit?: "contain" | "cover";
437
+ /** Its name, on one line. */
438
+ heading?: string;
439
+ /** As for `omg-image`. */
440
+ pixelated?: boolean;
441
+ /** The picture's shape, as for `omg-image`; `4/3` by default. */
442
+ ratio?: string;
443
+ /** It is the one picked. */
444
+ selected?: boolean;
445
+ /** The picture, as for `omg-image`. */
446
+ src?: string;
447
+ }
448
+
449
+ /** `<omg-tabs value aria-label>`: shows one of its `omg-tab` children, with a row of their headings above. Arrow keys, Home and End move between tabs. A page listens for `omg-tab-change`, since `change` would also come up from the controls inside a tab. */
450
+ export interface OmgTabsElement extends HTMLElement {
451
+ /** The open tab's name. */
452
+ value: string;
453
+ }
454
+
455
+ /** The attributes of `<omg-tabs>`, as a page writes them. */
456
+ export interface OmgTabsAttributes {
457
+ /** What the tabs choose between, for screen readers. */
458
+ "aria-label"?: string;
459
+ /** The `name` of the open tab; the first that isn't disabled without one. */
460
+ value?: string;
461
+ }
462
+
463
+ /** `<omg-tab name heading disabled>`: one view of an `omg-tabs`. */
464
+ export interface OmgTabElement extends HTMLElement {}
465
+
466
+ /** The attributes of `<omg-tab>`, as a page writes them. */
467
+ export interface OmgTabAttributes {
468
+ /** It can't be opened. */
469
+ disabled?: boolean;
470
+ /** The text of its heading, and its name for screen readers. */
471
+ heading?: string;
472
+ /** What `value` on the `omg-tabs` calls it; unique among its tabs. */
473
+ name?: string;
474
+ }
475
+
476
+ declare global {
477
+ interface HTMLElementTagNameMap {
478
+ "omg-button": OmgButtonElement;
479
+ "omg-command-button": OmgCommandButtonElement;
480
+ "omg-status": OmgStatusElement;
481
+ "omg-banner": OmgBannerElement;
482
+ "omg-log": OmgLogElement;
483
+ "omg-steps": OmgStepsElement;
484
+ "omg-step": OmgStepElement;
485
+ "omg-badge": OmgBadgeElement;
486
+ "omg-progress": OmgProgressElement;
487
+ "omg-input": OmgInputElement;
488
+ "omg-textarea": OmgTextareaElement;
489
+ "omg-switch": OmgSwitchElement;
490
+ "omg-checkbox": OmgCheckboxElement;
491
+ "omg-select": OmgSelectElement;
492
+ "omg-segmented": OmgSegmentedElement;
493
+ "omg-page": OmgPageElement;
494
+ "omg-section": OmgSectionElement;
495
+ "omg-stack": OmgStackElement;
496
+ "omg-empty": OmgEmptyElement;
497
+ "omg-grid": OmgGridElement;
498
+ "omg-split": OmgSplitElement;
499
+ "omg-card": OmgCardElement;
500
+ "omg-list": OmgListElement;
501
+ "omg-list-item": OmgListItemElement;
502
+ "omg-divider": OmgDividerElement;
503
+ "omg-image": OmgImageElement;
504
+ "omg-tile": OmgTileElement;
505
+ "omg-tabs": OmgTabsElement;
506
+ "omg-tab": OmgTabElement;
507
+ }
508
+ interface HTMLElementEventMap {
509
+ /** The command failed; cancel it to show the failure yourself. */
510
+ "omg-command-error": CustomEvent<{ command: string; error: string }>;
511
+ /** The command's result. */
512
+ "omg-command-result": CustomEvent<{ command: string; result: unknown }>;
513
+ /** Before it runs; cancel it to not run. */
514
+ "omg-command-start": CustomEvent<{ command: string; input: unknown }>;
515
+ /** The person opened a tab. */
516
+ "omg-tab-change": CustomEvent<{ value: string }>;
517
+ }
518
+ }
package/ui/1/index.js ADDED
@@ -0,0 +1,9 @@
1
+ // OhMyGame's page components, version 1, stable: it only grows. Load them once:
2
+ //
3
+ // <script type="module" src="/_ohmygame/ui/1/index.js"></script>
4
+ import "./layout.js";
5
+ import "./navigation.js";
6
+ import "./feedback.js";
7
+ import "./controls.js";
8
+ import "./forms.js";
9
+ import "./media.js";