@vonage/vivid 5.8.0 → 5.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/bundled/data-grid.options.cjs +1 -0
- package/bundled/data-grid.options.js +29 -0
- package/bundled/definition2.cjs +1 -1
- package/bundled/definition2.js +1 -1
- package/bundled/definition3.cjs +1 -1
- package/bundled/definition3.js +1 -1
- package/bundled/definition9.cjs +9 -9
- package/bundled/definition9.js +113 -1342
- package/bundled/feature.cjs +4 -0
- package/bundled/feature.js +2886 -0
- package/bundled/floating-ui.dom.cjs +1 -0
- package/bundled/floating-ui.dom.js +1242 -0
- package/bundled/localized.cjs +1 -1
- package/bundled/localized.js +8 -5
- package/bundled/vivid-element.cjs +3 -3
- package/bundled/vivid-element.js +89 -69
- package/combobox/definition.cjs +14 -15
- package/combobox/definition.js +15 -16
- package/combobox/index.cjs +4 -4
- package/combobox/index.js +82 -87
- package/custom-elements.json +4890 -3492
- package/data-grid/definition.cjs +23 -49
- package/data-grid/definition.js +1 -27
- package/data-grid/index.cjs +27 -27
- package/data-grid/index.js +44 -64
- package/data-table/definition.cjs +204 -0
- package/data-table/definition.js +188 -0
- package/data-table/index.cjs +37 -0
- package/data-table/index.js +143 -0
- package/file-picker/definition.cjs +10 -8
- package/file-picker/definition.js +10 -8
- package/file-picker/index.cjs +5 -5
- package/file-picker/index.js +12 -12
- package/icon/definition.cjs +1 -1
- package/icon/definition.js +1 -1
- package/index.cjs +26 -4
- package/index.js +4 -1
- package/lib/components.d.ts +4 -1
- package/lib/data-table/definition.d.ts +8 -0
- package/lib/data-table/table-body.d.ts +3 -0
- package/lib/data-table/table-body.template.d.ts +3 -0
- package/lib/data-table/table-cell.d.ts +381 -0
- package/lib/data-table/table-cell.template.d.ts +3 -0
- package/lib/data-table/table-head.d.ts +3 -0
- package/lib/data-table/table-head.template.d.ts +3 -0
- package/lib/data-table/table-header-cell.d.ts +381 -0
- package/lib/data-table/table-header-cell.template.d.ts +3 -0
- package/lib/data-table/table-row.d.ts +381 -0
- package/lib/data-table/table-row.template.d.ts +3 -0
- package/lib/data-table/table.d.ts +3 -0
- package/lib/data-table/table.template.d.ts +3 -0
- package/lib/popover/definition.d.ts +4 -0
- package/lib/popover/locale.d.ts +3 -0
- package/lib/popover/popover.d.ts +781 -0
- package/lib/popover/popover.template.d.ts +3 -0
- package/lib/rich-text-editor/rte/config.d.ts +3 -0
- package/lib/rich-text-editor/rte/document.d.ts +2 -0
- package/lib/rich-text-editor/rte/exports.d.ts +1 -0
- package/lib/rich-text-editor/rte/view.d.ts +30 -0
- package/lib/rich-text-view/definition.d.ts +4 -0
- package/lib/rich-text-view/rich-text-view.d.ts +15 -0
- package/lib/rich-text-view/rich-text-view.template.d.ts +3 -0
- package/lib/tag-name-map.d.ts +9 -1
- package/locales/de-DE.cjs +3 -0
- package/locales/de-DE.js +3 -0
- package/locales/en-GB.cjs +3 -0
- package/locales/en-GB.js +3 -0
- package/locales/en-US.cjs +3 -0
- package/locales/en-US.js +3 -0
- package/locales/ja-JP.cjs +3 -0
- package/locales/ja-JP.js +3 -0
- package/locales/zh-CN.cjs +3 -0
- package/locales/zh-CN.js +3 -0
- package/package.json +7 -7
- package/popover/definition.cjs +363 -0
- package/popover/definition.js +357 -0
- package/popover/index.cjs +27 -0
- package/popover/index.js +263 -0
- package/rich-text-editor/definition.cjs +327 -3881
- package/rich-text-editor/definition.js +142 -3696
- package/rich-text-editor/index.cjs +12 -15
- package/rich-text-editor/index.js +3489 -6291
- package/rich-text-view/definition.cjs +159 -0
- package/rich-text-view/definition.js +153 -0
- package/rich-text-view/index.cjs +1 -0
- package/rich-text-view/index.js +95 -0
- package/shared/localization/Locale.d.ts +2 -0
- package/unbundled/_commonjsHelpers.cjs +26 -0
- package/unbundled/_commonjsHelpers.js +26 -1
- package/unbundled/data-grid.options.cjs +34 -0
- package/unbundled/data-grid.options.js +28 -0
- package/unbundled/definition.cjs +1 -1
- package/unbundled/definition.js +1 -1
- package/unbundled/feature.cjs +3678 -0
- package/unbundled/feature.js +3662 -0
- package/unbundled/vivid-element.cjs +1 -1
- package/unbundled/vivid-element.js +1 -1
- package/video-player/definition.cjs +11 -1
- package/video-player/definition.js +12 -2
- package/video-player/index.cjs +30 -30
- package/video-player/index.js +705 -702
- package/vivid.api.json +1402 -67
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { VividElementDefinitionContext } from '../../shared/design-system/defineVividComponent';
|
|
2
|
+
import { Popover } from './popover';
|
|
3
|
+
export declare const popoverTemplate: (context: VividElementDefinitionContext) => import("@microsoft/fast-element").ViewTemplate<Popover, any>;
|
|
@@ -4,9 +4,12 @@ import { RteInstance, type RteInstanceOptions } from './instance';
|
|
|
4
4
|
import { RteFeature, RteFeatureImpl } from './feature';
|
|
5
5
|
import { TextblockAttrs } from './utils/textblock-attrs';
|
|
6
6
|
import { TextblockMarks } from './utils/textblock-marks';
|
|
7
|
+
import type { RteDocument } from './document';
|
|
8
|
+
import { type RteView, type RteViewOptions } from './view';
|
|
7
9
|
export declare class RteConfig {
|
|
8
10
|
constructor(features: RteFeature[]);
|
|
9
11
|
instantiateEditor(options?: RteInstanceOptions): RteInstance;
|
|
12
|
+
instantiateView(document: RteDocument, options?: RteViewOptions): RteView;
|
|
10
13
|
}
|
|
11
14
|
export declare class RteConfigImpl {
|
|
12
15
|
schema: Schema;
|
|
@@ -21,6 +21,8 @@ type RegularNode = {
|
|
|
21
21
|
marks?: Mark[];
|
|
22
22
|
content?: Array<RteNode>;
|
|
23
23
|
};
|
|
24
|
+
export type RteTextNode = TextNode;
|
|
25
|
+
export type RteRegularNode = RegularNode;
|
|
24
26
|
export type RteNode = TextNode | RegularNode;
|
|
25
27
|
export type RteMark = Mark;
|
|
26
28
|
export type RteDocument = Doc;
|
|
@@ -21,3 +21,4 @@ export { RteHtmlParser } from './html-parser';
|
|
|
21
21
|
export { RteHtmlSerializer } from './html-serializer';
|
|
22
22
|
export type { RteInstance } from './instance';
|
|
23
23
|
export type { RteDocument, RteFragment, RteNode, RteMark } from './document';
|
|
24
|
+
export type { RteView, RteViewOptions } from './view';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RteConfig } from './config';
|
|
2
|
+
import type { RteDocument, RteMark, RteNode } from './document';
|
|
3
|
+
import { impl } from './utils/impl';
|
|
4
|
+
export type RteView = ({
|
|
5
|
+
type: 'node';
|
|
6
|
+
node: RteDocument | RteNode;
|
|
7
|
+
children: RteView;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'mark';
|
|
10
|
+
mark: RteMark;
|
|
11
|
+
children: RteView;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'fragment';
|
|
14
|
+
content: RteView[];
|
|
15
|
+
}) & {
|
|
16
|
+
[impl]: RteViewCtx;
|
|
17
|
+
};
|
|
18
|
+
export type RteViewCtx = {
|
|
19
|
+
config: RteConfig;
|
|
20
|
+
options: RteViewOptions;
|
|
21
|
+
};
|
|
22
|
+
export type RteViewOptions = {
|
|
23
|
+
renderChildView?: (view: RteView & {
|
|
24
|
+
type: 'node' | 'mark';
|
|
25
|
+
}) => {
|
|
26
|
+
dom: HTMLElement;
|
|
27
|
+
contentDom?: HTMLElement;
|
|
28
|
+
} | false;
|
|
29
|
+
};
|
|
30
|
+
export declare const convertToView: (doc: RteDocument, ctx: RteViewCtx) => RteView;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RichTextView } from './rich-text-view';
|
|
2
|
+
export declare const richTextViewDefinition: import("../../shared/design-system/defineVividComponent").VividComponentDefinition;
|
|
3
|
+
export declare const registerRichTextView: (prefix?: string) => void;
|
|
4
|
+
export { RichTextView as VwcRichTextViewElement };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VividElement } from '../../shared/foundation/vivid-element/vivid-element';
|
|
2
|
+
import type { RteView } from '../rich-text-editor/rte/view';
|
|
3
|
+
export declare class RichTextView extends VividElement {
|
|
4
|
+
view?: RteView;
|
|
5
|
+
private _styles?;
|
|
6
|
+
private _addStyles;
|
|
7
|
+
private _removeStyles;
|
|
8
|
+
private _slotCounter;
|
|
9
|
+
private _slottedChildren;
|
|
10
|
+
private _cleanupLightDom;
|
|
11
|
+
private _updateView;
|
|
12
|
+
private _renderView;
|
|
13
|
+
private _handleCustomRender;
|
|
14
|
+
private _renderDefault;
|
|
15
|
+
}
|
package/lib/tag-name-map.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VwcAccordionElement, VwcAccordionItemElement, VwcActionGroupElement, VwcAlertElement, VwcAudioPlayerElement, VwcAvatarElement, VwcBadgeElement, VwcBannerElement, VwcBreadcrumbElement, VwcBreadcrumbItemElement, VwcButtonElement, VwcCalendarElement, VwcCalendarEventElement, VwcCardElement, VwcCheckboxElement, VwcColorPickerElement, VwcComboboxElement, VwcContextualHelpElement, VwcDataGridCellElement, VwcDataGridElement, VwcDataGridRowElement, VwcDatePickerElement, VwcDateRangePickerElement, VwcDateTimePickerElement, VwcDialogElement, VwcDialPadElement, VwcDividerElement, VwcEmptyStateElement, VwcFabElement, VwcFilePickerElement, VwcHeaderElement, VwcIconElement, VwcLayoutElement, VwcMenuElement, VwcMenuItemElement, VwcNavDisclosureElement, VwcNavElement, VwcNavItemElement, VwcNoteElement, VwcNumberFieldElement, VwcOptionElement, VwcPaginationElement, VwcProgressElement, VwcProgressRingElement, VwcRadioElement, VwcRadioGroupElement, VwcRangeSliderElement, VwcRichTextEditorElement, VwcSearchableSelectElement, VwcSelectableBoxElement, VwcSelectElement, VwcSideDrawerElement, VwcSimpleColorPickerElement, VwcSliderElement, VwcSplitButtonElement, VwcSwitchElement, VwcTabElement, VwcTabPanelElement, VwcTabsElement, VwcTagElement, VwcTagGroupElement, VwcTextAreaElement, VwcTextFieldElement, VwcTimePickerElement, VwcToggletipElement, VwcTooltipElement, VwcTreeItemElement, VwcTreeViewElement, VwcVideoPlayerElement } from './components';
|
|
1
|
+
import type { VwcAccordionElement, VwcAccordionItemElement, VwcActionGroupElement, VwcAlertElement, VwcAudioPlayerElement, VwcAvatarElement, VwcBadgeElement, VwcBannerElement, VwcBreadcrumbElement, VwcBreadcrumbItemElement, VwcButtonElement, VwcCalendarElement, VwcCalendarEventElement, VwcCardElement, VwcCheckboxElement, VwcColorPickerElement, VwcComboboxElement, VwcContextualHelpElement, VwcDataGridCellElement, VwcDataGridElement, VwcDataGridRowElement, VwcDatePickerElement, VwcDateRangePickerElement, VwcDateTimePickerElement, VwcDialogElement, VwcDialPadElement, VwcDividerElement, VwcEmptyStateElement, VwcFabElement, VwcFilePickerElement, VwcHeaderElement, VwcIconElement, VwcLayoutElement, VwcMenuElement, VwcMenuItemElement, VwcNavDisclosureElement, VwcNavElement, VwcNavItemElement, VwcNoteElement, VwcNumberFieldElement, VwcOptionElement, VwcPaginationElement, VwcPopoverElement, VwcProgressElement, VwcProgressRingElement, VwcRadioElement, VwcRadioGroupElement, VwcRangeSliderElement, VwcRichTextEditorElement, VwcRichTextViewElement, VwcSearchableSelectElement, VwcSelectableBoxElement, VwcSelectElement, VwcSideDrawerElement, VwcSimpleColorPickerElement, VwcSliderElement, VwcSplitButtonElement, VwcSwitchElement, VwcTabElement, VwcTableBodyElement, VwcTableCellElement, VwcTableElement, VwcTableHeadElement, VwcTableHeaderCellElement, VwcTableRowElement, VwcTabPanelElement, VwcTabsElement, VwcTagElement, VwcTagGroupElement, VwcTextAreaElement, VwcTextFieldElement, VwcTimePickerElement, VwcToggletipElement, VwcTooltipElement, VwcTreeItemElement, VwcTreeViewElement, VwcVideoPlayerElement } from './components';
|
|
2
2
|
type DefaultVividTagNameMap = {
|
|
3
3
|
'vwc-accordion': VwcAccordionElement;
|
|
4
4
|
'vwc-accordion-item': VwcAccordionItemElement;
|
|
@@ -21,6 +21,12 @@ type DefaultVividTagNameMap = {
|
|
|
21
21
|
'vwc-data-grid-cell': VwcDataGridCellElement;
|
|
22
22
|
'vwc-data-grid': VwcDataGridElement;
|
|
23
23
|
'vwc-data-grid-row': VwcDataGridRowElement;
|
|
24
|
+
'vwc-table': VwcTableElement;
|
|
25
|
+
'vwc-table-body': VwcTableBodyElement;
|
|
26
|
+
'vwc-table-cell': VwcTableCellElement;
|
|
27
|
+
'vwc-table-head': VwcTableHeadElement;
|
|
28
|
+
'vwc-table-header-cell': VwcTableHeaderCellElement;
|
|
29
|
+
'vwc-table-row': VwcTableRowElement;
|
|
24
30
|
'vwc-date-picker': VwcDatePickerElement;
|
|
25
31
|
'vwc-date-range-picker': VwcDateRangePickerElement;
|
|
26
32
|
'vwc-date-time-picker': VwcDateTimePickerElement;
|
|
@@ -42,11 +48,13 @@ type DefaultVividTagNameMap = {
|
|
|
42
48
|
'vwc-number-field': VwcNumberFieldElement;
|
|
43
49
|
'vwc-option': VwcOptionElement;
|
|
44
50
|
'vwc-pagination': VwcPaginationElement;
|
|
51
|
+
'vwc-popover': VwcPopoverElement;
|
|
45
52
|
'vwc-progress': VwcProgressElement;
|
|
46
53
|
'vwc-progress-ring': VwcProgressRingElement;
|
|
47
54
|
'vwc-radio': VwcRadioElement;
|
|
48
55
|
'vwc-radio-group': VwcRadioGroupElement;
|
|
49
56
|
'vwc-range-slider': VwcRangeSliderElement;
|
|
57
|
+
'vwc-rich-text-view': VwcRichTextViewElement;
|
|
50
58
|
'vwc-rich-text-editor': VwcRichTextEditorElement;
|
|
51
59
|
'vwc-searchable-select': VwcSearchableSelectElement;
|
|
52
60
|
'vwc-selectable-box': VwcSelectableBoxElement;
|
package/locales/de-DE.cjs
CHANGED
package/locales/de-DE.js
CHANGED
package/locales/en-GB.cjs
CHANGED
package/locales/en-GB.js
CHANGED
package/locales/en-US.cjs
CHANGED
package/locales/en-US.js
CHANGED
package/locales/ja-JP.cjs
CHANGED
package/locales/ja-JP.js
CHANGED
package/locales/zh-CN.cjs
CHANGED
package/locales/zh-CN.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonage/vivid",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.0",
|
|
4
4
|
"homepage": "https://vivid.deno.dev",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/Vonage/vivid-3/issues"
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"prosemirror-view": "^1.40.1",
|
|
56
56
|
"ramda": "^0.32.0",
|
|
57
57
|
"uuid": "^11.1.0",
|
|
58
|
-
"vanilla-colorful": "^0.7.2"
|
|
58
|
+
"vanilla-colorful": "^0.7.2",
|
|
59
|
+
"video.js": "^8.23.4"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@custom-elements-manifest/analyzer": "^0.5.7",
|
|
@@ -79,7 +80,6 @@
|
|
|
79
80
|
"sass": "^1.94.2",
|
|
80
81
|
"tsx": "^4.20.6",
|
|
81
82
|
"typescript": "5.9.3",
|
|
82
|
-
"video.js": "^8.23.4",
|
|
83
83
|
"vite": "^5.4.18",
|
|
84
84
|
"vite-plugin-dts": "~2.3.0",
|
|
85
85
|
"vite-plugin-static-copy": "^1.0.6",
|
|
@@ -87,13 +87,13 @@
|
|
|
87
87
|
"vitest-axe": "^0.1.0",
|
|
88
88
|
"vitest-fetch-mock": "^0.4.5",
|
|
89
89
|
"wait-on": "^8.0.5",
|
|
90
|
-
"@repo/consts": "1.0.0",
|
|
91
90
|
"@repo/cem-analyzer-plugins": "1.0.0",
|
|
92
|
-
"@repo/
|
|
93
|
-
"@repo/eslint-config": "1.0.0",
|
|
91
|
+
"@repo/consts": "1.0.0",
|
|
94
92
|
"@repo/shared": "1.0.0",
|
|
95
|
-
"@repo/
|
|
93
|
+
"@repo/eslint-config": "1.0.0",
|
|
94
|
+
"@repo/eslint-plugin-repo": "1.0.0",
|
|
96
95
|
"@repo/tokens": "1.0.0",
|
|
96
|
+
"@repo/stylelint-config": "1.0.0",
|
|
97
97
|
"@repo/styles": "1.0.0",
|
|
98
98
|
"@repo/tools": "1.0.0",
|
|
99
99
|
"@repo/typescript-config": "1.0.0",
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const elevation_definition = require('../unbundled/definition6.cjs');
|
|
6
|
+
const vividElement = require('../unbundled/vivid-element.cjs');
|
|
7
|
+
const fastElement = require('@microsoft/fast-element');
|
|
8
|
+
const dom = require('@floating-ui/dom');
|
|
9
|
+
const delegatesAria = require('../unbundled/delegates-aria.cjs');
|
|
10
|
+
const localized = require('../unbundled/localized.cjs');
|
|
11
|
+
const fastWebUtilities = require('@microsoft/fast-web-utilities');
|
|
12
|
+
const icon_definition = require('../icon/definition.cjs');
|
|
13
|
+
const button_definition = require('../unbundled/definition.cjs');
|
|
14
|
+
|
|
15
|
+
const styles = ":host{display:inline-block}.base{white-space:initial;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.base{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.base ::-webkit-scrollbar{width:4px}.base ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.base ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}.base{position:fixed;overflow:visible;padding:0;border:none;border-radius:8px;margin:0;inline-size:max-content;min-inline-size:fit-content}.base:focus-visible{outline:none}.base::backdrop{background-color:var(--popover-backdrop-bg, transparent)}.control{display:flex;flex-direction:column;padding:var(--popover-padding, 24px);border-radius:inherit;background:var(--vvd-color-surface-4dp);color:var(--vvd-color-canvas-text);gap:var(--popover-gap, 24px)}.control:not(.open){display:none}.control.condensed{--popover-padding: 12px;--popover-gap: 12px}.control.manual{padding-block-start:40px}.arrow{position:absolute;z-index:-1;width:8px;height:8px;background:var(--vvd-color-surface-4dp);transform:rotate(45deg)}.dismiss-button{position:absolute;inset-block-start:4px;inset-inline-end:4px}";
|
|
16
|
+
|
|
17
|
+
var __defProp = Object.defineProperty;
|
|
18
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
19
|
+
var result = void 0 ;
|
|
20
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
21
|
+
if (decorator = decorators[i])
|
|
22
|
+
result = (decorator(target, key, result) ) || result;
|
|
23
|
+
if (result) __defProp(target, key, result);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
class Popover extends localized.Localized(delegatesAria.DelegatesAria(vividElement.VividElement)) {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.placement = "bottom";
|
|
30
|
+
this.manual = false;
|
|
31
|
+
this.layout = "default";
|
|
32
|
+
this.offset = 8;
|
|
33
|
+
this.alternate = false;
|
|
34
|
+
this.dismissButtonAriaLabel = null;
|
|
35
|
+
this.arrow = false;
|
|
36
|
+
this.open = false;
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
this.#currentAnchor = null;
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
this.#manualToggle = () => {
|
|
45
|
+
this._popoverEl.togglePopover();
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
this.#autoUpdateCallback = () => {
|
|
51
|
+
this.#lastPositionUpdate = this.updatePosition();
|
|
52
|
+
};
|
|
53
|
+
// --- Lifecycle & Events ---
|
|
54
|
+
/**
|
|
55
|
+
* Syncs native toggle state (Esc key, light dismiss) back to the 'open' attribute.
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
this.#handleNativeToggle = (e) => {
|
|
59
|
+
const isOpen = e.newState ? e.newState === "open" : this._popoverEl.matches(":popover-open");
|
|
60
|
+
if (this.open !== isOpen) {
|
|
61
|
+
this.open = isOpen;
|
|
62
|
+
}
|
|
63
|
+
this.$emit(isOpen ? "open" : "close", void 0, { bubbles: false });
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
placementChanged() {
|
|
67
|
+
this.#updateAutoUpdate();
|
|
68
|
+
}
|
|
69
|
+
arrowChanged() {
|
|
70
|
+
this.#updateAutoUpdate();
|
|
71
|
+
}
|
|
72
|
+
openChanged(_oldValue, newValue) {
|
|
73
|
+
if (!this._popoverEl) return;
|
|
74
|
+
const isOpen = this._popoverEl.matches(":popover-open");
|
|
75
|
+
if (newValue && !isOpen) {
|
|
76
|
+
this._popoverEl.showPopover();
|
|
77
|
+
} else if (!newValue && isOpen) {
|
|
78
|
+
this._popoverEl.hidePopover();
|
|
79
|
+
}
|
|
80
|
+
this.#updateAutoUpdate();
|
|
81
|
+
}
|
|
82
|
+
anchorChanged() {
|
|
83
|
+
this.#updateAnchor();
|
|
84
|
+
}
|
|
85
|
+
_slottedAnchorChanged() {
|
|
86
|
+
this.#updateAnchor();
|
|
87
|
+
}
|
|
88
|
+
#currentAnchor;
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
#updateAnchor() {
|
|
93
|
+
if (!this._popoverEl) return;
|
|
94
|
+
const newAnchor = this.anchor || this._slottedAnchor?.[0] || null;
|
|
95
|
+
if (this.#currentAnchor === newAnchor) return;
|
|
96
|
+
if (this.#currentAnchor) {
|
|
97
|
+
this.#unbindTrigger(this.#currentAnchor);
|
|
98
|
+
}
|
|
99
|
+
this.#currentAnchor = newAnchor;
|
|
100
|
+
if (this.#currentAnchor && this._popoverEl) {
|
|
101
|
+
this.#bindTrigger(this.#currentAnchor);
|
|
102
|
+
this.#updateAutoUpdate();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
#bindTrigger(anchor) {
|
|
109
|
+
anchor.setAttribute("aria-haspopup", "dialog");
|
|
110
|
+
if (anchor instanceof HTMLButtonElement || anchor instanceof HTMLInputElement) {
|
|
111
|
+
anchor.popoverTargetElement = this._popoverEl;
|
|
112
|
+
} else {
|
|
113
|
+
anchor.addEventListener("click", this.#manualToggle);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
#unbindTrigger(anchor) {
|
|
120
|
+
anchor.removeAttribute("aria-haspopup");
|
|
121
|
+
if (anchor instanceof HTMLButtonElement || anchor instanceof HTMLInputElement) {
|
|
122
|
+
anchor.popoverTargetElement = null;
|
|
123
|
+
} else {
|
|
124
|
+
anchor.removeEventListener("click", this.#manualToggle);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
#manualToggle;
|
|
128
|
+
// --- Floating UI Logic ---
|
|
129
|
+
/**
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
get #middleware() {
|
|
133
|
+
let middleware = [dom.inline(), dom.flip(), dom.shift(), dom.hide()];
|
|
134
|
+
/* v8 ignore next -- @preserve */
|
|
135
|
+
let offsetValue = this.offset ?? 0;
|
|
136
|
+
if (this.arrow && this._arrowEl) {
|
|
137
|
+
offsetValue = 12;
|
|
138
|
+
middleware = [
|
|
139
|
+
...middleware,
|
|
140
|
+
dom.arrow({ element: this._arrowEl, padding: 10 })
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
/* v8 ignore else -- @preserve */
|
|
144
|
+
if (offsetValue > 0) {
|
|
145
|
+
middleware.unshift(dom.offset(offsetValue));
|
|
146
|
+
}
|
|
147
|
+
return middleware;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
#cleanup;
|
|
153
|
+
/**
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
#updateAutoUpdate() {
|
|
157
|
+
this.#cleanup?.();
|
|
158
|
+
if (this.open && this.#currentAnchor && this._popoverEl) {
|
|
159
|
+
this.#cleanup = dom.autoUpdate(
|
|
160
|
+
this.#currentAnchor,
|
|
161
|
+
this._popoverEl,
|
|
162
|
+
this.#autoUpdateCallback
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Tracks the promise of the last position update.
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
#lastPositionUpdate;
|
|
171
|
+
#autoUpdateCallback;
|
|
172
|
+
/**
|
|
173
|
+
* Updates the position of the popover
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
async updatePosition() {
|
|
177
|
+
/* v8 ignore if -- @preserve */
|
|
178
|
+
if (!this.open || !this.#currentAnchor || !this._popoverEl) return;
|
|
179
|
+
const positionData = await dom.computePosition(
|
|
180
|
+
this.#currentAnchor,
|
|
181
|
+
this._popoverEl,
|
|
182
|
+
{
|
|
183
|
+
placement: this.placement,
|
|
184
|
+
strategy: "fixed",
|
|
185
|
+
middleware: this.#middleware
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
/* v8 ignore if -- @preserve */
|
|
189
|
+
if (!this.open) return;
|
|
190
|
+
this.#assignPopoverPosition(positionData);
|
|
191
|
+
if (this.arrow && this._arrowEl) {
|
|
192
|
+
this.#assignArrowPosition(positionData);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
#assignPopoverPosition(data) {
|
|
199
|
+
const { x, y } = data;
|
|
200
|
+
Object.assign(this._popoverEl.style, {
|
|
201
|
+
left: `${x}px`,
|
|
202
|
+
top: `${y}px`,
|
|
203
|
+
visibility: data.middlewareData.hide?.referenceHidden ? "hidden" : "visible"
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
#assignArrowPosition(data) {
|
|
210
|
+
/* v8 ignore if -- @preserve */
|
|
211
|
+
if (!this._arrowEl) return;
|
|
212
|
+
const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
|
|
213
|
+
const styles = {
|
|
214
|
+
left: "calc(100% - 4px)",
|
|
215
|
+
right: "-4px",
|
|
216
|
+
top: "calc(100% - 4px)",
|
|
217
|
+
bottom: "-4px"
|
|
218
|
+
};
|
|
219
|
+
const staticAxis = data.placement.split("-")[0];
|
|
220
|
+
Object.assign(this._arrowEl.style, {
|
|
221
|
+
left: arrowX ? `${arrowX}px` : styles[staticAxis],
|
|
222
|
+
top: arrowY ? `${arrowY}px` : styles[staticAxis]
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
#handleNativeToggle;
|
|
226
|
+
connectedCallback() {
|
|
227
|
+
super.connectedCallback();
|
|
228
|
+
this.#updateAnchor();
|
|
229
|
+
/* v8 ignore else -- @preserve */
|
|
230
|
+
if (this._popoverEl) {
|
|
231
|
+
this._popoverEl.addEventListener("toggle", this.#handleNativeToggle);
|
|
232
|
+
if (this.open && !this._popoverEl.matches(":popover-open")) {
|
|
233
|
+
this._popoverEl.showPopover();
|
|
234
|
+
this.#updateAutoUpdate();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
disconnectedCallback() {
|
|
239
|
+
super.disconnectedCallback();
|
|
240
|
+
this.#cleanup?.();
|
|
241
|
+
if (this.#currentAnchor) {
|
|
242
|
+
this.#unbindTrigger(this.#currentAnchor);
|
|
243
|
+
this.#currentAnchor = null;
|
|
244
|
+
}
|
|
245
|
+
/* v8 ignore else -- @preserve */
|
|
246
|
+
if (this._popoverEl) {
|
|
247
|
+
this._popoverEl.removeEventListener("toggle", this.#handleNativeToggle);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// --- Methods ---
|
|
251
|
+
show() {
|
|
252
|
+
this.open = true;
|
|
253
|
+
return this.#lastPositionUpdate ?? Promise.resolve();
|
|
254
|
+
}
|
|
255
|
+
hide() {
|
|
256
|
+
this.open = false;
|
|
257
|
+
}
|
|
258
|
+
toggle() {
|
|
259
|
+
this.open = !this.open;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
__decorateClass([
|
|
263
|
+
fastElement.attr({ mode: "fromView" })
|
|
264
|
+
], Popover.prototype, "placement");
|
|
265
|
+
__decorateClass([
|
|
266
|
+
fastElement.attr({ mode: "boolean" })
|
|
267
|
+
], Popover.prototype, "manual");
|
|
268
|
+
__decorateClass([
|
|
269
|
+
fastElement.attr({ mode: "fromView" })
|
|
270
|
+
], Popover.prototype, "layout");
|
|
271
|
+
__decorateClass([
|
|
272
|
+
fastElement.attr({
|
|
273
|
+
attribute: "offset",
|
|
274
|
+
mode: "fromView",
|
|
275
|
+
converter: fastElement.nullableNumberConverter
|
|
276
|
+
})
|
|
277
|
+
], Popover.prototype, "offset");
|
|
278
|
+
__decorateClass([
|
|
279
|
+
fastElement.attr({
|
|
280
|
+
mode: "boolean"
|
|
281
|
+
})
|
|
282
|
+
], Popover.prototype, "alternate");
|
|
283
|
+
__decorateClass([
|
|
284
|
+
fastElement.attr({ attribute: "dismiss-button-aria-label" })
|
|
285
|
+
], Popover.prototype, "dismissButtonAriaLabel");
|
|
286
|
+
__decorateClass([
|
|
287
|
+
fastElement.attr({ mode: "boolean" })
|
|
288
|
+
], Popover.prototype, "arrow");
|
|
289
|
+
__decorateClass([
|
|
290
|
+
fastElement.attr({ mode: "boolean" })
|
|
291
|
+
], Popover.prototype, "open");
|
|
292
|
+
__decorateClass([
|
|
293
|
+
fastElement.observable
|
|
294
|
+
], Popover.prototype, "anchor");
|
|
295
|
+
__decorateClass([
|
|
296
|
+
fastElement.observable
|
|
297
|
+
], Popover.prototype, "_slottedAnchor");
|
|
298
|
+
|
|
299
|
+
const getClasses = ({ open, manual, layout }) => fastWebUtilities.classNames(
|
|
300
|
+
"control",
|
|
301
|
+
["open", Boolean(open)],
|
|
302
|
+
["manual", Boolean(manual)],
|
|
303
|
+
["condensed", layout === "condensed"]
|
|
304
|
+
);
|
|
305
|
+
const popoverTemplate = (context) => {
|
|
306
|
+
const elevationTag = context.tagFor(elevation_definition.Elevation);
|
|
307
|
+
const buttonTag = context.tagFor(button_definition.Button);
|
|
308
|
+
const iconTag = context.tagFor(icon_definition.VwcIconElement);
|
|
309
|
+
return fastElement.html`
|
|
310
|
+
<slot name="anchor" ${fastElement.slotted("_slottedAnchor")}></slot>
|
|
311
|
+
<${elevationTag}>
|
|
312
|
+
<div class="base"
|
|
313
|
+
${fastElement.ref("_popoverEl")}
|
|
314
|
+
popover="${(x) => x.manual ? "manual" : "auto"}"
|
|
315
|
+
tabindex="-1"
|
|
316
|
+
autofocus
|
|
317
|
+
${delegatesAria.delegateAria({
|
|
318
|
+
role: "dialog",
|
|
319
|
+
ariaModal: "false"
|
|
320
|
+
})}
|
|
321
|
+
>
|
|
322
|
+
<div class="${getClasses}"
|
|
323
|
+
part="${(x) => x.alternate ? "vvd-theme-alternate" : ""}">
|
|
324
|
+
<slot></slot>
|
|
325
|
+
<slot name="footer"></slot>
|
|
326
|
+
${fastElement.when(
|
|
327
|
+
(x) => x.manual,
|
|
328
|
+
fastElement.html`<${buttonTag}
|
|
329
|
+
aria-label="${(x) => x.dismissButtonAriaLabel || x.locale.popover.dismissButtonLabel}"
|
|
330
|
+
type="button"
|
|
331
|
+
size="condensed"
|
|
332
|
+
class="dismiss-button"
|
|
333
|
+
@click="${(x) => x.hide()}">
|
|
334
|
+
<${iconTag} name="close-line" slot="icon"></${iconTag}>
|
|
335
|
+
</${buttonTag}>`
|
|
336
|
+
)}
|
|
337
|
+
${fastElement.when(
|
|
338
|
+
(x) => x.arrow,
|
|
339
|
+
fastElement.html`<div class="arrow" ${fastElement.ref("_arrowEl")}></div>`
|
|
340
|
+
)}
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
</${elevationTag}>
|
|
344
|
+
`;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
const popoverDefinition = vividElement.defineVividComponent(
|
|
348
|
+
"popover",
|
|
349
|
+
Popover,
|
|
350
|
+
popoverTemplate,
|
|
351
|
+
[button_definition.buttonDefinition, icon_definition.iconDefinition, elevation_definition.elevationDefinition],
|
|
352
|
+
{
|
|
353
|
+
styles,
|
|
354
|
+
shadowOptions: {
|
|
355
|
+
delegatesFocus: true
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
const registerPopover = vividElement.createRegisterFunction(popoverDefinition);
|
|
360
|
+
|
|
361
|
+
exports.VwcPopoverElement = Popover;
|
|
362
|
+
exports.popoverDefinition = popoverDefinition;
|
|
363
|
+
exports.registerPopover = registerPopover;
|