@uvalib/web-components 1.8.5 → 1.9.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/CHANGELOG.md +22 -0
- package/README.md +485 -59
- package/dist/base/clipboard.d.ts +9 -0
- package/dist/base/clipboard.js +30 -0
- package/dist/base/clipboard.js.map +1 -0
- package/dist/base.css +188 -3
- package/dist/components/uvalib-citation/UvalibCitation.d.ts +124 -0
- package/dist/components/uvalib-citation/UvalibCitation.js +545 -0
- package/dist/components/uvalib-citation/UvalibCitation.js.map +1 -0
- package/dist/components/uvalib-citation/uvalib-citation.d.ts +1 -0
- package/dist/components/uvalib-citation/uvalib-citation.js +4 -0
- package/dist/components/uvalib-citation/uvalib-citation.js.map +1 -0
- package/dist/components/uvalib-dialog/UvalibDialog.d.ts +167 -0
- package/dist/components/uvalib-dialog/UvalibDialog.js +688 -0
- package/dist/components/uvalib-dialog/UvalibDialog.js.map +1 -0
- package/dist/components/uvalib-dialog/uvalib-dialog.d.ts +1 -0
- package/dist/components/uvalib-dialog/uvalib-dialog.js +4 -0
- package/dist/components/uvalib-dialog/uvalib-dialog.js.map +1 -0
- package/dist/components/uvalib-filter/UvalibFilter.d.ts +92 -9
- package/dist/components/uvalib-filter/UvalibFilter.js +748 -60
- package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
- package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -4
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/custom-elements.json +4402 -2139
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +41 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +4 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +4 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/field-text.d.ts +1 -0
- package/dist/styles/field-text.js +21 -0
- package/dist/styles/field-text.js.map +1 -0
- package/dist/styles/hidden.js +13 -1
- package/dist/styles/hidden.js.map +1 -1
- package/dist/styles/table.d.ts +1 -0
- package/dist/styles/table.js +164 -0
- package/dist/styles/table.js.map +1 -0
- package/dist/tokens.css +4 -0
- package/dist-cdn/base.css +188 -3
- package/dist-cdn/chunks/{base-B3tNX103.js → base-CHMHBPeI.js} +42 -2
- package/dist-cdn/chunks/{base-B3tNX103.js.map → base-CHMHBPeI.js.map} +1 -1
- package/dist-cdn/chunks/clipboard-CNG7Y_5X.js +18 -0
- package/dist-cdn/chunks/clipboard-CNG7Y_5X.js.map +1 -0
- package/dist-cdn/chunks/if-defined-COiQb-gl.js +6 -0
- package/dist-cdn/chunks/if-defined-COiQb-gl.js.map +1 -0
- package/dist-cdn/chunks/{site-header-CEmNtmk5.js → site-header-B78a_ldi.js} +27 -22
- package/dist-cdn/chunks/site-header-B78a_ldi.js.map +1 -0
- package/dist-cdn/chunks/{site-main-nav-CAwKq_x5.js → site-main-nav-CmMq2t8t.js} +52 -51
- package/dist-cdn/chunks/site-main-nav-CmMq2t8t.js.map +1 -0
- package/dist-cdn/custom-elements.json +4402 -2139
- package/dist-cdn/manifest.json +4 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-main-nav.js +1 -1
- package/dist-cdn/site-page.js +3 -3
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +8 -5
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +135 -8
- package/dist-cdn/tokens.css +4 -0
- package/dist-cdn/uvalib-citation.js +382 -0
- package/dist-cdn/uvalib-citation.js.map +1 -0
- package/dist-cdn/uvalib-dialog.js +419 -0
- package/dist-cdn/uvalib-dialog.js.map +1 -0
- package/dist-cdn/uvalib-filter.js +603 -69
- package/dist-cdn/uvalib-filter.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +49 -49
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/package.json +9 -1
- package/skills/uvalib-web-components/SKILL.md +8 -5
- package/skills/uvalib-web-components/reference/components.md +135 -8
- package/dist-cdn/chunks/site-header-CEmNtmk5.js.map +0 -1
- package/dist-cdn/chunks/site-main-nav-CAwKq_x5.js.map +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type PropertyValues } from 'lit';
|
|
2
|
+
import { UvalibElement } from '../../base/UvalibElement.js';
|
|
3
|
+
/**
|
|
4
|
+
* Why the dialog closed: its Close button, a `data-uvalib-dialog-close` (or invoker close)
|
|
5
|
+
* button in the content, Escape (or another close request, such as Android's Back), a click on
|
|
6
|
+
* the backdrop, a `<form method="dialog">` submitted, `close()` or `open = false` from script,
|
|
7
|
+
* or the element leaving the page while open.
|
|
8
|
+
*/
|
|
9
|
+
export type DialogCloseReason = 'close-button' | 'button' | 'escape' | 'backdrop' | 'form' | 'api' | 'removed';
|
|
10
|
+
/** How the dialog opened: a visitor's button (`data-uvalib-dialog` or an invoker), or script. */
|
|
11
|
+
export type DialogOpenReason = 'button' | 'api';
|
|
12
|
+
export interface DialogOpenDetail {
|
|
13
|
+
reason: DialogOpenReason;
|
|
14
|
+
}
|
|
15
|
+
export interface DialogCloseDetail {
|
|
16
|
+
reason: DialogCloseReason;
|
|
17
|
+
returnValue: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A modal dialog for content and short forms: search tips, Cite, a sign-in prompt, a request
|
|
21
|
+
* form. Use it instead of a hand-built modal, a `role="dialog"` div or a framework's dialog.
|
|
22
|
+
*
|
|
23
|
+
* The children are the content. In shadow DOM they are slotted, never moved, so the page's CSS,
|
|
24
|
+
* ids, listeners and framework-rendered nodes keep working; with `no-shadow-dom` they are moved
|
|
25
|
+
* into the dialog (the same nodes, in the same document). It opens as a native `<dialog>` with
|
|
26
|
+
* `showModal()`: everything else on the page, `<site-page>`'s shadow header included, is inert
|
|
27
|
+
* while it is open, so focus stays inside without a trap script. The visible heading (`label`,
|
|
28
|
+
* an `<h2>` unless `heading-level` says otherwise) names it, and a 44px Close button is always
|
|
29
|
+
* shown; `description` (or a `slot="description"` child) is shown under the heading and is the
|
|
30
|
+
* dialog's description.
|
|
31
|
+
*
|
|
32
|
+
* Open it with a button anywhere in the page, `<button type="button" data-uvalib-dialog="<id>">`
|
|
33
|
+
* (one delegated listener, so buttons rendered later work too), with an invoker button
|
|
34
|
+
* (`commandfor="<id>" command="--show-modal"`) where the browser has invoker commands, with
|
|
35
|
+
* `show()`, or by setting `open`. On open, focus goes to the content's `[autofocus]` element
|
|
36
|
+
* when it has one (a form dialog: the first field), else to the heading, so a screen reader
|
|
37
|
+
* reads the dialog from the top and long content starts in view. On every close (Close,
|
|
38
|
+
* Escape, the backdrop, a `data-uvalib-dialog-close` button, a `<form method="dialog">`
|
|
39
|
+
* submitted, `close()`) focus returns to the element that opened it; if that is gone, to
|
|
40
|
+
* `return-focus` (a selector, or an element set as the property).
|
|
41
|
+
*
|
|
42
|
+
* Escape always closes it. A click on the backdrop closes it too (the native
|
|
43
|
+
* `closedby="any"`, or the same check in script where the browser lacks it), except with
|
|
44
|
+
* `persistent`, and never when a press starts inside the dialog and ends on the backdrop (a
|
|
45
|
+
* text selection or a drag). A `<form method="dialog">` in the content closes it on submit
|
|
46
|
+
* with the submitter's `value` as `returnValue`; other forms submit as usual.
|
|
47
|
+
*
|
|
48
|
+
* `size` is `small` (30rem), `medium` (the default, 40rem) or `large` (60rem) at most, and
|
|
49
|
+
* never wider or taller than the viewport less 16px on each side; the content scrolls inside
|
|
50
|
+
* it under a header that stays in view.
|
|
51
|
+
*
|
|
52
|
+
* @tagname uvalib-dialog
|
|
53
|
+
* @slot - The content: text, links, a form.
|
|
54
|
+
* @slot description - A short description under the heading, read as the dialog's description (instead of the `description` attribute).
|
|
55
|
+
* @fires uvalib-dialog-open - The dialog opened: `detail` is `{ reason }`, `button` (a visitor's opener) or `api` (`show()` or `open`). Bubbles and is composed.
|
|
56
|
+
* @fires uvalib-dialog-close - The dialog closed: `detail` is `{ reason, returnValue }`, `reason` one of `close-button`, `button` (a `data-uvalib-dialog-close` or invoker close button), `escape`, `backdrop`, `form` (a `<form method="dialog">`), `api` (`close()` or `open = false`) or `removed` (taken out of the page while open). Bubbles and is composed.
|
|
57
|
+
* @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-dialog', 'open', '<label>']` when a visitor's button opens it, and `['uvalib-dialog', 'close', '<label>']` when the visitor closes it (Close, a close button, Escape, the backdrop or a dialog form); never on `show()`, `close()` or `open` from script, and never the content. Bubbles and is composed.
|
|
58
|
+
* @cssstate open - The dialog is open.
|
|
59
|
+
* @csspart dialog - The `<dialog>`.
|
|
60
|
+
* @csspart header - The heading row (the heading and Close).
|
|
61
|
+
* @csspart heading - The heading.
|
|
62
|
+
* @csspart close - The Close button.
|
|
63
|
+
* @csspart description - The description under the heading.
|
|
64
|
+
* @csspart body - The scrolling wrapper of the content.
|
|
65
|
+
* @cssprop --uvalib-dialog-width - The dialog's widest inline size, instead of `size`'s (still never wider than the viewport less 16px on each side).
|
|
66
|
+
* @cssprop --uva-color-surface - Dark-mode role token: dialog background (else #fff).
|
|
67
|
+
* @cssprop --uva-color-text - Dark-mode role token: dialog text (else `--uva-grey-darkest`, #2b2b2b).
|
|
68
|
+
* @cssprop --uva-color-text-muted - Dark-mode role token: the description (else #4b5563, 7.5:1 on white).
|
|
69
|
+
* @cssprop --uva-color-border - Dark-mode role token: dialog edge and heading rule (else #dadada).
|
|
70
|
+
* @cssprop --uva-color-button-bg - Dark-mode role token: Close's border and text (else `--uva-blue-alt`, #007bac).
|
|
71
|
+
* @cssprop --uva-color-button-hover-bg - Dark-mode role token: hovered Close (else `--uva-blue-alt-A`, #005679).
|
|
72
|
+
* @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).
|
|
73
|
+
*/
|
|
74
|
+
export declare class UvalibDialog extends UvalibElement {
|
|
75
|
+
static styles: import("lit").CSSResult;
|
|
76
|
+
/** The visible heading and the dialog's accessible name. */
|
|
77
|
+
label: string;
|
|
78
|
+
/** The heading's level, 1 to 6 (default 2). */
|
|
79
|
+
headingLevel: number;
|
|
80
|
+
/** A short description under the heading (or a `slot="description"` child), read as the dialog's description. */
|
|
81
|
+
description: string;
|
|
82
|
+
/** The widest the dialog gets: `small` (30rem), `medium` (40rem) or `large` (60rem). */
|
|
83
|
+
size: 'small' | 'medium' | 'large';
|
|
84
|
+
/** Whether it is open. Reflected; setting it opens or closes the dialog (as `show()` and `close()`). */
|
|
85
|
+
open: boolean;
|
|
86
|
+
/** A click on the backdrop does not close it (Escape and Close still do). For forms that would lose typed text. */
|
|
87
|
+
persistent: boolean;
|
|
88
|
+
/** Where focus goes on close when the opener is gone: a selector (in the dialog's root, then the document) or an element. */
|
|
89
|
+
returnFocus: string | HTMLElement | null;
|
|
90
|
+
/** The Close button's text. */
|
|
91
|
+
closeLabel: string;
|
|
92
|
+
private readonly uid;
|
|
93
|
+
private readonly internals;
|
|
94
|
+
/** Light mode: the content wrapper, created on connect. */
|
|
95
|
+
private content?;
|
|
96
|
+
/** Light mode: the nodes this element rendered (never adopted as content). */
|
|
97
|
+
private own?;
|
|
98
|
+
private childObserver?;
|
|
99
|
+
/** The element focused when it opened (or the button that opened it). */
|
|
100
|
+
private opener;
|
|
101
|
+
/** Whether the dialog is showing, as far as this element has settled it. */
|
|
102
|
+
private shown;
|
|
103
|
+
/** Why the next close happens, when this element knows before the native close event. */
|
|
104
|
+
private closeReason?;
|
|
105
|
+
/** The open reason for an open requested before the first render. */
|
|
106
|
+
private pendingOpen?;
|
|
107
|
+
/** A press that started on the backdrop (not inside the dialog). */
|
|
108
|
+
private downOnBackdrop;
|
|
109
|
+
/** Whether the last pointer press, rather than a key, came last: a cancel then is the backdrop. */
|
|
110
|
+
private pointerLast;
|
|
111
|
+
/** Whether the last render had a description child. */
|
|
112
|
+
private descChild;
|
|
113
|
+
private get root();
|
|
114
|
+
private get dialog();
|
|
115
|
+
private get heading();
|
|
116
|
+
/** The dialog's return value: the submitter's `value` of a `<form method="dialog">`, or what `close()` was given. Empty on open. */
|
|
117
|
+
get returnValue(): string;
|
|
118
|
+
connectedCallback(): void;
|
|
119
|
+
/** Moved with `moveBefore()`: stay as it is (open or not). */
|
|
120
|
+
connectedMoveCallback(): void;
|
|
121
|
+
disconnectedCallback(): void;
|
|
122
|
+
/** Open the dialog (modal). Focus returns to the element focused now when it closes. */
|
|
123
|
+
show(): void;
|
|
124
|
+
/** Close the dialog, with `returnValue` if given. Focus returns to the opener. */
|
|
125
|
+
close(returnValue?: string): void;
|
|
126
|
+
/** @internal A visitor's button (`data-uvalib-dialog` or an invoker) opens it. */
|
|
127
|
+
openFrom(opener: Element): void;
|
|
128
|
+
private reveal;
|
|
129
|
+
private closeWith;
|
|
130
|
+
/** The dialog has closed, however it happened: restore focus, report, tell the page. */
|
|
131
|
+
private closed;
|
|
132
|
+
private get name();
|
|
133
|
+
/** The content's elements (slotted, or in the content wrapper in light mode). */
|
|
134
|
+
private contentQuery;
|
|
135
|
+
/**
|
|
136
|
+
* APG: focus the first field of a form dialog (mark it `autofocus`), else a static element at
|
|
137
|
+
* the top, the heading, so the start of the content stays in view and is read first.
|
|
138
|
+
*/
|
|
139
|
+
private focusInitial;
|
|
140
|
+
private restoreFocus;
|
|
141
|
+
private returnTarget;
|
|
142
|
+
/** Invoker commands aimed at this element (`commandfor="<id>"`). */
|
|
143
|
+
private readonly onCommand;
|
|
144
|
+
/** A `<form method="dialog">` in the content closes it with the submitter's value. */
|
|
145
|
+
private readonly onSubmit;
|
|
146
|
+
/** `data-uvalib-dialog-close` buttons in the content. */
|
|
147
|
+
private readonly onContentClick;
|
|
148
|
+
private readonly onCloseClick;
|
|
149
|
+
/** Escape, or the native light dismiss (`closedby="any"`), asks to close. */
|
|
150
|
+
private readonly onCancel;
|
|
151
|
+
private readonly onKeydown;
|
|
152
|
+
private readonly onPointerDown;
|
|
153
|
+
/** Without native `closedby`: a click whose press and release are both on the backdrop closes it. */
|
|
154
|
+
private readonly onDialogClick;
|
|
155
|
+
/** The dialog's own close event: settles Escape, the native backdrop close, or any close not made by this element. */
|
|
156
|
+
private readonly onDialogClose;
|
|
157
|
+
/** Light mode: children the page adds later go into the content too. */
|
|
158
|
+
private watchChildren;
|
|
159
|
+
private adopt;
|
|
160
|
+
/** Re-render when a description child appears or goes. */
|
|
161
|
+
private descriptionChanged;
|
|
162
|
+
/** A `slot="description"` child of this dialog (not of a nested one). */
|
|
163
|
+
private get descriptionChild();
|
|
164
|
+
protected firstUpdated(): void;
|
|
165
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
166
|
+
protected render(): import("lit").TemplateResult;
|
|
167
|
+
}
|