@redvars/peacock 4.2.1 → 4.3.1
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/{BaseField-D8ByB0l3.js → BaseField-CHBcjVc2.js} +3 -3
- package/dist/{BaseField-D8ByB0l3.js.map → BaseField-CHBcjVc2.js.map} +1 -1
- package/dist/{BaseInput-xCHvT4AN.js → BaseInput-DZp2O8Gh.js} +2 -2
- package/dist/{BaseInput-xCHvT4AN.js.map → BaseInput-DZp2O8Gh.js.map} +1 -1
- package/dist/ai-badge.js +2 -2
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-progress-DxNgAQtw.js → base-progress-CKQ32Ruw.js} +2 -2
- package/dist/{base-progress-DxNgAQtw.js.map → base-progress-CKQ32Ruw.js.map} +1 -1
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/calendar.js +2 -2
- package/dist/{canvas-base-DHKf2CmA.js → canvas-base-BoKef3yr.js} +2 -2
- package/dist/{canvas-base-DHKf2CmA.js.map → canvas-base-BoKef3yr.js.map} +1 -1
- package/dist/carousel.js +644 -0
- package/dist/carousel.js.map +1 -0
- package/dist/{cartesian-chart-G6VX1aKk.js → cartesian-chart-DqZxnoG1.js} +2 -2
- package/dist/{cartesian-chart-G6VX1aKk.js.map → cartesian-chart-DqZxnoG1.js.map} +1 -1
- package/dist/{cb-group-base-BBDUgxne.js → cb-group-base-DHwx72Gt.js} +3 -1
- package/dist/{cb-group-base-BBDUgxne.js.map → cb-group-base-DHwx72Gt.js.map} +1 -1
- package/dist/{cb-group-base-CZLzCnXK.js → cb-group-base-DXnAJxEK.js} +3 -3
- package/dist/{cb-group-base-CZLzCnXK.js.map → cb-group-base-DXnAJxEK.js.map} +1 -1
- package/dist/cb-group.js +7 -4
- package/dist/cb-group.js.map +1 -1
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +4 -4
- package/dist/chart-bar.js +4 -4
- package/dist/{chart-base-DREru2P0.js → chart-base-ByCJM_9C.js} +2 -2
- package/dist/{chart-base-DREru2P0.js.map → chart-base-ByCJM_9C.js.map} +1 -1
- package/dist/chart-doughnut.js +3 -3
- package/dist/chart-line.js +4 -4
- package/dist/chart-pie.js +3 -3
- package/dist/chat-event.js +2 -2
- package/dist/chat-message.js +2 -2
- package/dist/chat-thread.js +2 -2
- package/dist/checkbox-group.js +3 -3
- package/dist/checkbox.js +3 -3
- package/dist/chip-set.js +2 -2
- package/dist/chip.js +2 -2
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +3 -3
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +4 -4
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +4 -4
- package/dist/condition-builder.js +4 -4
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +4 -4
- package/dist/custom-elements-jsdocs.json +902 -74
- package/dist/custom-elements.json +3301 -446
- package/dist/date-field.js +5 -5
- package/dist/date-picker.js +2 -2
- package/dist/date-range-field.js +5 -5
- package/dist/datetime-field.js +5 -5
- package/dist/dependency-map.js +3 -3
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/{diagram-CHF70xTL.js → diagram-Cnrj-4y3.js} +2 -2
- package/dist/{diagram-CHF70xTL.js.map → diagram-Cnrj-4y3.js.map} +1 -1
- package/dist/diagram-controls.js +2 -2
- package/dist/diagram-minimap.js +2 -2
- package/dist/diagram.js +4 -4
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +2 -2
- package/dist/discussion-comment.js +2 -2
- package/dist/discussion.js +4 -4
- package/dist/{document-editor-Cb9fCxvA.js → document-editor-C8ThjDQ7.js} +2 -2
- package/dist/{document-editor-Cb9fCxvA.js.map → document-editor-C8ThjDQ7.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +2 -2
- package/dist/erd.js +3 -3
- package/dist/file-upload.js +3 -3
- package/dist/filter-bar.js +2 -2
- package/dist/flow.js +4 -4
- package/dist/form.js +2 -2
- package/dist/{generative-view-C4fJ2zI7.js → generative-view-CQ8-g1wY.js} +2 -2
- package/dist/{generative-view-C4fJ2zI7.js.map → generative-view-CQ8-g1wY.js.map} +1 -1
- package/dist/generative-view.js +3 -3
- package/dist/highlight-Be0wu7kh.js +252 -0
- package/dist/highlight-Be0wu7kh.js.map +1 -0
- package/dist/highlight.js +6 -0
- package/dist/highlight.js.map +1 -0
- package/dist/html-editor.js +4 -4
- package/dist/{i18n-controller-CH4e9sju.js → i18n-controller-DLJcJ5gO.js} +2 -2
- package/dist/{i18n-controller-CH4e9sju.js.map → i18n-controller-DLJcJ5gO.js.map} +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +27 -17
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +3 -3
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/listbox.js +2 -2
- package/dist/loader-full.js +19 -9
- package/dist/loader-full.js.map +1 -1
- package/dist/loader.js +46 -9
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +4 -4
- package/dist/mention-input.js +4 -4
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +2 -2
- package/dist/number-field.js +4 -4
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +4 -4
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +4 -4
- package/dist/{picker-field-loXW-xrW.js → picker-field-B5xOFc3-.js} +3 -3
- package/dist/{picker-field-loXW-xrW.js.map → picker-field-B5xOFc3-.js.map} +1 -1
- package/dist/pin-input.js +4 -4
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +4 -4
- package/dist/radio.js +3 -3
- package/dist/rating.js +3 -3
- package/dist/redvars-loader.js +2 -2
- package/dist/relative-time.js +2 -2
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-B5j0eqCJ.js → rich-text-input-C4B9D6oD.js} +3 -3
- package/dist/{rich-text-input-B5j0eqCJ.js.map → rich-text-input-C4B9D6oD.js.map} +1 -1
- package/dist/{schema-BJzlGRP1.js → schema-CPhNrjrx.js} +2 -2
- package/dist/{schema-BJzlGRP1.js.map → schema-CPhNrjrx.js.map} +1 -1
- package/dist/search.js +3 -3
- package/dist/select.js +4 -4
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +3 -3
- package/dist/site-footer-group.js +142 -0
- package/dist/site-footer-group.js.map +1 -0
- package/dist/site-footer.js +338 -0
- package/dist/site-footer.js.map +1 -0
- package/dist/site-header.js +774 -0
- package/dist/site-header.js.map +1 -0
- package/dist/site-nav-group.js +123 -0
- package/dist/site-nav-group.js.map +1 -0
- package/dist/site-nav-link.js +321 -0
- package/dist/site-nav-link.js.map +1 -0
- package/dist/site-nav-menu.js +506 -0
- package/dist/site-nav-menu.js.map +1 -0
- package/dist/site-nav-shared-BDR2HG8e.js +23 -0
- package/dist/site-nav-shared-BDR2HG8e.js.map +1 -0
- package/dist/slider.js +3 -3
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/i18n/strings.d.ts +24 -0
- package/dist/src/carousel/carousel.d.ts +135 -0
- package/dist/src/carousel/index.d.ts +1 -0
- package/dist/src/highlight/highlight.d.ts +56 -0
- package/dist/src/highlight/index.d.ts +2 -0
- package/dist/src/highlight/matches.d.ts +9 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/site-footer/index.d.ts +2 -0
- package/dist/src/site-footer/site-footer-group.d.ts +34 -0
- package/dist/src/site-footer/site-footer.d.ts +74 -0
- package/dist/src/site-header/index.d.ts +4 -0
- package/dist/src/site-header/site-header.d.ts +170 -0
- package/dist/src/site-header/site-nav-group.d.ts +32 -0
- package/dist/src/site-header/site-nav-link.d.ts +65 -0
- package/dist/src/site-header/site-nav-menu.d.ts +104 -0
- package/dist/src/site-header/site-nav-shared.d.ts +13 -0
- package/dist/src/table/table.d.ts +5 -0
- package/dist/src/video/index.d.ts +2 -0
- package/dist/src/video/video-source.d.ts +12 -0
- package/dist/src/video/video.d.ts +80 -0
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-o6v6Hrmn.js → strings-MXyrGrNs.js} +28 -1
- package/dist/strings-MXyrGrNs.js.map +1 -0
- package/dist/svg.js +2 -2
- package/dist/switch.js +3 -3
- package/dist/table.js +53 -10
- package/dist/table.js.map +1 -1
- package/dist/test/carousel.test.d.ts +1 -0
- package/dist/test/highlight.test.d.ts +1 -0
- package/dist/test/site-footer.test.d.ts +1 -0
- package/dist/test/site-header.test.d.ts +1 -0
- package/dist/test/video.test.d.ts +1 -0
- package/dist/textarea.js +4 -4
- package/dist/time-field.js +5 -5
- package/dist/time-picker.js +2 -2
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-BSzBnLZN.js → toggle-base-I1wE_fVe.js} +2 -2
- package/dist/{toggle-base-BSzBnLZN.js.map → toggle-base-I1wE_fVe.js.map} +1 -1
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +3 -3
- package/dist/tree-chart.js +3 -3
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +4 -4
- package/dist/user-menu.js +2 -2
- package/dist/video-IwNmHyft.js +509 -0
- package/dist/video-IwNmHyft.js.map +1 -0
- package/dist/video.js +12 -0
- package/dist/video.js.map +1 -0
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-timeline.js +2 -2
- package/dist/workflow.js +3 -3
- package/dist/workspace-switcher.js +2 -2
- package/package.json +1 -1
- package/readme.md +5 -0
- package/src/__internal/i18n/strings.ts +31 -0
- package/src/carousel/carousel.scss +124 -0
- package/src/carousel/carousel.ts +547 -0
- package/src/carousel/index.ts +1 -0
- package/src/condition-builder/cb-group-base.scss +5 -1
- package/src/condition-builder/cb-group-base.ts +1 -1
- package/src/condition-builder/cb-group.scss +4 -0
- package/src/highlight/highlight.scss +25 -0
- package/src/highlight/highlight.ts +123 -0
- package/src/highlight/index.ts +2 -0
- package/src/highlight/matches.ts +94 -0
- package/src/index.ts +18 -0
- package/src/loader.ts +36 -0
- package/src/site-footer/index.ts +2 -0
- package/src/site-footer/site-footer-group.scss +53 -0
- package/src/site-footer/site-footer-group.ts +52 -0
- package/src/site-footer/site-footer.scss +171 -0
- package/src/site-footer/site-footer.ts +151 -0
- package/src/site-header/index.ts +8 -0
- package/src/site-header/site-header.scss +238 -0
- package/src/site-header/site-header.ts +565 -0
- package/src/site-header/site-nav-group.scss +29 -0
- package/src/site-header/site-nav-group.ts +57 -0
- package/src/site-header/site-nav-link.scss +154 -0
- package/src/site-header/site-nav-link.ts +140 -0
- package/src/site-header/site-nav-menu.scss +182 -0
- package/src/site-header/site-nav-menu.ts +336 -0
- package/src/site-header/site-nav-shared.ts +27 -0
- package/src/table/table.scss +52 -2
- package/src/table/table.ts +20 -6
- package/src/video/index.ts +2 -0
- package/src/video/video-source.ts +80 -0
- package/src/video/video.scss +183 -0
- package/src/video/video.ts +246 -0
- package/dist/strings-o6v6Hrmn.js.map +0 -1
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { html, LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
|
+
import {
|
|
6
|
+
adoptCollapsed,
|
|
7
|
+
COLLAPSED_ATTRIBUTE,
|
|
8
|
+
NAV_PARTS,
|
|
9
|
+
} from './site-nav-shared.js';
|
|
10
|
+
import styles from './site-nav-menu.scss';
|
|
11
|
+
|
|
12
|
+
/** Why a menu's panel closed. */
|
|
13
|
+
export type SiteNavMenuCloseReason = 'action' | 'escape' | 'light-dismiss';
|
|
14
|
+
|
|
15
|
+
/** Detail of the `close` event. */
|
|
16
|
+
export interface SiteNavMenuCloseDetail {
|
|
17
|
+
/** Why the panel closed. */
|
|
18
|
+
reason: SiteNavMenuCloseReason;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** How long a mouse rests on a menu before it opens, and is away before it closes (`open-on-hover`). */
|
|
22
|
+
const HOVER_OPEN_DELAY = 120;
|
|
23
|
+
const HOVER_CLOSE_DELAY = 250;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @label Site Nav Menu
|
|
27
|
+
* @tag wc-site-nav-menu
|
|
28
|
+
* @rawTag site-nav-menu
|
|
29
|
+
*
|
|
30
|
+
* @summary A section of a site header that opens a panel of links.
|
|
31
|
+
* @overview
|
|
32
|
+
* <p>A disclosure button in a <code>wc-site-header</code> that shows a panel of
|
|
33
|
+
* <code>wc-site-nav-link</code> elements under the bar. The default <code>layout="list"</code> is a
|
|
34
|
+
* short list under the button. <code>layout="columns"</code> is a wide panel of
|
|
35
|
+
* <code>wc-site-nav-group</code> columns, with an optional featured card in the
|
|
36
|
+
* <code>feature</code> slot.</p>
|
|
37
|
+
* <p>It follows the disclosure navigation pattern, not the ARIA menu pattern: the button has
|
|
38
|
+
* <code>aria-expanded</code>, and the links follow it in the Tab order while the panel is open.
|
|
39
|
+
* Click, Enter or Space opens the panel; Escape closes it and returns focus to the button, and so
|
|
40
|
+
* does a click outside or moving focus out of it. Only one menu in a header is open at a time.
|
|
41
|
+
* Arrow Down on the button opens the panel at its first link, and the arrow keys, Home and End move
|
|
42
|
+
* between the links.</p>
|
|
43
|
+
* <p>The menu shows as current when one of its links is <code>current</code>. When the header is
|
|
44
|
+
* collapsed into its drawer, the menu becomes an expandable section of the drawer, expanded when it
|
|
45
|
+
* holds the current page.</p>
|
|
46
|
+
*
|
|
47
|
+
* @slot - The panel's `wc-site-nav-link` and `wc-site-nav-group` elements.
|
|
48
|
+
* @slot feature - A card shown at the end of a `columns` panel, such as a `wc-card` announcing news. Left out of the drawer.
|
|
49
|
+
*
|
|
50
|
+
* @fires {CustomEvent} open - Dispatched when the person opens the panel.
|
|
51
|
+
* @fires {CustomEvent<{reason: 'action' | 'escape' | 'light-dismiss'}>} close - Dispatched when the person closes the panel: the button, Escape, or a click or focus outside.
|
|
52
|
+
*
|
|
53
|
+
* @csspart trigger - The disclosure button.
|
|
54
|
+
* @csspart panel - The panel of links.
|
|
55
|
+
*
|
|
56
|
+
* @cssprop --site-nav-menu-panel-width - Width of a `list` panel. Defaults to 16rem.
|
|
57
|
+
* @cssprop --site-nav-menu-columns-max-width - Widest a `columns` panel grows. Defaults to 60rem.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```html
|
|
61
|
+
* <wc-site-nav-menu label="Product" layout="columns">
|
|
62
|
+
* <wc-site-nav-group label="Build">
|
|
63
|
+
* <wc-site-nav-link href="/tables" description="Describe data, get secured screens">
|
|
64
|
+
* <wc-icon slot="icon" name="table"></wc-icon>Tables and forms
|
|
65
|
+
* </wc-site-nav-link>
|
|
66
|
+
* </wc-site-nav-group>
|
|
67
|
+
* <wc-card slot="feature" href="/blog/1-0">…</wc-card>
|
|
68
|
+
* </wc-site-nav-menu>
|
|
69
|
+
* ```
|
|
70
|
+
* @tags navigation
|
|
71
|
+
*/
|
|
72
|
+
@IndividualComponent
|
|
73
|
+
export class SiteNavMenu extends LitElement {
|
|
74
|
+
// ── Static ───────────────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
static override shadowRootOptions = {
|
|
77
|
+
...LitElement.shadowRootOptions,
|
|
78
|
+
delegatesFocus: true,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
static styles = [styles];
|
|
82
|
+
|
|
83
|
+
static override get observedAttributes() {
|
|
84
|
+
return [...super.observedAttributes, COLLAPSED_ATTRIBUTE];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ── Properties ───────────────────────────────────────────────────────────
|
|
88
|
+
|
|
89
|
+
/** The button's text. */
|
|
90
|
+
@property() label = '';
|
|
91
|
+
|
|
92
|
+
/** Whether the panel is open. */
|
|
93
|
+
@property({ type: Boolean, reflect: true }) open = false;
|
|
94
|
+
|
|
95
|
+
/** `"list"`: a short list under the button; `"columns"`: a wide panel of groups. */
|
|
96
|
+
@property({ reflect: true }) layout: 'list' | 'columns' = 'list';
|
|
97
|
+
|
|
98
|
+
// ── State ────────────────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
/** True when the `feature` slot has content. */
|
|
101
|
+
@state() private hasFeature = false;
|
|
102
|
+
|
|
103
|
+
// ── Queries ──────────────────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
@query('#trigger') private triggerElement?: HTMLButtonElement;
|
|
106
|
+
|
|
107
|
+
// ── Private fields ───────────────────────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
/** Pending open or close from `open-on-hover`. */
|
|
110
|
+
private hoverTimer?: ReturnType<typeof setTimeout>;
|
|
111
|
+
|
|
112
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
override connectedCallback() {
|
|
115
|
+
super.connectedCallback();
|
|
116
|
+
adoptCollapsed(this);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
override disconnectedCallback() {
|
|
120
|
+
this.stopListeningOutside();
|
|
121
|
+
clearTimeout(this.hoverTimer);
|
|
122
|
+
super.disconnectedCallback();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override attributeChangedCallback(
|
|
126
|
+
name: string,
|
|
127
|
+
old: string | null,
|
|
128
|
+
value: string | null,
|
|
129
|
+
) {
|
|
130
|
+
super.attributeChangedCallback(name, old, value);
|
|
131
|
+
// In the drawer, a menu starts expanded when it holds the current page; in the bar, closed.
|
|
132
|
+
if (name === COLLAPSED_ATTRIBUTE && (old === null) !== (value === null)) {
|
|
133
|
+
this.open = value !== null && this.holdsCurrent();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected override updated(changed: PropertyValues<this>) {
|
|
138
|
+
if (changed.has('open')) {
|
|
139
|
+
if (this.open && !this.collapsed) this.listenOutside();
|
|
140
|
+
else this.stopListeningOutside();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ── Public methods ───────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
override focus() {
|
|
147
|
+
this.triggerElement?.focus();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
override blur() {
|
|
151
|
+
this.triggerElement?.blur();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ── Private methods ──────────────────────────────────────────────────────
|
|
155
|
+
|
|
156
|
+
/** Whether the header has moved the navigation into its drawer. */
|
|
157
|
+
private get collapsed() {
|
|
158
|
+
return this.hasAttribute(COLLAPSED_ATTRIBUTE);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private holdsCurrent(): boolean {
|
|
162
|
+
return Array.from(this.querySelectorAll(NAV_PARTS.link)).some(
|
|
163
|
+
link =>
|
|
164
|
+
link.hasAttribute('current') || (link as { current?: boolean }).current,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private links(): HTMLElement[] {
|
|
169
|
+
return Array.from(this.querySelectorAll<HTMLElement>(NAV_PARTS.link));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private header(): (HTMLElement & { openOnHover?: boolean }) | null {
|
|
173
|
+
return this.closest(NAV_PARTS.header);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Opens or closes as the person asked, and says so. */
|
|
177
|
+
private setOpen(open: boolean, reason: SiteNavMenuCloseReason = 'action') {
|
|
178
|
+
if (open === this.open) return;
|
|
179
|
+
this.open = open;
|
|
180
|
+
if (open) {
|
|
181
|
+
// One panel at a time in the bar.
|
|
182
|
+
if (!this.collapsed) {
|
|
183
|
+
this.header()
|
|
184
|
+
?.querySelectorAll<SiteNavMenu>(`${NAV_PARTS.menu}[open]`)
|
|
185
|
+
.forEach(menu => {
|
|
186
|
+
if (menu !== this) menu.setOpen(false, 'light-dismiss');
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
this.dispatchEvent(new CustomEvent('open'));
|
|
190
|
+
} else {
|
|
191
|
+
this.dispatchEvent(
|
|
192
|
+
new CustomEvent<SiteNavMenuCloseDetail>('close', {
|
|
193
|
+
detail: { reason },
|
|
194
|
+
}),
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private listenOutside() {
|
|
200
|
+
document.addEventListener(
|
|
201
|
+
'pointerdown',
|
|
202
|
+
this.handleDocumentPointerDown,
|
|
203
|
+
true,
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private stopListeningOutside() {
|
|
208
|
+
document.removeEventListener(
|
|
209
|
+
'pointerdown',
|
|
210
|
+
this.handleDocumentPointerDown,
|
|
211
|
+
true,
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private handleDocumentPointerDown = (event: PointerEvent) => {
|
|
216
|
+
if (!event.composedPath().includes(this)) {
|
|
217
|
+
this.setOpen(false, 'light-dismiss');
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
private handleTriggerClick() {
|
|
222
|
+
this.setOpen(!this.open);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private handleKeydown(event: KeyboardEvent) {
|
|
226
|
+
if (this.collapsed) return;
|
|
227
|
+
const path = event.composedPath();
|
|
228
|
+
const onTrigger =
|
|
229
|
+
!!this.triggerElement && path.includes(this.triggerElement);
|
|
230
|
+
if (event.key === 'Escape' && this.open) {
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
event.stopPropagation();
|
|
233
|
+
this.setOpen(false, 'escape');
|
|
234
|
+
this.triggerElement?.focus();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const links = this.links();
|
|
238
|
+
if (!links.length) return;
|
|
239
|
+
if (onTrigger) {
|
|
240
|
+
if (event.key === 'ArrowDown') {
|
|
241
|
+
event.preventDefault();
|
|
242
|
+
this.setOpen(true);
|
|
243
|
+
this.updateComplete.then(() => links[0]?.focus());
|
|
244
|
+
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const index = links.findIndex(link => path.includes(link));
|
|
248
|
+
if (index < 0) return;
|
|
249
|
+
let next: number | undefined;
|
|
250
|
+
if (event.key === 'ArrowDown') next = (index + 1) % links.length;
|
|
251
|
+
else if (event.key === 'ArrowUp')
|
|
252
|
+
next = (index - 1 + links.length) % links.length;
|
|
253
|
+
else if (event.key === 'Home') next = 0;
|
|
254
|
+
else if (event.key === 'End') next = links.length - 1;
|
|
255
|
+
if (next === undefined) return;
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
links[next]?.focus();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Focus leaving the menu (to the next link in the bar, say) closes its panel. */
|
|
261
|
+
private handleFocusOut(event: FocusEvent) {
|
|
262
|
+
if (this.collapsed || !this.open) return;
|
|
263
|
+
const next = event.relatedTarget as Node | null;
|
|
264
|
+
if (!next) return;
|
|
265
|
+
if (this.contains(next) || this.shadowRoot?.contains(next)) return;
|
|
266
|
+
this.setOpen(false, 'light-dismiss');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
private handlePointerEnter(event: PointerEvent) {
|
|
270
|
+
if (event.pointerType !== 'mouse' || this.collapsed) return;
|
|
271
|
+
if (!this.header()?.openOnHover) return;
|
|
272
|
+
clearTimeout(this.hoverTimer);
|
|
273
|
+
this.hoverTimer = setTimeout(() => this.setOpen(true), HOVER_OPEN_DELAY);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private handlePointerLeave(event: PointerEvent) {
|
|
277
|
+
if (event.pointerType !== 'mouse' || this.collapsed) return;
|
|
278
|
+
if (!this.header()?.openOnHover) return;
|
|
279
|
+
clearTimeout(this.hoverTimer);
|
|
280
|
+
this.hoverTimer = setTimeout(
|
|
281
|
+
() => this.setOpen(false, 'light-dismiss'),
|
|
282
|
+
HOVER_CLOSE_DELAY,
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
private handleFeatureSlotChange(event: Event) {
|
|
287
|
+
this.hasFeature =
|
|
288
|
+
(event.target as HTMLSlotElement).assignedElements().length > 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
292
|
+
|
|
293
|
+
render() {
|
|
294
|
+
const current = this.holdsCurrent();
|
|
295
|
+
// Keyboard handling is for the button and the links inside; the wrapper only listens.
|
|
296
|
+
return html`<div
|
|
297
|
+
class=${classMap({ menu: true, open: this.open, current })}
|
|
298
|
+
@keydown=${this.handleKeydown}
|
|
299
|
+
@focusout=${this.handleFocusOut}
|
|
300
|
+
@pointerenter=${this.handlePointerEnter}
|
|
301
|
+
@pointerleave=${this.handlePointerLeave}
|
|
302
|
+
>
|
|
303
|
+
<button
|
|
304
|
+
id="trigger"
|
|
305
|
+
class="trigger"
|
|
306
|
+
part="trigger"
|
|
307
|
+
type="button"
|
|
308
|
+
aria-expanded=${this.open ? 'true' : 'false'}
|
|
309
|
+
aria-controls="panel"
|
|
310
|
+
@click=${this.handleTriggerClick}
|
|
311
|
+
>
|
|
312
|
+
<wc-focus-ring class="focus-ring" for="trigger"></wc-focus-ring>
|
|
313
|
+
<span class="label">${this.label}</span>
|
|
314
|
+
<wc-icon
|
|
315
|
+
class="chevron"
|
|
316
|
+
name="keyboard_arrow_down"
|
|
317
|
+
aria-hidden="true"
|
|
318
|
+
></wc-icon>
|
|
319
|
+
</button>
|
|
320
|
+
<div
|
|
321
|
+
id="panel"
|
|
322
|
+
class=${classMap({ panel: true, 'has-feature': this.hasFeature })}
|
|
323
|
+
part="panel"
|
|
324
|
+
?hidden=${!this.open}
|
|
325
|
+
>
|
|
326
|
+
<div class="content"><slot></slot></div>
|
|
327
|
+
<div class="feature" ?hidden=${!this.hasFeature}>
|
|
328
|
+
<slot
|
|
329
|
+
name="feature"
|
|
330
|
+
@slotchange=${this.handleFeatureSlotChange}
|
|
331
|
+
></slot>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</div>`;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Tags of the site header's navigation parts. */
|
|
2
|
+
export const NAV_PARTS = {
|
|
3
|
+
header: 'wc-site-header',
|
|
4
|
+
menu: 'wc-site-nav-menu',
|
|
5
|
+
group: 'wc-site-nav-group',
|
|
6
|
+
link: 'wc-site-nav-link',
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
/** Attribute a header sets on its navigation parts while it is collapsed into a drawer. */
|
|
10
|
+
export const COLLAPSED_ATTRIBUTE = 'data-collapsed';
|
|
11
|
+
|
|
12
|
+
/** Marks every navigation part inside `header` as collapsed or not. */
|
|
13
|
+
export function syncCollapsed(header: Element, collapsed: boolean) {
|
|
14
|
+
header
|
|
15
|
+
.querySelectorAll(
|
|
16
|
+
`${NAV_PARTS.menu}, ${NAV_PARTS.group}, ${NAV_PARTS.link}`,
|
|
17
|
+
)
|
|
18
|
+
.forEach(part => part.toggleAttribute(COLLAPSED_ATTRIBUTE, collapsed));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** For a part connected after its header rendered: take the header's collapsed state. */
|
|
22
|
+
export function adoptCollapsed(part: Element) {
|
|
23
|
+
const header = part.closest(NAV_PARTS.header) as
|
|
24
|
+
| (Element & { collapsed?: boolean })
|
|
25
|
+
| null;
|
|
26
|
+
part.toggleAttribute(COLLAPSED_ATTRIBUTE, !!header?.collapsed);
|
|
27
|
+
}
|
package/src/table/table.scss
CHANGED
|
@@ -48,10 +48,27 @@
|
|
|
48
48
|
// Wide rows scroll inside the table instead of widening the page around it.
|
|
49
49
|
contain: inline-size;
|
|
50
50
|
position: relative;
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-direction: column;
|
|
51
53
|
flex: 1 1 auto;
|
|
52
54
|
min-height: 0;
|
|
53
55
|
overflow: auto;
|
|
54
56
|
outline: none;
|
|
57
|
+
|
|
58
|
+
> * {
|
|
59
|
+
flex: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// The body takes the spare height, which its filler row passes on to the pinned edges.
|
|
63
|
+
> .body {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex: 1 0 auto;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
|
|
68
|
+
> * {
|
|
69
|
+
flex: none;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
// ── Rows and cells ──────────────────────────────────────────────────────────
|
|
@@ -506,7 +523,13 @@
|
|
|
506
523
|
.loading-bar {
|
|
507
524
|
position: absolute;
|
|
508
525
|
inset-inline: 0;
|
|
509
|
-
|
|
526
|
+
// The progress track has a block margin of `--spacing-100`; offset it so the track lies on
|
|
527
|
+
// the header's bottom divider instead of floating above it.
|
|
528
|
+
bottom: calc(-1 * var(--spacing-100, 0.5rem));
|
|
529
|
+
// Above the pinned column groups, so it runs the full width of the table.
|
|
530
|
+
z-index: 2;
|
|
531
|
+
min-width: 0;
|
|
532
|
+
pointer-events: none;
|
|
510
533
|
--progress-height: 2px;
|
|
511
534
|
}
|
|
512
535
|
|
|
@@ -548,10 +571,37 @@
|
|
|
548
571
|
}
|
|
549
572
|
|
|
550
573
|
// The footer's top border already closes the table, so the last row needs no divider.
|
|
551
|
-
.has-footer .body .row:last-child .cell
|
|
574
|
+
.has-footer .body .row:last-child .cell,
|
|
575
|
+
.has-footer .body .row:has(+ .filler-row) .cell {
|
|
552
576
|
border-bottom-color: transparent;
|
|
553
577
|
}
|
|
554
578
|
|
|
579
|
+
// ── Filler row: the free height below the last row in a taller table ──────
|
|
580
|
+
|
|
581
|
+
.body .row.filler-row {
|
|
582
|
+
// Grows from zero: it shows only when the rows leave height free.
|
|
583
|
+
flex: 1 0 0;
|
|
584
|
+
min-block-size: 0;
|
|
585
|
+
pointer-events: none;
|
|
586
|
+
|
|
587
|
+
> .columns {
|
|
588
|
+
align-self: stretch;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// With a footer the last row drops its divider; the filler draws it while it has height.
|
|
593
|
+
.has-footer .body .row.filler-row {
|
|
594
|
+
background: linear-gradient(
|
|
595
|
+
var(--table-border-color),
|
|
596
|
+
var(--table-border-color)
|
|
597
|
+
)
|
|
598
|
+
top / 100% 1px no-repeat;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.filler-cell {
|
|
602
|
+
flex-shrink: 0;
|
|
603
|
+
}
|
|
604
|
+
|
|
555
605
|
:host([striped]) .body .row:nth-child(even):not(.selected) {
|
|
556
606
|
--_cell-background: color-mix(
|
|
557
607
|
in srgb,
|
package/src/table/table.ts
CHANGED
|
@@ -1804,11 +1804,7 @@ export class Table extends LitElement {
|
|
|
1804
1804
|
this.onSortActivate(column, event.shiftKey)}
|
|
1805
1805
|
>
|
|
1806
1806
|
${renderHeaderLabel(column)}
|
|
1807
|
-
<wc-icon
|
|
1808
|
-
class="sort-icon"
|
|
1809
|
-
aria-hidden="true"
|
|
1810
|
-
name=${icon}
|
|
1811
|
-
></wc-icon>
|
|
1807
|
+
<wc-icon class="sort-icon" aria-hidden="true" name=${icon}></wc-icon>
|
|
1812
1808
|
${showPriority
|
|
1813
1809
|
? html`<span class="sort-priority" aria-hidden="true"
|
|
1814
1810
|
>${position + 1}</span
|
|
@@ -2246,7 +2242,25 @@ export class Table extends LitElement {
|
|
|
2246
2242
|
|
|
2247
2243
|
private renderBody(columns: GridColumn[], view: TableView) {
|
|
2248
2244
|
return html`<div class="body" role="rowgroup">
|
|
2249
|
-
${this.renderBodyRows(columns, view)}
|
|
2245
|
+
${this.renderBodyRows(columns, view)}${this.renderFillerRow(columns)}
|
|
2246
|
+
</div>`;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
/**
|
|
2250
|
+
* Takes the height the rows leave free in a taller table, so the pinned column edges
|
|
2251
|
+
* run down to the footer instead of stopping at the last row. Not part of the grid.
|
|
2252
|
+
*/
|
|
2253
|
+
private renderFillerRow(columns: GridColumn[]) {
|
|
2254
|
+
return html`<div
|
|
2255
|
+
class="row filler-row"
|
|
2256
|
+
aria-hidden="true"
|
|
2257
|
+
style="--_row-min-width: ${totalWidth(columns)}rem"
|
|
2258
|
+
>
|
|
2259
|
+
${renderRowGroups(
|
|
2260
|
+
columns,
|
|
2261
|
+
entry =>
|
|
2262
|
+
html`<div class="filler-cell" style=${cellStyle(entry)}></div>`,
|
|
2263
|
+
)}
|
|
2250
2264
|
</div>`;
|
|
2251
2265
|
}
|
|
2252
2266
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** Where a video plays from. */
|
|
2
|
+
export type VideoProvider = 'youtube' | 'vimeo' | 'file';
|
|
3
|
+
|
|
4
|
+
export interface VideoSource {
|
|
5
|
+
provider: VideoProvider;
|
|
6
|
+
/** The player URL to load on play, for YouTube and Vimeo; the file URL for a file. */
|
|
7
|
+
url: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const YOUTUBE_HOSTS = [
|
|
11
|
+
'youtube.com',
|
|
12
|
+
'www.youtube.com',
|
|
13
|
+
'm.youtube.com',
|
|
14
|
+
'music.youtube.com',
|
|
15
|
+
'youtube-nocookie.com',
|
|
16
|
+
'www.youtube-nocookie.com',
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const VIMEO_HOSTS = ['vimeo.com', 'www.vimeo.com', 'player.vimeo.com'];
|
|
20
|
+
|
|
21
|
+
/** A YouTube time such as `90`, `90s` or `1m30s`, in whole seconds. */
|
|
22
|
+
function seconds(time: string | null): number {
|
|
23
|
+
if (!time) return 0;
|
|
24
|
+
if (/^\d+$/.test(time)) return Number(time);
|
|
25
|
+
const match = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(time);
|
|
26
|
+
if (!match) return 0;
|
|
27
|
+
const [, h = '0', m = '0', s = '0'] = match;
|
|
28
|
+
return Number(h) * 3600 + Number(m) * 60 + Number(s);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function youtubeId(url: URL): string | undefined {
|
|
32
|
+
if (url.hostname === 'youtu.be') return url.pathname.split('/')[1];
|
|
33
|
+
if (!YOUTUBE_HOSTS.includes(url.hostname)) return undefined;
|
|
34
|
+
if (url.pathname === '/watch') return url.searchParams.get('v') ?? undefined;
|
|
35
|
+
const [, kind, id] = url.pathname.split('/');
|
|
36
|
+
return ['embed', 'shorts', 'live', 'v'].includes(kind) ? id : undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Reads a video URL. YouTube links play through youtube-nocookie.com and Vimeo links with
|
|
41
|
+
* `dnt=1`, so neither sets tracking cookies; any other URL is treated as a video file.
|
|
42
|
+
*/
|
|
43
|
+
export function parseVideoSource(src: string): VideoSource {
|
|
44
|
+
let url: URL;
|
|
45
|
+
try {
|
|
46
|
+
url = new URL(src, document.baseURI);
|
|
47
|
+
} catch {
|
|
48
|
+
return { provider: 'file', url: src };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const youtube = youtubeId(url);
|
|
52
|
+
if (youtube && /^[\w-]+$/.test(youtube)) {
|
|
53
|
+
const params = new URLSearchParams({ autoplay: '1', rel: '0' });
|
|
54
|
+
const start = seconds(
|
|
55
|
+
url.searchParams.get('t') ?? url.searchParams.get('start'),
|
|
56
|
+
);
|
|
57
|
+
if (start) params.set('start', String(start));
|
|
58
|
+
return {
|
|
59
|
+
provider: 'youtube',
|
|
60
|
+
url: `https://www.youtube-nocookie.com/embed/${youtube}?${params}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (VIMEO_HOSTS.includes(url.hostname)) {
|
|
65
|
+
const parts = url.pathname.split('/').filter(Boolean);
|
|
66
|
+
const at = parts[0] === 'video' ? 1 : 0;
|
|
67
|
+
const id = parts[at];
|
|
68
|
+
if (id && /^\d+$/.test(id)) {
|
|
69
|
+
const params = new URLSearchParams({ autoplay: '1', dnt: '1' });
|
|
70
|
+
const hash = url.searchParams.get('h') ?? parts[at + 1];
|
|
71
|
+
if (hash && /^\w+$/.test(hash)) params.set('h', hash);
|
|
72
|
+
return {
|
|
73
|
+
provider: 'vimeo',
|
|
74
|
+
url: `https://player.vimeo.com/video/${id}?${params}`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return { provider: 'file', url: src };
|
|
80
|
+
}
|