@ohmygame/plugin-ui 2.4.0 → 2.34.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 +7 -0
- package/index.d.ts +3 -0
- package/package.json +1 -1
- package/plugin-ui.css +5 -0
- package/ui/1/base.js +17 -0
- package/ui/1/controls.js +85 -2
- package/ui/1/custom-elements.json +2190 -746
- package/ui/1/data.js +238 -0
- package/ui/1/feedback.js +5 -4
- package/ui/1/floating.js +111 -0
- package/ui/1/forms.js +440 -39
- package/ui/1/index.d.ts +313 -1
- package/ui/1/index.js +2 -0
- package/ui/1/layout.js +36 -6
- package/ui/1/media.js +77 -0
- package/ui/1/overlays.js +465 -0
package/ui/1/index.d.ts
CHANGED
|
@@ -18,6 +18,24 @@ export interface OmgButtonAttributes {
|
|
|
18
18
|
variant?: "secondary" | "primary" | "ghost" | "danger";
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/** `<omg-disclosure heading open disabled>`: a plain title row with a leading arrow that shows or hides content. Closing keeps the content mounted and returns focus to the button when focus was inside. Enter and Space use the button's native activation. */
|
|
22
|
+
export interface OmgDisclosureElement extends HTMLElement {
|
|
23
|
+
/** The `disabled` attribute. */
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
/** The `open` attribute; setting it does not emit an event. */
|
|
26
|
+
open: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The attributes of `<omg-disclosure>`, as a page writes them. */
|
|
30
|
+
export interface OmgDisclosureAttributes {
|
|
31
|
+
/** Disables the button, without changing the content's state. */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** The button's label. */
|
|
34
|
+
heading?: string;
|
|
35
|
+
/** Shows the content; closed by default. */
|
|
36
|
+
open?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
21
39
|
/** `<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
40
|
export interface OmgCommandButtonElement extends OmgButtonElement {
|
|
23
41
|
/** The command's input; it takes the place of the attribute. */
|
|
@@ -46,6 +64,43 @@ export interface OmgCommandButtonAttributes {
|
|
|
46
64
|
variant?: "secondary" | "primary" | "ghost" | "danger";
|
|
47
65
|
}
|
|
48
66
|
|
|
67
|
+
/** `<omg-table label>`: a semantic table with stable keyed rows and cells. Text is always inserted as text; a Node cell is slotted without cloning so its state, listeners and plugin styles survive updates. Callers own sorting, loading and actions. Wide tables scroll inside their labelled region. */
|
|
68
|
+
export interface OmgTableElement extends HTMLElement {
|
|
69
|
+
/** Unique column keys, headings, optional width and alignment. */
|
|
70
|
+
columns: Array<{ key: string; heading: string; align?: "left" | "right"; width?: string }>;
|
|
71
|
+
/** Unique row keys and cells by column key; Node cells belong to this table while mounted. */
|
|
72
|
+
rows: Array<{ key: string; cells: Record<string, string | Node> }>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The attributes of `<omg-table>`, as a page writes them. */
|
|
76
|
+
export interface OmgTableAttributes {
|
|
77
|
+
/** Message with no rows; defaults to No data. */
|
|
78
|
+
"empty-label"?: string;
|
|
79
|
+
/** Table and scroll-region accessible name. */
|
|
80
|
+
label?: string;
|
|
81
|
+
/** Marks data busy; existing rows remain visible. */
|
|
82
|
+
loading?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** `<omg-pagination page pages>`: controlled pagination. It requests a page; the caller updates `page` after success. Pending requests preserve focus. */
|
|
86
|
+
export interface OmgPaginationElement extends HTMLElement {}
|
|
87
|
+
|
|
88
|
+
/** The attributes of `<omg-pagination>`, as a page writes them. */
|
|
89
|
+
export interface OmgPaginationAttributes {
|
|
90
|
+
/** Ignores requests while retaining focus. */
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
/** Navigation accessible name; defaults to Pagination. */
|
|
93
|
+
label?: string;
|
|
94
|
+
/** Next button text; defaults to Next. */
|
|
95
|
+
"next-label"?: string;
|
|
96
|
+
/** Current page, one-based; defaults to 1. */
|
|
97
|
+
page?: number;
|
|
98
|
+
/** Number of pages; at least 1. */
|
|
99
|
+
pages?: number;
|
|
100
|
+
/** Previous button text; defaults to Previous. */
|
|
101
|
+
"previous-label"?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
49
104
|
/** `<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
105
|
export interface OmgStatusElement extends HTMLElement {}
|
|
51
106
|
|
|
@@ -124,8 +179,128 @@ export interface OmgProgressAttributes {
|
|
|
124
179
|
value?: number;
|
|
125
180
|
}
|
|
126
181
|
|
|
182
|
+
/** `<omg-file-picker label accept multiple>`: choose local files or drop them. Selection stays local; callers own validation, persistence and uploads. Accept checks filenames/MIME hints, never file contents. Invalid drops retain the prior selection. Cancelling the native chooser also retains it. */
|
|
183
|
+
export interface OmgFilePickerElement extends HTMLElement {
|
|
184
|
+
/** Clears selection silently; user clearing emits change. */
|
|
185
|
+
clear(): void;
|
|
186
|
+
/** A copy of the currently selected local files. */
|
|
187
|
+
readonly files: File[];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The attributes of `<omg-file-picker>`, as a page writes them. */
|
|
191
|
+
export interface OmgFilePickerAttributes {
|
|
192
|
+
/** Comma-separated extensions or MIME types, including image/*. */
|
|
193
|
+
accept?: string;
|
|
194
|
+
/** Its name, without a label. */
|
|
195
|
+
"aria-label"?: string;
|
|
196
|
+
/** Picker action; defaults to Choose files. */
|
|
197
|
+
"choose-label"?: string;
|
|
198
|
+
/** Clear action; defaults to Clear. */
|
|
199
|
+
"clear-label"?: string;
|
|
200
|
+
/** Can't be changed. */
|
|
201
|
+
disabled?: boolean;
|
|
202
|
+
/** Drop hint; defaults to or drop files here. */
|
|
203
|
+
"drop-label"?: string;
|
|
204
|
+
/** What's wrong with its value. */
|
|
205
|
+
error?: string;
|
|
206
|
+
/** A line under it; an error takes its place. */
|
|
207
|
+
hint?: string;
|
|
208
|
+
/** Shown with it. */
|
|
209
|
+
label?: string;
|
|
210
|
+
/** Allows more than one file. */
|
|
211
|
+
multiple?: boolean;
|
|
212
|
+
/** Rejection feedback; defaults to Check the file type and number of files. */
|
|
213
|
+
"rejected-label"?: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** `<omg-slider label min max step value>`: a native range with a numeric readout. The browser bounds and steps the value. Input fires while adjusting; change fires when committed. Programmatic changes are silent. */
|
|
217
|
+
export interface OmgSliderElement extends HTMLElement {
|
|
218
|
+
/** Current bounded numeric value. */
|
|
219
|
+
value: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** The attributes of `<omg-slider>`, as a page writes them. */
|
|
223
|
+
export interface OmgSliderAttributes {
|
|
224
|
+
/** Its name, without a label. */
|
|
225
|
+
"aria-label"?: string;
|
|
226
|
+
/** Can't be changed. */
|
|
227
|
+
disabled?: boolean;
|
|
228
|
+
/** What's wrong with its value. */
|
|
229
|
+
error?: string;
|
|
230
|
+
/** A line under it; an error takes its place. */
|
|
231
|
+
hint?: string;
|
|
232
|
+
/** Shown with it. */
|
|
233
|
+
label?: string;
|
|
234
|
+
/** Range end; defaults to 100. */
|
|
235
|
+
max?: number;
|
|
236
|
+
/** Range start; defaults to 0. */
|
|
237
|
+
min?: number;
|
|
238
|
+
/** Increment; defaults to 1. */
|
|
239
|
+
step?: number | "any";
|
|
240
|
+
/** Current value; defaults to the native range midpoint. */
|
|
241
|
+
value?: number;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** `<omg-radio-group label value>` with `<option>` children: visible choices, optionally explained by each option's `data-description`. Native arrows and Space select; separate groups keep independent selections. */
|
|
245
|
+
export interface OmgRadioGroupElement extends HTMLElement {
|
|
246
|
+
/** The chosen option's value. */
|
|
247
|
+
value: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** The attributes of `<omg-radio-group>`, as a page writes them. */
|
|
251
|
+
export interface OmgRadioGroupAttributes {
|
|
252
|
+
/** Its name, without a label. */
|
|
253
|
+
"aria-label"?: string;
|
|
254
|
+
/** Can't be changed. */
|
|
255
|
+
disabled?: boolean;
|
|
256
|
+
/** What's wrong with its value. */
|
|
257
|
+
error?: string;
|
|
258
|
+
/** A line under it; an error takes its place. */
|
|
259
|
+
hint?: string;
|
|
260
|
+
/** Shown with it. */
|
|
261
|
+
label?: string;
|
|
262
|
+
/** The chosen option's value. */
|
|
263
|
+
value?: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** `<omg-combobox label value>` with `<option>` children: a searchable choice. Query text never changes the committed value until an enabled option is picked. Closing discards the query. Options can be replaced asynchronously; set `manual-filter` when the caller filters them remotely. */
|
|
267
|
+
export interface OmgComboboxElement extends HTMLElement {
|
|
268
|
+
/** Current uncommitted search text. */
|
|
269
|
+
readonly query: string;
|
|
270
|
+
/** The chosen option's value. */
|
|
271
|
+
value: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** The attributes of `<omg-combobox>`, as a page writes them. */
|
|
275
|
+
export interface OmgComboboxAttributes {
|
|
276
|
+
/** Its name, without a label. */
|
|
277
|
+
"aria-label"?: string;
|
|
278
|
+
/** Can't be changed. */
|
|
279
|
+
disabled?: boolean;
|
|
280
|
+
/** Empty list message; defaults to No results. */
|
|
281
|
+
"empty-label"?: string;
|
|
282
|
+
/** What's wrong with its value. */
|
|
283
|
+
error?: string;
|
|
284
|
+
/** A line under it; an error takes its place. */
|
|
285
|
+
hint?: string;
|
|
286
|
+
/** Shown with it. */
|
|
287
|
+
label?: string;
|
|
288
|
+
/** Shows loading-label; disables picking stale options. */
|
|
289
|
+
loading?: boolean;
|
|
290
|
+
/** Loading message; defaults to Loading…. */
|
|
291
|
+
"loading-label"?: string;
|
|
292
|
+
/** The caller filters options using omg-query. */
|
|
293
|
+
"manual-filter"?: boolean;
|
|
294
|
+
/** Text shown with no selection. */
|
|
295
|
+
placeholder?: string;
|
|
296
|
+
/** The chosen option's value. */
|
|
297
|
+
value?: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
127
300
|
/** `<omg-input label value type placeholder hint error>`: one line of text. */
|
|
128
301
|
export interface OmgInputElement extends HTMLElement {
|
|
302
|
+
/** Whether the native input satisfies its constraints. */
|
|
303
|
+
checkValidity(): boolean;
|
|
129
304
|
/** Its text. */
|
|
130
305
|
value: string;
|
|
131
306
|
}
|
|
@@ -142,10 +317,16 @@ export interface OmgInputAttributes {
|
|
|
142
317
|
hint?: string;
|
|
143
318
|
/** Shown with it. */
|
|
144
319
|
label?: string;
|
|
320
|
+
/** Maximum for type=number. */
|
|
321
|
+
max?: number;
|
|
322
|
+
/** Minimum for type=number; native validation does not clamp typed text. */
|
|
323
|
+
min?: number;
|
|
145
324
|
/** Shown while it is empty. */
|
|
146
325
|
placeholder?: string;
|
|
147
326
|
/** Can be read and copied, not changed. */
|
|
148
327
|
readonly?: boolean;
|
|
328
|
+
/** Numeric increment; native default is 1. */
|
|
329
|
+
step?: number | "any";
|
|
149
330
|
/** What it holds; text by default. */
|
|
150
331
|
type?: "text" | "search" | "password" | "number" | "email" | "url";
|
|
151
332
|
/** Its text; setting it replaces what was typed. */
|
|
@@ -301,7 +482,7 @@ export interface OmgStackAttributes {
|
|
|
301
482
|
align?: "start" | "center" | "end" | "stretch" | "baseline";
|
|
302
483
|
/** Column by default. */
|
|
303
484
|
direction?: "column" | "row";
|
|
304
|
-
/** A space token; 2 by default. */
|
|
485
|
+
/** A space token; 4 for columns, 2 for rows by default. */
|
|
305
486
|
gap?: "0" | "1" | "2" | "3" | "4" | "6";
|
|
306
487
|
/** How children are spread along it. */
|
|
307
488
|
justify?: "start" | "center" | "end" | "between";
|
|
@@ -382,6 +563,15 @@ export interface OmgDividerAttributes {
|
|
|
382
563
|
label?: string;
|
|
383
564
|
}
|
|
384
565
|
|
|
566
|
+
/** `<omg-path path>`: a read-only path with a subdued directory and a prominent filename. Narrow rows truncate the start, keeping the filename in view. The full path remains selectable and available through the native title. */
|
|
567
|
+
export interface OmgPathElement extends HTMLElement {}
|
|
568
|
+
|
|
569
|
+
/** The attributes of `<omg-path>`, as a page writes them. */
|
|
570
|
+
export interface OmgPathAttributes {
|
|
571
|
+
/** File or directory path, displayed as text; never opened or resolved. */
|
|
572
|
+
path?: string;
|
|
573
|
+
}
|
|
574
|
+
|
|
385
575
|
/** `<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
576
|
export interface OmgImageElement extends HTMLElement {
|
|
387
577
|
/** It has loaded, or failed to. */
|
|
@@ -446,6 +636,36 @@ export interface OmgTileAttributes {
|
|
|
446
636
|
src?: string;
|
|
447
637
|
}
|
|
448
638
|
|
|
639
|
+
/** `<omg-image-preview src file alt>`: an image button that opens the whole picture in a modal. Reuses omg-image loading and omg-dialog focus/closing. It never changes a selection or uploads a file. */
|
|
640
|
+
export interface OmgImagePreviewElement extends HTMLElement {
|
|
641
|
+
/** Preview visibility. */
|
|
642
|
+
open: boolean;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/** The attributes of `<omg-image-preview>`, as a page writes them. */
|
|
646
|
+
export interface OmgImagePreviewAttributes {
|
|
647
|
+
/** Image description and default preview title. */
|
|
648
|
+
alt?: string;
|
|
649
|
+
/** Show transparency in both views. */
|
|
650
|
+
checker?: boolean;
|
|
651
|
+
/** Close button name; defaults to Close. */
|
|
652
|
+
"close-label"?: string;
|
|
653
|
+
/** A project image; requires project.files and takes precedence over src. */
|
|
654
|
+
file?: string;
|
|
655
|
+
/** Thumbnail fit; contain by default. The modal always shows the whole image. */
|
|
656
|
+
fit?: "contain" | "cover";
|
|
657
|
+
/** Trigger's accessible name; defaults to alt or Preview image. */
|
|
658
|
+
label?: string;
|
|
659
|
+
/** Show the preview modal. */
|
|
660
|
+
open?: boolean;
|
|
661
|
+
/** Preserve pixel-art edges in both views. */
|
|
662
|
+
pixelated?: boolean;
|
|
663
|
+
/** Thumbnail aspect ratio; image's own by default. */
|
|
664
|
+
ratio?: string;
|
|
665
|
+
/** Same sources as omg-image. */
|
|
666
|
+
src?: string;
|
|
667
|
+
}
|
|
668
|
+
|
|
449
669
|
/** `<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
670
|
export interface OmgTabsElement extends HTMLElement {
|
|
451
671
|
/** The open tab's name. */
|
|
@@ -473,10 +693,80 @@ export interface OmgTabAttributes {
|
|
|
473
693
|
name?: string;
|
|
474
694
|
}
|
|
475
695
|
|
|
696
|
+
/** `<omg-popover label>`: a non-modal panel with a labelled trigger. */
|
|
697
|
+
export interface OmgPopoverElement extends HTMLElement {
|
|
698
|
+
/** Showing state; programmatic changes are silent. */
|
|
699
|
+
open: boolean;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** The attributes of `<omg-popover>`, as a page writes them. */
|
|
703
|
+
export interface OmgPopoverAttributes {
|
|
704
|
+
/** Disables the trigger and closes the panel. */
|
|
705
|
+
disabled?: boolean;
|
|
706
|
+
/** Trigger and panel accessible name. */
|
|
707
|
+
label?: string;
|
|
708
|
+
/** Shows the panel. */
|
|
709
|
+
open?: boolean;
|
|
710
|
+
/** Preferred placement, bottom-start by default. */
|
|
711
|
+
placement?: "bottom-start" | "bottom-end" | "top-start" | "top" | "bottom";
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** `<omg-menu label>`: an action menu. Arrow keys, Home/End and typeahead move through enabled actions. Enter/Space selects, Esc returns to the trigger. */
|
|
715
|
+
export interface OmgMenuElement extends HTMLElement {
|
|
716
|
+
/** Actions; values must be unique. Setting items preserves the focused action by value when possible. */
|
|
717
|
+
items: Array<{ value: string; label: string; description?: string; disabled?: boolean; danger?: boolean; checked?: boolean }>;
|
|
718
|
+
/** Showing state; programmatic changes are silent. */
|
|
719
|
+
open: boolean;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/** The attributes of `<omg-menu>`, as a page writes them. */
|
|
723
|
+
export interface OmgMenuAttributes {
|
|
724
|
+
/** Disables the trigger and closes the panel. */
|
|
725
|
+
disabled?: boolean;
|
|
726
|
+
/** Trigger and panel accessible name. */
|
|
727
|
+
label?: string;
|
|
728
|
+
/** Shows the panel. */
|
|
729
|
+
open?: boolean;
|
|
730
|
+
/** Preferred placement, bottom-start by default. */
|
|
731
|
+
placement?: "bottom-start" | "bottom-end" | "top-start" | "top" | "bottom";
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/** `<omg-tooltip content>` around a focusable control: a brief non-interactive hint immediately on hover or focus. Activation and Esc dismiss it. The text is also attached as aria-description to the actual focused control, across custom-element shadow roots, preserving any existing description. */
|
|
735
|
+
export interface OmgTooltipElement extends HTMLElement {}
|
|
736
|
+
|
|
737
|
+
/** The attributes of `<omg-tooltip>`, as a page writes them. */
|
|
738
|
+
export interface OmgTooltipAttributes {
|
|
739
|
+
/** Plain text hint; never essential instructions. */
|
|
740
|
+
content?: string;
|
|
741
|
+
/** Preferred placement; top by default. */
|
|
742
|
+
placement?: "top" | "bottom" | "top-start" | "bottom-start" | "bottom-end";
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/** `<omg-dialog heading open>`: custom modal content inside the plugin iframe. Native dialog owns focus trapping and Escape; content remains mounted. Programmatic open changes are silent. Simple host confirmations still use ui.confirm. */
|
|
746
|
+
export interface OmgDialogElement extends HTMLElement {
|
|
747
|
+
/** Modal visibility. */
|
|
748
|
+
open: boolean;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/** The attributes of `<omg-dialog>`, as a page writes them. */
|
|
752
|
+
export interface OmgDialogAttributes {
|
|
753
|
+
/** Close button name; defaults to Close. */
|
|
754
|
+
"close-label"?: string;
|
|
755
|
+
/** Optional description below the title. */
|
|
756
|
+
description?: string;
|
|
757
|
+
/** Dialog title and accessible name. */
|
|
758
|
+
heading?: string;
|
|
759
|
+
/** Shows the modal. */
|
|
760
|
+
open?: boolean;
|
|
761
|
+
}
|
|
762
|
+
|
|
476
763
|
declare global {
|
|
477
764
|
interface HTMLElementTagNameMap {
|
|
478
765
|
"omg-button": OmgButtonElement;
|
|
766
|
+
"omg-disclosure": OmgDisclosureElement;
|
|
479
767
|
"omg-command-button": OmgCommandButtonElement;
|
|
768
|
+
"omg-table": OmgTableElement;
|
|
769
|
+
"omg-pagination": OmgPaginationElement;
|
|
480
770
|
"omg-status": OmgStatusElement;
|
|
481
771
|
"omg-banner": OmgBannerElement;
|
|
482
772
|
"omg-log": OmgLogElement;
|
|
@@ -484,6 +774,10 @@ declare global {
|
|
|
484
774
|
"omg-step": OmgStepElement;
|
|
485
775
|
"omg-badge": OmgBadgeElement;
|
|
486
776
|
"omg-progress": OmgProgressElement;
|
|
777
|
+
"omg-file-picker": OmgFilePickerElement;
|
|
778
|
+
"omg-slider": OmgSliderElement;
|
|
779
|
+
"omg-radio-group": OmgRadioGroupElement;
|
|
780
|
+
"omg-combobox": OmgComboboxElement;
|
|
487
781
|
"omg-input": OmgInputElement;
|
|
488
782
|
"omg-textarea": OmgTextareaElement;
|
|
489
783
|
"omg-switch": OmgSwitchElement;
|
|
@@ -500,19 +794,37 @@ declare global {
|
|
|
500
794
|
"omg-list": OmgListElement;
|
|
501
795
|
"omg-list-item": OmgListItemElement;
|
|
502
796
|
"omg-divider": OmgDividerElement;
|
|
797
|
+
"omg-path": OmgPathElement;
|
|
503
798
|
"omg-image": OmgImageElement;
|
|
504
799
|
"omg-tile": OmgTileElement;
|
|
800
|
+
"omg-image-preview": OmgImagePreviewElement;
|
|
505
801
|
"omg-tabs": OmgTabsElement;
|
|
506
802
|
"omg-tab": OmgTabElement;
|
|
803
|
+
"omg-popover": OmgPopoverElement;
|
|
804
|
+
"omg-menu": OmgMenuElement;
|
|
805
|
+
"omg-tooltip": OmgTooltipElement;
|
|
806
|
+
"omg-dialog": OmgDialogElement;
|
|
507
807
|
}
|
|
508
808
|
interface HTMLElementEventMap {
|
|
809
|
+
/** Cancelable close request, forwarded from omg-dialog. */
|
|
810
|
+
"omg-close": CustomEvent<{ reason: "escape" | "backdrop" | "button" }>;
|
|
509
811
|
/** The command failed; cancel it to show the failure yourself. */
|
|
510
812
|
"omg-command-error": CustomEvent<{ command: string; error: string }>;
|
|
511
813
|
/** The command's result. */
|
|
512
814
|
"omg-command-result": CustomEvent<{ command: string; result: unknown }>;
|
|
513
815
|
/** Before it runs; cancel it to not run. */
|
|
514
816
|
"omg-command-start": CustomEvent<{ command: string; input: unknown }>;
|
|
817
|
+
/** Requested page; no state changes until the caller updates page. */
|
|
818
|
+
"omg-page-change": CustomEvent<{ page: number }>;
|
|
819
|
+
/** Search text changed, or a manual-filter list opened; caller owns fetching and stale-result protection. */
|
|
820
|
+
"omg-query": CustomEvent<{ query: string }>;
|
|
821
|
+
/** Rejected selection; previous files remain available. */
|
|
822
|
+
"omg-reject": CustomEvent<{ files: File[], reason: "accept" | "multiple" }>;
|
|
823
|
+
/** Selected action, after closing the menu. */
|
|
824
|
+
"omg-select": CustomEvent<{ value: string }>;
|
|
515
825
|
/** The person opened a tab. */
|
|
516
826
|
"omg-tab-change": CustomEvent<{ value: string }>;
|
|
827
|
+
/** The person opened or closed the content; bubbles across shadow roots. */
|
|
828
|
+
"omg-toggle": CustomEvent<{ open: boolean }>;
|
|
517
829
|
}
|
|
518
830
|
}
|
package/ui/1/index.js
CHANGED
package/ui/1/layout.js
CHANGED
|
@@ -87,7 +87,7 @@ class OmgSection extends OmgElement {
|
|
|
87
87
|
:host { display: block; }
|
|
88
88
|
section { display: flex; flex-direction: column; gap: var(--space-3); }
|
|
89
89
|
.heading { font-size: var(--text-md); }
|
|
90
|
-
.body { display: flex; flex-direction: column; gap: var(--space-
|
|
90
|
+
.body { display: flex; flex-direction: column; gap: var(--space-4); }
|
|
91
91
|
`),
|
|
92
92
|
];
|
|
93
93
|
static template = `
|
|
@@ -123,7 +123,7 @@ const SPACES = ["1", "2", "3", "4", "6"];
|
|
|
123
123
|
* lays its children out in a row or a column, spaced by the app's steps.
|
|
124
124
|
*
|
|
125
125
|
* @attr {"column" | "row"} direction - Column by default.
|
|
126
|
-
* @attr {"0" | "1" | "2" | "3" | "4" | "6"} gap - A space token; 2 by default.
|
|
126
|
+
* @attr {"0" | "1" | "2" | "3" | "4" | "6"} gap - A space token; 4 for columns, 2 for rows by default.
|
|
127
127
|
* @attr {"start" | "center" | "end" | "stretch" | "baseline"} align - How children line up across it.
|
|
128
128
|
* @attr {"start" | "center" | "end" | "between"} justify - How children are spread along it.
|
|
129
129
|
* @attr {boolean} wrap - Lets a row wrap.
|
|
@@ -132,8 +132,8 @@ const SPACES = ["1", "2", "3", "4", "6"];
|
|
|
132
132
|
class OmgStack extends OmgElement {
|
|
133
133
|
static styles = [
|
|
134
134
|
css(`
|
|
135
|
-
:host { display: flex; flex-direction: column; gap: var(--space-
|
|
136
|
-
:host([direction="row"]) { flex-direction: row; align-items: center; }
|
|
135
|
+
:host { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
|
|
136
|
+
:host([direction="row"]) { flex-direction: row; align-items: center; gap: var(--space-2); }
|
|
137
137
|
:host([wrap]) { flex-wrap: wrap; }
|
|
138
138
|
${SPACES.map((step) => `:host([gap="${step}"]) { gap: var(--space-${step}); }`).join("\n")}
|
|
139
139
|
:host([gap="0"]) { gap: 0; }
|
|
@@ -210,7 +210,7 @@ class OmgGrid extends OmgElement {
|
|
|
210
210
|
static styles = [
|
|
211
211
|
css(`
|
|
212
212
|
:host { display: block; min-width: 0; }
|
|
213
|
-
.grid { display: grid; gap: var(--space-
|
|
213
|
+
.grid { display: grid; gap: var(--space-4); grid-template-columns: var(--_columns); }
|
|
214
214
|
:host([gap="0"]) .grid { gap: 0; }
|
|
215
215
|
${SPACES.map((step) => `:host([gap="${step}"]) .grid { gap: var(--space-${step}); }`).join("\n")}
|
|
216
216
|
`),
|
|
@@ -294,7 +294,7 @@ class OmgCard extends OmgTextWatcher {
|
|
|
294
294
|
css(`
|
|
295
295
|
:host { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; padding: var(--space-4); border-radius: var(--radius-lg); background: var(--color-surface-raised); }
|
|
296
296
|
.heading { font-size: var(--text-md); }
|
|
297
|
-
.body { display: flex; flex-direction: column; gap: var(--space-
|
|
297
|
+
.body { display: flex; flex-direction: column; gap: var(--space-4); }
|
|
298
298
|
`),
|
|
299
299
|
];
|
|
300
300
|
static template = `
|
|
@@ -407,6 +407,35 @@ class OmgDivider extends OmgElement {
|
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
+
/**
|
|
411
|
+
* `<omg-path path>`: a read-only path with a subdued directory and a prominent
|
|
412
|
+
* filename. Narrow rows truncate the start, keeping the filename in view.
|
|
413
|
+
* The full path remains selectable and available through the native title.
|
|
414
|
+
*
|
|
415
|
+
* @attr {string} path - File or directory path, displayed as text; never opened or resolved.
|
|
416
|
+
* @part path - The full path, clipped at the start when needed.
|
|
417
|
+
* @part directory - The directory prefix.
|
|
418
|
+
* @part name - The filename or last directory name.
|
|
419
|
+
*/
|
|
420
|
+
class OmgPath extends OmgElement {
|
|
421
|
+
static observedAttributes = ["path"];
|
|
422
|
+
static styles = [css(`
|
|
423
|
+
:host { display: block; min-width: 0; max-width: 100%; }
|
|
424
|
+
.path { display: block; direction: rtl; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
425
|
+
.parts { direction: ltr; unicode-bidi: isolate; }
|
|
426
|
+
.directory { color: var(--color-text-tertiary); }
|
|
427
|
+
`)];
|
|
428
|
+
static template = `<span class="path" part="path"><span class="parts"><span class="directory" part="directory"></span><span part="name"></span></span></span>`;
|
|
429
|
+
update() {
|
|
430
|
+
const path = this.getAttribute("path") || "";
|
|
431
|
+
const end = path.replace(/[\\/]+$/, "").length;
|
|
432
|
+
const split = Math.max(path.lastIndexOf("/", end - 1), path.lastIndexOf("\\", end - 1)) + 1;
|
|
433
|
+
this.part("path").title = path;
|
|
434
|
+
text(this.part("directory"), path.slice(0, split));
|
|
435
|
+
text(this.part("name"), path.slice(split));
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
410
439
|
define("omg-page", OmgPage);
|
|
411
440
|
define("omg-section", OmgSection);
|
|
412
441
|
define("omg-stack", OmgStack);
|
|
@@ -417,3 +446,4 @@ define("omg-card", OmgCard);
|
|
|
417
446
|
define("omg-list", OmgList);
|
|
418
447
|
define("omg-list-item", OmgListItem);
|
|
419
448
|
define("omg-divider", OmgDivider);
|
|
449
|
+
define("omg-path", OmgPath);
|
package/ui/1/media.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Media: a picture, and a tile that shows one with its name.
|
|
2
|
+
import "./overlays.js";
|
|
2
3
|
import { connect } from "../../plugin-ui.js";
|
|
3
4
|
import { OmgElement, css, define, text } from "./base.js";
|
|
4
5
|
|
|
@@ -368,3 +369,79 @@ class OmgTile extends OmgElement {
|
|
|
368
369
|
|
|
369
370
|
define("omg-image", OmgImage);
|
|
370
371
|
define("omg-tile", OmgTile);
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* `<omg-image-preview src file alt>`: an image button that opens the whole
|
|
375
|
+
* picture in a modal. Reuses omg-image loading and omg-dialog focus/closing.
|
|
376
|
+
* It never changes a selection or uploads a file.
|
|
377
|
+
*
|
|
378
|
+
* @attr {string} src - Same sources as omg-image.
|
|
379
|
+
* @attr {string} file - A project image; requires project.files and takes precedence over src.
|
|
380
|
+
* @attr {string} alt - Image description and default preview title.
|
|
381
|
+
* @attr {string} label - Trigger's accessible name; defaults to alt or Preview image.
|
|
382
|
+
* @attr {string} close-label - Close button name; defaults to Close.
|
|
383
|
+
* @attr {string} ratio - Thumbnail aspect ratio; image's own by default.
|
|
384
|
+
* @attr {"contain" | "cover"} fit - Thumbnail fit; contain by default. The modal always shows the whole image.
|
|
385
|
+
* @attr {boolean} pixelated - Preserve pixel-art edges in both views.
|
|
386
|
+
* @attr {boolean} checker - Show transparency in both views.
|
|
387
|
+
* @attr {boolean} open - Show the preview modal.
|
|
388
|
+
* @prop {boolean} open - Preview visibility.
|
|
389
|
+
* @fires {{ reason: "escape" | "backdrop" | "button" }} omg-close - Cancelable close request, forwarded from omg-dialog.
|
|
390
|
+
* @part trigger - Image button.
|
|
391
|
+
* @part thumbnail - The omg-image in the page.
|
|
392
|
+
* @part dialog - The omg-dialog holding the full image.
|
|
393
|
+
* @part image - The full omg-image, loaded only while open.
|
|
394
|
+
*/
|
|
395
|
+
class OmgImagePreview extends OmgElement {
|
|
396
|
+
static observedAttributes = ["src", "file", "alt", "label", "close-label", "ratio", "fit", "pixelated", "checker", "open"];
|
|
397
|
+
static styles = [css(`
|
|
398
|
+
:host { display: block; min-width: 0; max-width: 100%; }
|
|
399
|
+
button { display: block; width: 100%; padding: 0; border: 0; border-radius: var(--radius-lg); background: transparent; cursor: zoom-in; }
|
|
400
|
+
button:disabled { cursor: default; }
|
|
401
|
+
button:hover:not(:disabled) { opacity: .9; }
|
|
402
|
+
omg-dialog::part(panel) { max-width: 960px; }
|
|
403
|
+
omg-image[part="image"]::part(image) { width: 100%; height: auto; max-height: calc(100vh - 144px); object-fit: contain; }
|
|
404
|
+
`)];
|
|
405
|
+
static template = `<button part="trigger" type="button" aria-haspopup="dialog"><omg-image part="thumbnail"></omg-image></button><omg-dialog part="dialog"><omg-image part="image"></omg-image></omg-dialog>`;
|
|
406
|
+
#reload = true;
|
|
407
|
+
constructor() {
|
|
408
|
+
super();
|
|
409
|
+
this.part("trigger").addEventListener("click", () => { this.open = true; });
|
|
410
|
+
this.part("dialog").addEventListener("omg-close", (event) => {
|
|
411
|
+
// Let outer listeners cancel the shared dialog's close before reflecting it.
|
|
412
|
+
queueMicrotask(() => { if (!event.defaultPrevented) this.open = false; });
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
get open() { return this.hasAttribute("open"); }
|
|
416
|
+
set open(value) { this.toggleAttribute("open", Boolean(value)); }
|
|
417
|
+
attributeChangedCallback(name, previous, value) {
|
|
418
|
+
if (name === "file" || (name === "src" && !this.getAttribute("file"))) this.#reload = true;
|
|
419
|
+
super.attributeChangedCallback(name, previous, value);
|
|
420
|
+
}
|
|
421
|
+
update() {
|
|
422
|
+
const thumbnail = this.part("thumbnail");
|
|
423
|
+
const image = this.part("image");
|
|
424
|
+
const dialog = this.part("dialog");
|
|
425
|
+
const sync = (target, name, value, force = false) => {
|
|
426
|
+
if (!force && target.getAttribute(name) === value) return;
|
|
427
|
+
if (value === null) target.removeAttribute(name);
|
|
428
|
+
else target.setAttribute(name, value);
|
|
429
|
+
};
|
|
430
|
+
for (const name of ["alt", "ratio", "fit", "pixelated", "checker", "file", "src"]) {
|
|
431
|
+
const source = name === "file" || name === "src";
|
|
432
|
+
const value = this.getAttribute(name);
|
|
433
|
+
sync(thumbnail, name, value, this.#reload && source);
|
|
434
|
+
if (name !== "ratio" && name !== "fit")
|
|
435
|
+
sync(image, name, source && !this.open ? null : value, this.open && this.#reload && source);
|
|
436
|
+
}
|
|
437
|
+
this.#reload = false;
|
|
438
|
+
const label = this.getAttribute("alt") || this.getAttribute("label") || "Preview image";
|
|
439
|
+
this.part("trigger").setAttribute("aria-label", this.getAttribute("label") || label);
|
|
440
|
+
this.part("trigger").disabled = !(this.getAttribute("src") || this.getAttribute("file"));
|
|
441
|
+
sync(dialog, "heading", label);
|
|
442
|
+
sync(dialog, "close-label", this.getAttribute("close-label"));
|
|
443
|
+
dialog.open = this.open;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
define("omg-image-preview", OmgImagePreview);
|