@design.estate/dees-catalog 21.32.2 → 21.32.3
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/dist_bundle/bundle.js +28 -8
- package/dist_bundle/bundle.js.map +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-VSNSBXUT.js → chunk-EL3KNDIB.js} +300 -182
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-VSNSBXUT.js.map → chunk-EL3KNDIB.js.map} +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-PMJELHWH.js → chunk-ZRD47DC6.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-JVYREEMV.js → dees-modal-7LJGK5SK.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-RIABBONK.js → dees-workspace-terminal-O3NEQ4DO.js} +3 -3
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/elements/00formgate.d.ts +35 -0
- package/dist_ts_web/elements/00formgate.js +80 -0
- package/dist_ts_web/elements/00group-form/dees-form/dees-form.d.ts +6 -0
- package/dist_ts_web/elements/00group-form/dees-form/dees-form.js +12 -1
- package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.d.ts +6 -0
- package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.js +12 -3
- package/dist_ts_web/elements/00group-overlay/dees-modal/dees-modal.d.ts +5 -4
- package/dist_ts_web/elements/00group-overlay/dees-modal/dees-modal.demo.d.ts +2 -1
- package/dist_ts_web/elements/00group-overlay/dees-modal/dees-modal.demo.js +86 -25
- package/dist_ts_web/elements/00group-overlay/dees-modal/dees-modal.js +8 -6
- package/dist_ts_web/elements/00group-overlay/dees-popover/dees-popover.d.ts +8 -2
- package/dist_ts_web/elements/00group-overlay/dees-popover/dees-popover.js +12 -4
- package/dist_ts_web/elements/00group-overlay/dees-speechbubble/dees-speechbubble.demo.js +27 -2
- package/package.json +1 -1
- package/readme.md +12 -5
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements/00formgate.ts +90 -0
- package/ts_web/elements/00group-form/dees-form/dees-form.ts +12 -0
- package/ts_web/elements/00group-layout/dees-stepper/dees-stepper.ts +12 -2
- package/ts_web/elements/00group-overlay/dees-modal/dees-modal.demo.ts +42 -24
- package/ts_web/elements/00group-overlay/dees-modal/dees-modal.ts +7 -7
- package/ts_web/elements/00group-overlay/dees-popover/dees-popover.ts +11 -3
- package/ts_web/elements/00group-overlay/dees-speechbubble/dees-speechbubble.demo.ts +30 -1
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-PMJELHWH.js.map → chunk-ZRD47DC6.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-JVYREEMV.js.map → dees-modal-7LJGK5SK.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-RIABBONK.js.map → dees-workspace-terminal-O3NEQ4DO.js.map} +0 -0
package/readme.md
CHANGED
|
@@ -1388,8 +1388,8 @@ html`<dees-actionfooter .context=${card} .actions=${[
|
|
|
1388
1388
|
dialog runs it on Enter in its form's last field.
|
|
1389
1389
|
- **Asked first.** `beforePrimary`, a function returning a boolean, is asked before the primary
|
|
1390
1390
|
runs, from a press as from `runPrimary()`; `false` holds it and the action does not run. The
|
|
1391
|
-
other actions are never held. A dialog
|
|
1392
|
-
says why and the
|
|
1391
|
+
other actions are never held. A dialog and a bubble ask their forms here, so a field that
|
|
1392
|
+
refuses its value says why and the step forward waits for it.
|
|
1393
1393
|
- **Words.** `catalogAction('common.cancel' | 'common.create' | 'modal.continue', action)` makes
|
|
1394
1394
|
an action named by a catalog word: the footer reads it in the reader's language while it
|
|
1395
1395
|
renders, so it follows a change of language while it shows.
|
|
@@ -1537,6 +1537,12 @@ so a form that is moved in the DOM or re-attached — a cached view, a re-opened
|
|
|
1537
1537
|
keeps reporting changes and submitting, with no duplicate events after any number of
|
|
1538
1538
|
re-attachments, and reports nothing while it is detached.
|
|
1539
1539
|
|
|
1540
|
+
As it connects, a form makes itself known to the nearest dialog (`dees-modal`) or bubble
|
|
1541
|
+
(`dees-popover`) around it, also through the shadow roots of the components between them,
|
|
1542
|
+
and that host's primary action asks it first (`reportValidity()`). A component may draw
|
|
1543
|
+
the form of a dialog's body in its own shadow root. A stepper keeps its steps' forms to
|
|
1544
|
+
itself, so a dialog around it does not ask them.
|
|
1545
|
+
|
|
1540
1546
|
Enter in a field moves to the next enabled field; in the last one it submits. With a
|
|
1541
1547
|
`dees-form-submit`, that is the button's `submit()`. Without one, the form dispatches
|
|
1542
1548
|
`form-submit-request` (bubbling, composed, cancelable; the name is exported as
|
|
@@ -4480,8 +4486,9 @@ for an action that deletes or cannot be taken back. `disabled: true` shows an ac
|
|
|
4480
4486
|
be taken yet. The primary waits for the forms in the dialog's content: while a field refuses
|
|
4481
4487
|
its value, pressing the primary, or Enter in the form's last field, leaves the action unrun,
|
|
4482
4488
|
and the first refused field says why and takes the focus. The other actions, such as Cancel,
|
|
4483
|
-
never wait.
|
|
4484
|
-
|
|
4489
|
+
never wait. This includes a form inside the shadow root of a component the content is made of,
|
|
4490
|
+
such as a dialog body of the consumer's own; the forms are asked in the order they stand. A form
|
|
4491
|
+
in a bubble (`dees-popover`) or a stepper of the content is theirs, not the dialog's. An action whose label is
|
|
4485
4492
|
wider than the dialog wraps onto more lines inside it rather than being cut off; a label
|
|
4486
4493
|
that fits keeps the one-line action.
|
|
4487
4494
|
|
|
@@ -4618,7 +4625,7 @@ The catalog's one speech bubble: nonmodal content anchored in the browser's top
|
|
|
4618
4625
|
- **Placement.** `.placement` (`TDeesPopoverPlacement`) is `'auto'` by default: the bubble measures the room around the part of its anchor the reader sees — its box cut by the viewport and the scroll containers around it — and opens below or above it, wherever it fits with more room (below a header, above a footer), beside it only when neither fits, and on the side with the most room for its size when nothing fits. `'top'`, `'bottom'`, `'start'` and `'end'` (the inline sides in the anchor's writing direction; `'end'` is the right in a left-to-right page) name the side, which then holds. Either way the bubble keeps 8px from the viewport's edges, sliding along its side, and its tail keeps pointing at the anchor's middle. The side it took is the `actual-placement` attribute (`top`, `bottom`, `left`, `right`). While open it places itself again as the page scrolls or resizes and as its anchor or its content resizes, keeping its side while it still fits there. It eases in from its anchor on that side, at once under `prefers-reduced-motion: reduce`.
|
|
4619
4626
|
- **Scrolling.** Content taller than `.maxHeight` scrolls inside the bubble's frame and fades out toward the edges past which more lies ([Scroll edges](#scroll-edges), the fade look); content that fits fades nowhere.
|
|
4620
4627
|
- **Controls inside.** A dropdown's list, a date picker or a context menu opened from a control inside the bubble shows above it: they mount in the bubble's own top layer (its `overlayLayer`, which `getOverlayContainer` finds as it finds an open dialog), and the bubble leaves the keys to them while one is open, so Escape closes the list first and the bubble with the next press. A press in the list does not close the bubble. A toast raised inside the bubble is no part of it: it shows above the bubble and stays when it closes.
|
|
4621
|
-
- **Actions.** `.actions` (`IActionFooterAction<DeesPopover>[]`) are the bubble's actions about what it shows, such as a filter bubble's "Clear filters". They stand in its [action footer](#deesactionfooter) at the bottom edge, which stays in place while the content scrolls: the primary rightmost (the last action unless one carries `primary`; `primary: false` on all of them draws plain buttons), one action at a time, each called with the bubble, a failure announced with the source `popover-action`. A press on one keeps the bubble open. When the tail leaves the bubble from the footer — the bubble above its anchor, or beside it level with the footer — it takes the footer's tint. Without actions the bubble has no footer; a tooltip has none.
|
|
4628
|
+
- **Actions.** `.actions` (`IActionFooterAction<DeesPopover>[]`) are the bubble's actions about what it shows, such as a filter bubble's "Clear filters". They stand in its [action footer](#deesactionfooter) at the bottom edge, which stays in place while the content scrolls: the primary rightmost (the last action unless one carries `primary`; `primary: false` on all of them draws plain buttons), one action at a time, each called with the bubble, a failure announced with the source `popover-action`. The primary waits for the forms of the content, also a form inside the shadow root of a component in it: while a field refuses its value, a press on the primary leaves it unrun, and the first refused field says why and takes the focus. A press on one keeps the bubble open. When the tail leaves the bubble from the footer — the bubble above its anchor, or beside it level with the footer — it takes the footer's tint. Without actions the bubble has no footer; a tooltip has none.
|
|
4622
4629
|
- **Tooltip.** A host that opens the bubble on hover gives it `role="tooltip"`: it is then named by its content, not by `.label`, and leaves its anchor's state alone (no `aria-expanded`, `aria-haspopup` or `aria-controls`); the host describes the anchor by it. `dees-speechbubble` does this for its rich bubbles.
|
|
4623
4630
|
|
|
4624
4631
|
```typescript
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-catalog',
|
|
6
|
-
version: '21.32.
|
|
6
|
+
version: '21.32.3',
|
|
7
7
|
description: 'A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.'
|
|
8
8
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatched by a `dees-form` as it connects: bubbling and composed, with the form as
|
|
3
|
+
* `detail.form`, so it reaches its hosts through every shadow root it stands in. The nearest host
|
|
4
|
+
* that acts on its forms' values — a dialog's or a bubble's primary action (`FormGate`), a
|
|
5
|
+
* stepper's steps — claims the form and stops the event, so an enclosing host never asks a form
|
|
6
|
+
* that belongs to an inner one.
|
|
7
|
+
*/
|
|
8
|
+
export const formConnectEvent = 'form-connect';
|
|
9
|
+
|
|
10
|
+
/** What a gate asks of a form; `dees-form` implements it. */
|
|
11
|
+
export interface IGatedForm extends HTMLElement {
|
|
12
|
+
reportValidity(): boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IFormConnectDetail {
|
|
16
|
+
form: IGatedForm;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The gate holding each form: a form that connects under another gate leaves the one it was under. */
|
|
20
|
+
const holders = new WeakMap<IGatedForm, FormGate>();
|
|
21
|
+
|
|
22
|
+
/** A node's parent as drawn: a slotted node's slot, a shadow root's host. */
|
|
23
|
+
const drawnParent = (node: Node): Node | null =>
|
|
24
|
+
(node instanceof Element ? node.assignedSlot : null) ?? (node instanceof ShadowRoot ? node.host : node.parentNode);
|
|
25
|
+
|
|
26
|
+
const drawnAncestry = (node: Node): Node[] => {
|
|
27
|
+
const ancestry: Node[] = [];
|
|
28
|
+
for (let current: Node | null = node; current; current = drawnParent(current)) ancestry.unshift(current);
|
|
29
|
+
return ancestry;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Orders two nodes as they are drawn: through shadow roots, a slotted node where its slot stands. */
|
|
33
|
+
const byDrawnOrder = (a: Node, b: Node): number => {
|
|
34
|
+
const ancestryA = drawnAncestry(a);
|
|
35
|
+
const ancestryB = drawnAncestry(b);
|
|
36
|
+
let depth = 0;
|
|
37
|
+
while (depth < ancestryA.length && ancestryA[depth] === ancestryB[depth]) depth++;
|
|
38
|
+
const [branchA, branchB] = [ancestryA[depth], ancestryB[depth]];
|
|
39
|
+
if (!branchA || !branchB) return branchA ? 1 : branchB ? -1 : 0;
|
|
40
|
+
return branchA.compareDocumentPosition(branchB) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The forms a host's primary action waits for: every `dees-form` inside the host, also inside the
|
|
45
|
+
* shadow roots of the components its content is made of, that no nearer host claims. Created with
|
|
46
|
+
* the host, before its content renders, it hears each form connect (`formConnectEvent`).
|
|
47
|
+
*/
|
|
48
|
+
export class FormGate {
|
|
49
|
+
private readonly forms = new Set<IGatedForm>();
|
|
50
|
+
|
|
51
|
+
constructor(private readonly host: HTMLElement) {
|
|
52
|
+
host.addEventListener(formConnectEvent, this.claim);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether the host's forms accept their values, asked in the order they are drawn: the first
|
|
57
|
+
* field that refuses reports why and takes the focus, and the answer is `false`. For a footer's
|
|
58
|
+
* `beforePrimary`.
|
|
59
|
+
*/
|
|
60
|
+
public readonly accept = (): boolean => {
|
|
61
|
+
this.release();
|
|
62
|
+
return [...this.forms].sort(byDrawnOrder).every((form) => form.reportValidity());
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
private readonly claim = (eventArg: Event): void => {
|
|
66
|
+
const { form } = (eventArg as CustomEvent<IFormConnectDetail>).detail;
|
|
67
|
+
eventArg.stopPropagation();
|
|
68
|
+
holders.get(form)?.forms.delete(form);
|
|
69
|
+
holders.set(form, this);
|
|
70
|
+
this.forms.add(form);
|
|
71
|
+
this.release();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Lets go of the forms no longer inside the host. */
|
|
75
|
+
private release(): void {
|
|
76
|
+
for (const form of this.forms) {
|
|
77
|
+
if (this.contains(form)) continue;
|
|
78
|
+
this.forms.delete(form);
|
|
79
|
+
if (holders.get(form) === this) holders.delete(form);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private contains(form: IGatedForm): boolean {
|
|
84
|
+
if (!form.isConnected) return false;
|
|
85
|
+
for (let node: Node | null = form; node; node = node instanceof ShadowRoot ? node.host : node.parentNode) {
|
|
86
|
+
if (node === this.host) return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -33,6 +33,7 @@ import './dees-form-section.js';
|
|
|
33
33
|
import { DeesTable } from '../../00group-dataview/dees-table/index.js';
|
|
34
34
|
import { demoFunc } from './dees-form.demo.js';
|
|
35
35
|
import { themeDefaultStyles } from '../../00theme.js';
|
|
36
|
+
import { formConnectEvent, type IFormConnectDetail } from '../../00formgate.js';
|
|
36
37
|
|
|
37
38
|
// Unified set for form input types
|
|
38
39
|
const FORM_INPUT_TYPES = [
|
|
@@ -282,6 +283,17 @@ export class DeesForm extends DeesElement {
|
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Makes the form known to the nearest host that acts on its values (see `formConnectEvent`):
|
|
288
|
+
* a dialog's primary action then asks it first, also from inside the shadow root of a component
|
|
289
|
+
* the dialog's content is made of.
|
|
290
|
+
*/
|
|
291
|
+
public async connectedCallback(): Promise<void> {
|
|
292
|
+
const connecting = super.connectedCallback();
|
|
293
|
+
this.dispatchEvent(new CustomEvent<IFormConnectDetail>(formConnectEvent, { bubbles: true, composed: true, detail: { form: this } }));
|
|
294
|
+
await connecting;
|
|
295
|
+
}
|
|
296
|
+
|
|
285
297
|
/**
|
|
286
298
|
* The state the form derives from its children. It belongs to the rendered
|
|
287
299
|
* form, so the first render applies it without waiting for the connection's
|
|
@@ -300,9 +300,10 @@ export class DeesStepper extends DeesElement {
|
|
|
300
300
|
? html`<dialog class="stepperContainer overlay" aria-label=${label} aria-modal="true"
|
|
301
301
|
style=${`z-index: ${this.stepperZIndex};`} @cancel=${this.handleDialogCancel}
|
|
302
302
|
@keydown=${this.handleDialogKeydown} @close=${this.handleDialogClose}
|
|
303
|
-
@click=${this.handleOutsideClick} @form-submit-request=${this.handleFormSubmitRequest}
|
|
303
|
+
@click=${this.handleOutsideClick} @form-submit-request=${this.handleFormSubmitRequest}
|
|
304
|
+
@form-connect=${this.claimStepForm}>${this.renderSurface()}</dialog>`
|
|
304
305
|
: html`<div class="stepperContainer" role="region" aria-label=${label}
|
|
305
|
-
@form-submit-request=${this.handleFormSubmitRequest}>${this.renderSurface()}</div>`;
|
|
306
|
+
@form-submit-request=${this.handleFormSubmitRequest} @form-connect=${this.claimStepForm}>${this.renderSurface()}</div>`;
|
|
306
307
|
}
|
|
307
308
|
|
|
308
309
|
private renderSurface() {
|
|
@@ -820,6 +821,15 @@ export class DeesStepper extends DeesElement {
|
|
|
820
821
|
void this.handleMenuOptionClick(primary, true);
|
|
821
822
|
}
|
|
822
823
|
|
|
824
|
+
/**
|
|
825
|
+
* The steps' forms are the stepper's own: it asks the selected step's form
|
|
826
|
+
* before the step's primary, so a dialog or a bubble around the stepper does
|
|
827
|
+
* not (see `formConnectEvent`).
|
|
828
|
+
*/
|
|
829
|
+
private claimStepForm(eventArg: Event): void {
|
|
830
|
+
eventArg.stopPropagation();
|
|
831
|
+
}
|
|
832
|
+
|
|
823
833
|
private getProgressStepState(stepArg: IStep): IStepProgressState {
|
|
824
834
|
if (!stepArg.progressStep) {
|
|
825
835
|
return {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { html } from '@design.estate/dees-element';
|
|
1
|
+
import { DeesElement, css, customElement, html, type TemplateResult } from '@design.estate/dees-element';
|
|
2
2
|
import { DeesModal } from './dees-modal.js';
|
|
3
3
|
import { demoPage, demoSection, demoOutput, demoCode, demoStyles, showDemoResult } from '../../../demos/templates.js';
|
|
4
4
|
import { createWorkspace, updateWorkspace, workspaceGeneralFields, workspacePrivacyFields, workspaceForm, type IDemoWorkspace } from '../../../demos/workspace.js';
|
|
@@ -6,6 +6,27 @@ import type { DeesForm } from '../../00group-form/dees-form/dees-form.js';
|
|
|
6
6
|
import type { DeesInputText } from '../../00group-input/dees-input-text/dees-input-text.js';
|
|
7
7
|
import '../../00group-input/dees-input-textarea/dees-input-textarea.js';
|
|
8
8
|
|
|
9
|
+
const inviteAddresses = (value: string) => value.split(/[\s,]+/).filter(Boolean);
|
|
10
|
+
|
|
11
|
+
/** Invitations to people: the field refuses an address that is not whole. */
|
|
12
|
+
const inviteForm = () => html`<dees-form>
|
|
13
|
+
<dees-input-textarea key="emails" label="Email addresses" .rows=${4} required
|
|
14
|
+
.value=${'ada@northstar.example\ngrace@northstar'}
|
|
15
|
+
.validationFunction=${(value: string) => inviteAddresses(value).every((address) => /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(address))
|
|
16
|
+
? { valid: true }
|
|
17
|
+
: { valid: false, message: 'Write each address in full, as name@example.com.' }}></dees-input-textarea>
|
|
18
|
+
</dees-form>`;
|
|
19
|
+
|
|
20
|
+
/** A dialog body of the consumer's own, drawing the invitation form in its shadow root. */
|
|
21
|
+
@customElement('dees-demo-invite-body')
|
|
22
|
+
class DeesDemoInviteBody extends DeesElement {
|
|
23
|
+
public static styles = css`:host { display: block; }`;
|
|
24
|
+
|
|
25
|
+
public render() {
|
|
26
|
+
return inviteForm();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
9
30
|
/** The same draft survives navigation; only Save hands it back to the caller. */
|
|
10
31
|
export const openSettingsDemo = async (options: { initial?: IDemoWorkspace; onSave?: (data: IDemoWorkspace) => void } = {}) => {
|
|
11
32
|
let draft = { ...(options.initial ?? createWorkspace()) };
|
|
@@ -84,6 +105,20 @@ const openExample = (options: Partial<Parameters<typeof DeesModal.createAndShow>
|
|
|
84
105
|
...options,
|
|
85
106
|
});
|
|
86
107
|
|
|
108
|
+
/** The invitation dialog; `form` finds its form, wherever the content draws it. */
|
|
109
|
+
const openInvitations = (trigger: Element, content: TemplateResult, form: (modal: DeesModal) => DeesForm) => openExample({
|
|
110
|
+
heading: 'Invite people',
|
|
111
|
+
content,
|
|
112
|
+
menuOptions: [
|
|
113
|
+
{ name: 'Cancel', action: (modal) => modal!.destroy() },
|
|
114
|
+
{ name: 'Send invitations', action: async (modal) => {
|
|
115
|
+
const { emails } = await form(modal!).collectFormData();
|
|
116
|
+
showDemoResult(trigger, `Invited ${inviteAddresses(String(emails)).length} people`);
|
|
117
|
+
await modal!.destroy();
|
|
118
|
+
} },
|
|
119
|
+
],
|
|
120
|
+
});
|
|
121
|
+
|
|
87
122
|
export const demoFunc = () => demoPage('Modal', 'Focused windows with native keyboard behavior, a clear action area, and room for settings that grow.', html`
|
|
88
123
|
${demoSection('Workspace settings', 'Switch between General and Privacy. A fixed height of 400px on desktop and 520px on narrow screens keeps the window steady.', html`
|
|
89
124
|
<div class="dees-demo-row"><dees-button type="accent" text="Open settings" @clicked=${(event: Event) => {
|
|
@@ -136,30 +171,13 @@ export const demoFunc = () => demoPage('Modal', 'Focused windows with native key
|
|
|
136
171
|
}}></dees-button>
|
|
137
172
|
</div>${demoOutput('Confirm or dismiss a prompt to see its result.')}
|
|
138
173
|
${demoCode("await DeesModal.prompt({\n heading: 'Close Northstar?', subheading: 'Workspace · 14 services', width: 'medium',\n label: 'Type northstar to confirm',\n description: 'Closing a workspace removes its services, files and invitations.',\n emptyValueMessage: 'Type the workspace name to confirm.',\n validate: (value) => value === 'northstar' ? undefined : 'That is not the workspace name.',\n});")}`)}
|
|
139
|
-
${demoSection('A field that refuses', 'The primary action waits for the dialog\'s form: a field that refuses its value says why and takes the focus, from a press as from Enter. Cancel never waits.', html`
|
|
174
|
+
${demoSection('A field that refuses', 'The primary action waits for the dialog\'s form, also one a component of the content draws in its own shadow root: a field that refuses its value says why and takes the focus, from a press as from Enter. Cancel never waits.', html`
|
|
140
175
|
<div class="dees-demo-row">
|
|
141
|
-
<dees-button text="Invite people" @clicked=${(event: Event) =>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
content: html`<dees-form>
|
|
147
|
-
<dees-input-textarea key="emails" label="Email addresses" .rows=${4} required
|
|
148
|
-
.value=${'ada@northstar.example\ngrace@northstar'}
|
|
149
|
-
.validationFunction=${(value: string) => addresses(value).every((address) => /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(address))
|
|
150
|
-
? { valid: true }
|
|
151
|
-
: { valid: false, message: 'Write each address in full, as name@example.com.' }}></dees-input-textarea>
|
|
152
|
-
</dees-form>`,
|
|
153
|
-
menuOptions: [
|
|
154
|
-
{ name: 'Cancel', action: (modal) => modal!.destroy() },
|
|
155
|
-
{ name: 'Send invitations', action: async (modal) => {
|
|
156
|
-
const { emails } = await modal!.shadowRoot!.querySelector<DeesForm>('dees-form')!.collectFormData();
|
|
157
|
-
showDemoResult(trigger, `Invited ${addresses(String(emails)).length} people`);
|
|
158
|
-
await modal!.destroy();
|
|
159
|
-
} },
|
|
160
|
-
],
|
|
161
|
-
});
|
|
162
|
-
}}></dees-button>
|
|
176
|
+
<dees-button text="Invite people" @clicked=${(event: Event) => openInvitations(event.currentTarget as Element, inviteForm(),
|
|
177
|
+
(modal) => modal.shadowRoot!.querySelector<DeesForm>('dees-form')!)}></dees-button>
|
|
178
|
+
<dees-button text="Body in a component" @clicked=${(event: Event) => openInvitations(event.currentTarget as Element,
|
|
179
|
+
html`<dees-demo-invite-body></dees-demo-invite-body>`,
|
|
180
|
+
(modal) => modal.shadowRoot!.querySelector<DeesDemoInviteBody>('dees-demo-invite-body')!.shadowRoot!.querySelector<DeesForm>('dees-form')!)}></dees-button>
|
|
163
181
|
</div>${demoOutput('Send the invitations: the dialog holds them until every address is whole.')}
|
|
164
182
|
${demoCode("await DeesModal.createAndShow({\n heading: 'Invite people',\n // the primary waits until the form's fields accept their values\n content: html`<dees-form><dees-input-textarea key=\"emails\" .validationFunction=${everyAddressWhole}></dees-input-textarea></dees-form>`,\n menuOptions: [cancel, { name: 'Send invitations', action: send }],\n});")}`)}
|
|
165
183
|
${demoSection('Actions that take a moment', 'One action runs at a time: its button shows the busy face, the others wait, and a failure hands the dialog back.', html`
|
|
@@ -27,7 +27,7 @@ import '../../00group-button/dees-button-exit/dees-button-exit.js';
|
|
|
27
27
|
import '../../00group-utility/dees-icon/dees-icon.js';
|
|
28
28
|
import { themeDefaultStyles } from '../../00theme.js';
|
|
29
29
|
import { DeesInputText } from '../../00group-input/dees-input-text/dees-input-text.js';
|
|
30
|
-
import
|
|
30
|
+
import { FormGate } from '../../00formgate.js';
|
|
31
31
|
|
|
32
32
|
declare global {
|
|
33
33
|
interface HTMLElementTagNameMap {
|
|
@@ -455,7 +455,7 @@ export class DeesModal extends DeesElement {
|
|
|
455
455
|
${this.menuOptions.length ? html`
|
|
456
456
|
<dees-actionfooter class="bottomButtons" .actions=${this.menuOptions} .context=${this}
|
|
457
457
|
.primaryActionType=${this.primaryActionType} .disabled=${this.promptPending}
|
|
458
|
-
.beforePrimary=${this.
|
|
458
|
+
.beforePrimary=${this.formGate.accept} source="modal-menu"></dees-actionfooter>
|
|
459
459
|
` : ''}
|
|
460
460
|
</section>
|
|
461
461
|
</dialog>
|
|
@@ -566,12 +566,12 @@ export class DeesModal extends DeesElement {
|
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
/**
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
* waits for it, from a press as from
|
|
569
|
+
* The forms of the dialog's content, also those inside the shadow roots of
|
|
570
|
+
* the components it is made of. The first field that refuses reports why and
|
|
571
|
+
* takes the focus, and the primary action waits for it, from a press as from
|
|
572
|
+
* Enter.
|
|
572
573
|
*/
|
|
573
|
-
private readonly
|
|
574
|
-
[...this.shadowRoot?.querySelectorAll<DeesForm>('.content dees-form') ?? []].every((form) => form.reportValidity());
|
|
574
|
+
private readonly formGate = new FormGate(this);
|
|
575
575
|
|
|
576
576
|
/**
|
|
577
577
|
* Enter in the last field of a form in this dialog runs the dialog's primary
|
|
@@ -13,6 +13,7 @@ import { dcLocalize } from '../../../i18n/localize.js';
|
|
|
13
13
|
import { deepActiveElement, type IOverlayLayerHost } from '../../00overlay.js';
|
|
14
14
|
import { listenForScrollAround, placeAnchored, visibleRect, type TAnchoredPlacement, type TAnchoredSide } from '../../00anchorplacement.js';
|
|
15
15
|
import { ScrollEdgeShadowController, scrollEdgeFadeStyles } from '../../00scrolledges.js';
|
|
16
|
+
import { FormGate } from '../../00formgate.js';
|
|
16
17
|
import type { DeesWindowLayer } from '../dees-windowlayer/dees-windowlayer.js';
|
|
17
18
|
import type { IActionFooterAction } from '../../00group-button/dees-actionfooter/dees-actionfooter.js';
|
|
18
19
|
import '../../00group-button/dees-actionfooter/dees-actionfooter.js';
|
|
@@ -95,8 +96,9 @@ export class DeesPopover extends DeesElement implements IOverlayLayerHost {
|
|
|
95
96
|
/**
|
|
96
97
|
* The bubble's actions, drawn by `dees-actionfooter` at its bottom edge: the primary rightmost,
|
|
97
98
|
* one action at a time, each called with the bubble; the footer stays in place while the content
|
|
98
|
-
* scrolls.
|
|
99
|
-
*
|
|
99
|
+
* scrolls. The primary waits for the forms of the content: the first field that refuses says why
|
|
100
|
+
* and takes the focus. A failure is announced with the source `popover-action`. Empty, the bubble
|
|
101
|
+
* has no footer; a tooltip has no actions.
|
|
100
102
|
*/
|
|
101
103
|
@property({ attribute: false })
|
|
102
104
|
accessor actions: IActionFooterAction<DeesPopover>[] = [];
|
|
@@ -112,6 +114,11 @@ export class DeesPopover extends DeesElement implements IOverlayLayerHost {
|
|
|
112
114
|
private accessor tailOnActions = false;
|
|
113
115
|
/** Content taller than the bubble scrolls, fading out toward an edge past which more lies. */
|
|
114
116
|
private readonly scrollEdges = new ScrollEdgeShadowController(this, () => this.shadowRoot?.querySelector<HTMLElement>('.content'));
|
|
117
|
+
/**
|
|
118
|
+
* The forms of the bubble's content, also those inside the shadow roots of the components it is
|
|
119
|
+
* made of: the primary action waits for them as a dialog's does.
|
|
120
|
+
*/
|
|
121
|
+
private readonly formGate = new FormGate(this);
|
|
115
122
|
|
|
116
123
|
public static styles = [
|
|
117
124
|
themeDefaultStyles,
|
|
@@ -273,7 +280,8 @@ export class DeesPopover extends DeesElement implements IOverlayLayerHost {
|
|
|
273
280
|
public render(): TemplateResult {
|
|
274
281
|
return html`
|
|
275
282
|
<div class="surface"><div class="content ${this.scrollEdges.fadeClasses()}"><slot></slot></div>${this.actions.length
|
|
276
|
-
? html`<dees-actionfooter class="actions" .actions=${this.actions} .context=${this}
|
|
283
|
+
? html`<dees-actionfooter class="actions" .actions=${this.actions} .context=${this}
|
|
284
|
+
.beforePrimary=${this.formGate.accept} source="popover-action"></dees-actionfooter>`
|
|
277
285
|
: ''}</div>
|
|
278
286
|
${this.showTail ? html`<span class="tail ${this.tailOnActions ? 'onActions' : ''}" aria-hidden="true"></span>` : ''}
|
|
279
287
|
<div class="overlayLayer"></div>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { html } from '@design.estate/dees-element';
|
|
2
|
-
import { demoCode, demoPage, demoSection } from '../../../demos/templates.js';
|
|
2
|
+
import { demoCode, demoOutput, demoPage, demoSection, showDemoResult } from '../../../demos/templates.js';
|
|
3
3
|
import type { DeesPopover } from '../dees-popover/dees-popover.js';
|
|
4
|
+
import type { IActionFooterAction } from '../../00group-button/dees-actionfooter/dees-actionfooter.js';
|
|
5
|
+
import type { DeesForm } from '../../00group-form/dees-form/dees-form.js';
|
|
6
|
+
import type { DeesInputTextarea } from '../../00group-input/dees-input-textarea/dees-input-textarea.js';
|
|
4
7
|
import '../dees-popover/dees-popover.js';
|
|
5
8
|
import '../../00group-layout/dees-label/dees-label.js';
|
|
6
9
|
|
|
@@ -22,6 +25,16 @@ const placed = (label: string, placement: DeesPopover['placement']) => html`
|
|
|
22
25
|
<dees-popover .placement=${placement} label=${label} width="min(260px, calc(100vw - 16px))">${bubbleText}</dees-popover>
|
|
23
26
|
</span>`;
|
|
24
27
|
|
|
28
|
+
/** A booking's note fits in 80 characters; the one given is longer, so Save waits until it is shortened. */
|
|
29
|
+
const noteActions: IActionFooterAction<DeesPopover>[] = [
|
|
30
|
+
{ name: 'Clear', action: async (bubble) => { bubble!.querySelector<DeesInputTextarea>('dees-input-textarea')!.setValue(''); } },
|
|
31
|
+
{ name: 'Save note', action: async (bubble) => {
|
|
32
|
+
const { note } = await bubble!.querySelector<DeesForm>('dees-form')!.collectFormData();
|
|
33
|
+
showDemoResult(bubble!.anchor!, `Saved: ${String(note) || 'no note'}`);
|
|
34
|
+
bubble!.close();
|
|
35
|
+
} },
|
|
36
|
+
];
|
|
37
|
+
|
|
25
38
|
export const demoFunc = () => demoPage('Speech bubble', 'The catalog\'s one speech bubble: a status button\'s panel, a table\'s or tile\'s footer info and a label\'s information are all a dees-popover, with its tail on what it belongs to. It opens where it fits unless a side is named, stays inside the window, and places itself again as the page scrolls.', html`
|
|
26
39
|
${demoSection('Opens where it fits', 'Without a named side the bubble opens below or above its anchor, wherever it fits with more room — below a page header, above a footer — and beside it only when neither fits. Scroll the page so a button sits near the bottom of the window, then press it.', html`
|
|
27
40
|
<div class="dees-demo-row">${placed('Where it fits', 'auto')}</div>
|
|
@@ -36,6 +49,22 @@ popover.open = true; // placement 'auto': below or above, wherever it fits`)}
|
|
|
36
49
|
${placed('End', 'end')}
|
|
37
50
|
</div>
|
|
38
51
|
`)}
|
|
52
|
+
${demoSection('A form in the bubble', 'The primary action waits for the bubble\'s form, as a dialog\'s does: a field that refuses its value says why and takes the focus. Clear never waits.', html`
|
|
53
|
+
<div class="dees-demo-row">
|
|
54
|
+
<span>
|
|
55
|
+
<dees-button type="outline" text="Note on booking" @clicked=${toggle}></dees-button>
|
|
56
|
+
<dees-popover label="Note on booking" .actions=${noteActions}>
|
|
57
|
+
<dees-form style="padding: var(--dees-spacing-lg)">
|
|
58
|
+
<dees-input-textarea key="note" label="Note" .rows=${3} .maxLength=${80}
|
|
59
|
+
.value=${'Paid by the customer in two parts: the deposit in March and the rest after delivery in April.'}></dees-input-textarea>
|
|
60
|
+
</dees-form>
|
|
61
|
+
</dees-popover>
|
|
62
|
+
</span>
|
|
63
|
+
</div>${demoOutput('Save the note: the bubble holds it until it fits in 80 characters.')}
|
|
64
|
+
${demoCode(`popover.actions = [clear, { name: 'Save note', action: save }];
|
|
65
|
+
// the primary waits until the form's fields accept their values
|
|
66
|
+
popover.innerHTML = '<dees-form><dees-input-textarea key="note" maxlength="80"></dees-input-textarea></dees-form>';`)}
|
|
67
|
+
`)}
|
|
39
68
|
${demoSection('Information on hover', 'A label\'s information, and any dees-speechbubble after a control, opens the same bubble as a tooltip on hover or keyboard focus and describes its control while it shows.', html`
|
|
40
69
|
<dees-label label="Region" infoText="Choose the **nearest** region. Data stays in the region you choose."></dees-label>
|
|
41
70
|
`)}
|
/package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-PMJELHWH.js.map → chunk-ZRD47DC6.js.map}
RENAMED
|
File without changes
|
|
File without changes
|