@vonage/vivid 5.3.0 → 5.5.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/accordion-item/definition.js +1 -1
- package/alert/definition.cjs +1 -1
- package/alert/definition.js +2 -2
- package/badge/definition.js +1 -1
- package/banner/definition.js +1 -1
- package/bundled/base-color-picker.cjs +18 -13
- package/bundled/base-color-picker.js +98 -81
- package/bundled/calendar-picker.template.cjs +7 -7
- package/bundled/calendar-picker.template.js +102 -102
- package/bundled/char-count.cjs +1 -1
- package/bundled/char-count.js +1 -1
- package/bundled/definition10.cjs +1 -1
- package/bundled/definition10.js +2 -2
- package/bundled/definition11.cjs +12 -19
- package/bundled/definition11.js +87 -66
- package/bundled/definition12.cjs +19 -10
- package/bundled/definition12.js +217 -36
- package/bundled/definition13.cjs +10 -1
- package/bundled/definition13.js +38 -14
- package/bundled/definition14.cjs +1 -5
- package/bundled/definition14.js +15 -24
- package/bundled/definition15.cjs +5 -30
- package/bundled/definition15.js +22 -73
- package/bundled/definition16.cjs +30 -19
- package/bundled/definition16.js +74 -97
- package/bundled/definition17.cjs +19 -13
- package/bundled/definition17.js +83 -117
- package/bundled/definition18.cjs +13 -12
- package/bundled/definition18.js +114 -71
- package/bundled/definition19.cjs +26 -27
- package/bundled/definition19.js +171 -180
- package/bundled/definition2.cjs +9 -9
- package/bundled/definition2.js +84 -129
- package/bundled/definition3.cjs +1 -1
- package/bundled/definition3.js +1 -1
- package/bundled/definition6.cjs +3 -3
- package/bundled/definition6.js +19 -19
- package/bundled/definition9.cjs +5 -5
- package/bundled/definition9.js +394 -392
- package/bundled/listbox.cjs +1 -1
- package/bundled/listbox.js +82 -102
- package/bundled/localized.cjs +1 -1
- package/bundled/localized.js +48 -31
- package/bundled/mixins.cjs +1 -1
- package/bundled/mixins.js +1 -1
- package/bundled/picker-field.template.cjs +14 -14
- package/bundled/picker-field.template.js +35 -56
- package/bundled/time-selection-picker.template.cjs +12 -12
- package/bundled/time-selection-picker.template.js +13 -12
- package/bundled/trapped-focus.cjs +1 -0
- package/bundled/trapped-focus.js +26 -0
- package/bundled/vivid-element.cjs +5 -1
- package/bundled/vivid-element.js +401 -358
- package/calendar/index.cjs +13 -13
- package/calendar/index.js +171 -143
- package/card/definition.cjs +1 -1
- package/card/definition.js +1 -1
- package/color-picker/definition.cjs +209 -113
- package/color-picker/definition.js +209 -113
- package/color-picker/index.cjs +104 -75
- package/color-picker/index.js +412 -326
- package/combobox/definition.cjs +7 -27
- package/combobox/definition.js +8 -28
- package/combobox/index.cjs +6 -6
- package/combobox/index.js +57 -71
- package/contextual-help/index.cjs +1 -1
- package/contextual-help/index.js +1 -1
- package/custom-elements.json +354 -2
- package/data-grid/index.cjs +1 -1
- package/data-grid/index.js +1 -1
- package/date-picker/definition.cjs +1 -1
- package/date-picker/definition.js +1 -1
- package/date-picker/index.cjs +1 -1
- package/date-picker/index.js +2 -2
- package/date-range-picker/definition.cjs +1 -1
- package/date-range-picker/definition.js +1 -1
- package/date-range-picker/index.cjs +1 -1
- package/date-range-picker/index.js +2 -2
- package/date-time-picker/definition.cjs +1 -1
- package/date-time-picker/definition.js +1 -1
- package/date-time-picker/index.cjs +1 -1
- package/date-time-picker/index.js +2 -2
- package/dial-pad/definition.cjs +139 -0
- package/dial-pad/definition.js +139 -0
- package/dial-pad/index.cjs +27 -20
- package/dial-pad/index.js +177 -100
- package/dialog/definition.cjs +2 -2
- package/dialog/definition.js +2 -2
- package/dialog/index.cjs +7 -7
- package/dialog/index.js +6 -6
- package/divider/index.cjs +1 -1
- package/divider/index.js +1 -1
- package/elevation/definition.cjs +1 -1
- package/elevation/definition.js +1 -1
- package/fab/definition.js +1 -1
- package/header/definition.cjs +1 -1
- package/header/definition.js +1 -1
- package/icon/definition.cjs +56 -22
- package/icon/definition.js +56 -22
- package/index.cjs +3 -4
- package/index.js +2 -3
- package/lib/accordion/accordion.d.ts +1 -1
- package/lib/accordion/definition.d.ts +1 -1
- package/lib/audio-player/audio-player.d.ts +1 -1
- package/lib/color-picker/color-picker.d.ts +390 -12
- package/lib/color-picker/locale.d.ts +4 -0
- package/lib/combobox/combobox.d.ts +1 -0
- package/lib/combobox/combobox.options.d.ts +1 -1
- package/lib/date-picker/date-picker.d.ts +38 -38
- package/lib/date-range-picker/date-range-picker.d.ts +20 -20
- package/lib/date-time-picker/date-time-picker.d.ts +40 -40
- package/lib/dial-pad/dial-pad.d.ts +1 -0
- package/lib/divider/divider.d.ts +1 -1
- package/lib/icon/icon.d.ts +1 -0
- package/lib/menu-item/menu-item-role.d.ts +1 -1
- package/lib/popup/popup.d.ts +1 -1
- package/lib/searchable-select/locale.d.ts +4 -0
- package/lib/searchable-select/searchable-select.d.ts +3 -0
- package/lib/select/select.d.ts +3 -1
- package/lib/simple-color-picker/simple-color-picker.d.ts +2 -1
- package/lib/slider/slider.d.ts +1 -1
- package/lib/tabs/tabs.d.ts +2 -2
- package/lib/text-area/text-area.d.ts +1 -1
- package/lib/text-field/text-field.d.ts +1 -1
- package/lib/time-picker/time-picker.d.ts +20 -20
- package/locales/de-DE.cjs +20 -3
- package/locales/de-DE.js +20 -3
- package/locales/en-GB.cjs +21 -4
- package/locales/en-GB.js +21 -4
- package/locales/en-US.cjs +21 -4
- package/locales/en-US.js +21 -4
- package/locales/ja-JP.cjs +20 -3
- package/locales/ja-JP.js +20 -3
- package/locales/zh-CN.cjs +19 -2
- package/locales/zh-CN.js +19 -2
- package/menu/definition.cjs +4 -4
- package/menu/definition.js +4 -4
- package/nav-disclosure/definition.js +1 -1
- package/nav-item/definition.js +1 -1
- package/note/definition.js +1 -1
- package/number-field/definition.js +1 -1
- package/number-field/index.cjs +1 -1
- package/number-field/index.js +3 -3
- package/option/definition.cjs +6 -77
- package/option/definition.js +3 -78
- package/option/index.cjs +1 -1
- package/option/index.js +1 -1
- package/package.json +31 -5
- package/popup/definition.cjs +2 -2
- package/popup/definition.js +2 -2
- package/progress-ring/index.cjs +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.cjs +1 -1
- package/radio/index.js +1 -1
- package/radio-group/index.cjs +1 -1
- package/radio-group/index.js +1 -1
- package/range-slider/definition.cjs +1 -1
- package/range-slider/definition.js +1 -1
- package/rich-text-editor/definition.cjs +2 -3
- package/rich-text-editor/definition.js +1 -2
- package/rich-text-editor/index.cjs +27 -27
- package/rich-text-editor/index.js +1209 -1199
- package/searchable-select/definition.cjs +103 -11
- package/searchable-select/definition.js +103 -11
- package/searchable-select/index.cjs +81 -69
- package/searchable-select/index.js +359 -273
- package/select/definition.cjs +30 -44
- package/select/definition.js +30 -44
- package/selectable-box/definition.cjs +1 -1
- package/selectable-box/definition.js +1 -1
- package/selectable-box/index.cjs +1 -1
- package/selectable-box/index.js +2 -2
- package/shared/aria/aria-mixin.d.ts +1 -1
- package/shared/color-picker/base-color-picker.d.ts +2 -1
- package/shared/foundation/listbox/listbox.d.ts +4 -0
- package/shared/picker-field/mixins/calendar-picker.d.ts +10 -10
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +10 -10
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +20 -20
- package/shared/picker-field/mixins/single-date-picker.d.ts +28 -28
- package/shared/picker-field/mixins/single-value-picker.d.ts +8 -8
- package/shared/picker-field/mixins/time-selection-picker.d.ts +20 -20
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +20 -20
- package/simple-color-picker/definition.cjs +9 -7
- package/simple-color-picker/definition.js +9 -7
- package/simple-color-picker/index.cjs +6 -6
- package/simple-color-picker/index.js +41 -39
- package/slider/definition.cjs +1 -1
- package/slider/definition.js +1 -1
- package/split-button/definition.js +1 -1
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/tab/definition.js +1 -1
- package/tag/definition.cjs +34 -14
- package/tag/definition.js +35 -15
- package/tag/index.cjs +25 -12
- package/tag/index.js +64 -47
- package/tag-group/definition.cjs +1 -2
- package/tag-group/definition.js +1 -2
- package/tag-group/index.cjs +1 -1
- package/tag-group/index.js +11 -12
- package/text-area/index.cjs +1 -1
- package/text-area/index.js +2 -2
- package/text-field/definition.js +1 -1
- package/time-picker/definition.cjs +1 -1
- package/time-picker/definition.js +1 -1
- package/time-picker/index.cjs +1 -1
- package/time-picker/index.js +1 -1
- package/toggletip/definition.cjs +1 -1
- package/toggletip/definition.js +1 -1
- package/toggletip/index.cjs +1 -1
- package/toggletip/index.js +1 -1
- package/tooltip/definition.cjs +3 -3
- package/tooltip/definition.js +3 -3
- package/tooltip/index.cjs +1 -1
- package/tooltip/index.js +1 -1
- package/tree-item/definition.cjs +1 -1
- package/tree-item/definition.js +1 -1
- package/tree-view/definition.cjs +1 -1
- package/tree-view/definition.js +1 -1
- package/unbundled/affix.js +1 -1
- package/unbundled/base-color-picker.cjs +36 -18
- package/unbundled/base-color-picker.js +36 -18
- package/unbundled/calendar-picker.template.cjs +2 -2
- package/unbundled/calendar-picker.template.js +2 -2
- package/unbundled/definition.js +1 -1
- package/unbundled/definition2.js +1 -1
- package/unbundled/definition3.cjs +222 -141
- package/unbundled/definition3.js +220 -139
- package/unbundled/definition4.cjs +145 -235
- package/unbundled/definition4.js +143 -233
- package/unbundled/definition5.cjs +269 -27
- package/unbundled/definition5.js +267 -26
- package/unbundled/definition6.cjs +56 -0
- package/unbundled/definition6.js +52 -0
- package/unbundled/listbox.cjs +41 -63
- package/unbundled/listbox.js +39 -61
- package/unbundled/picker-field.template.cjs +3 -36
- package/unbundled/picker-field.template.js +3 -35
- package/unbundled/slider.template.cjs +1 -1
- package/unbundled/slider.template.js +1 -1
- package/unbundled/time-selection-picker.template.cjs +2 -1
- package/unbundled/time-selection-picker.template.js +2 -1
- package/unbundled/trapped-focus.cjs +37 -0
- package/unbundled/trapped-focus.js +34 -0
- package/unbundled/vivid-element.cjs +1 -1
- package/unbundled/vivid-element.js +1 -1
- package/video-player/definition.cjs +56 -16
- package/video-player/definition.js +56 -16
- package/video-player/index.cjs +36 -36
- package/video-player/index.js +2461 -2445
- package/visually-hidden/index.cjs +1 -1
- package/visually-hidden/index.js +1 -1
- package/vivid.api.json +285 -38
- package/bundled/_has.cjs +0 -1
- package/bundled/_has.js +0 -34
- package/bundled/option.cjs +0 -1
- package/bundled/option.js +0 -158
- package/unbundled/option.cjs +0 -217
- package/unbundled/option.js +0 -214
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const button_definition = require('./definition.cjs');
|
|
4
|
+
const elevation_definition = require('./definition6.cjs');
|
|
3
5
|
const vividElement = require('./vivid-element.cjs');
|
|
4
6
|
const fastElement = require('@microsoft/fast-element');
|
|
7
|
+
const dom = require('@floating-ui/dom');
|
|
5
8
|
const fastWebUtilities = require('@microsoft/fast-web-utilities');
|
|
6
9
|
|
|
7
10
|
var __defProp = Object.defineProperty;
|
|
@@ -13,44 +16,283 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
13
16
|
if (result) __defProp(target, key, result);
|
|
14
17
|
return result;
|
|
15
18
|
};
|
|
16
|
-
|
|
19
|
+
const PlacementStrategy = {
|
|
20
|
+
Flip: "flip",
|
|
21
|
+
AutoPlacementHorizontal: "auto-placement-horizontal",
|
|
22
|
+
AutoPlacementVertical: "auto-placement-vertical"
|
|
23
|
+
};
|
|
24
|
+
const placementStrategyMiddlewares = {
|
|
25
|
+
[PlacementStrategy.Flip]: dom.flip(),
|
|
26
|
+
[PlacementStrategy.AutoPlacementHorizontal]: dom.autoPlacement({
|
|
27
|
+
allowedPlacements: [
|
|
28
|
+
"bottom",
|
|
29
|
+
"top",
|
|
30
|
+
"bottom-start",
|
|
31
|
+
"bottom-end",
|
|
32
|
+
"top-start",
|
|
33
|
+
"top-end"
|
|
34
|
+
]
|
|
35
|
+
}),
|
|
36
|
+
[PlacementStrategy.AutoPlacementVertical]: dom.autoPlacement({
|
|
37
|
+
allowedPlacements: [
|
|
38
|
+
"left",
|
|
39
|
+
"right",
|
|
40
|
+
"left-start",
|
|
41
|
+
"left-end",
|
|
42
|
+
"right-start",
|
|
43
|
+
"right-end"
|
|
44
|
+
]
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
class Popup extends vividElement.VividElement {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
this.open = false;
|
|
51
|
+
this.dismissible = false;
|
|
52
|
+
this.arrow = false;
|
|
53
|
+
this.alternate = false;
|
|
54
|
+
/**
|
|
55
|
+
* The placement strategy of the popup.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
this.placementStrategy = PlacementStrategy.Flip;
|
|
60
|
+
this.animationFrame = false;
|
|
61
|
+
this.strategy = "fixed";
|
|
62
|
+
this.offset = null;
|
|
63
|
+
this.#autoUpdateCallback = () => {
|
|
64
|
+
this.#lastPositionUpdate = this.updatePosition();
|
|
65
|
+
return this.#lastPositionUpdate;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
get #middleware() {
|
|
69
|
+
let middleware = [
|
|
70
|
+
dom.inline(),
|
|
71
|
+
placementStrategyMiddlewares[this.placementStrategy],
|
|
72
|
+
dom.hide(),
|
|
73
|
+
dom.size({
|
|
74
|
+
apply({ availableWidth, availableHeight, elements }) {
|
|
75
|
+
Object.assign(elements.floating.style, {
|
|
76
|
+
maxWidth: `${availableWidth}px`,
|
|
77
|
+
maxHeight: `${availableHeight}px`
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
];
|
|
82
|
+
let offsetValue = this.offset ?? 0;
|
|
83
|
+
if (this.arrow) {
|
|
84
|
+
offsetValue += 12;
|
|
85
|
+
middleware = [
|
|
86
|
+
...middleware,
|
|
87
|
+
dom.arrow({ element: this.arrowEl, padding: 10 })
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
if (offsetValue > 0) {
|
|
91
|
+
middleware.unshift(dom.offset(offsetValue));
|
|
92
|
+
}
|
|
93
|
+
return middleware;
|
|
94
|
+
}
|
|
95
|
+
#cleanup;
|
|
96
|
+
openChanged(_, newValue) {
|
|
97
|
+
this.#togglePopover();
|
|
98
|
+
this.#updateAutoUpdate();
|
|
99
|
+
this.$emit(newValue ? "vwc-popup:open" : "vwc-popup:close");
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
animationFrameChanged() {
|
|
105
|
+
this.#updateAutoUpdate();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
anchorChanged() {
|
|
111
|
+
this.#updateAutoUpdate();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
strategyChanged() {
|
|
117
|
+
this.#togglePopover();
|
|
118
|
+
}
|
|
119
|
+
connectedCallback() {
|
|
120
|
+
super.connectedCallback();
|
|
121
|
+
this.#togglePopover();
|
|
122
|
+
this.#updateAutoUpdate();
|
|
123
|
+
}
|
|
124
|
+
disconnectedCallback() {
|
|
125
|
+
super.disconnectedCallback();
|
|
126
|
+
this.#updateAutoUpdate();
|
|
127
|
+
}
|
|
128
|
+
#updateAutoUpdate() {
|
|
129
|
+
this.#cleanup?.();
|
|
130
|
+
if (this.open && this.controlEl) {
|
|
131
|
+
this.controlEl.classList.add("open");
|
|
132
|
+
}
|
|
133
|
+
if (this.anchorEl && this.open && this.popupEl) {
|
|
134
|
+
this.#cleanup = dom.autoUpdate(
|
|
135
|
+
this.anchorEl,
|
|
136
|
+
this.popupEl,
|
|
137
|
+
this.#autoUpdateCallback,
|
|
138
|
+
{
|
|
139
|
+
animationFrame: this.animationFrame
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
#togglePopover() {
|
|
145
|
+
if (this.popupEl && this.strategy === "fixed") {
|
|
146
|
+
if (this.open) {
|
|
147
|
+
this.popupEl.showPopover();
|
|
148
|
+
} else {
|
|
149
|
+
this.popupEl.hidePopover();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
#lastPositionUpdate;
|
|
154
|
+
#autoUpdateCallback;
|
|
155
|
+
/**
|
|
156
|
+
* Updates popup's position
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
async updatePosition() {
|
|
161
|
+
if (!this.open || !this.anchorEl) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const positionData = await dom.computePosition(this.anchorEl, this.popupEl, {
|
|
165
|
+
placement: this.placement,
|
|
166
|
+
strategy: this.strategy,
|
|
167
|
+
middleware: this.#middleware
|
|
168
|
+
});
|
|
169
|
+
this.#assignPopupPosition(positionData);
|
|
170
|
+
if (this.arrow) {
|
|
171
|
+
this.#assignArrowPosition(positionData);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
#assignPopupPosition(data) {
|
|
175
|
+
const { x: popupX, y: popupY } = data;
|
|
176
|
+
const { referenceHidden } = data.middlewareData.hide;
|
|
177
|
+
Object.assign(this.popupEl.style, {
|
|
178
|
+
left: `${popupX}px`,
|
|
179
|
+
top: `${popupY}px`,
|
|
180
|
+
visibility: referenceHidden ? "hidden" : "visible"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
#assignArrowPosition(data) {
|
|
184
|
+
const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
|
|
185
|
+
const styles = {
|
|
186
|
+
left: "calc(100% - 4px)",
|
|
187
|
+
right: "-4px",
|
|
188
|
+
top: "calc(100% - 4px)",
|
|
189
|
+
bottom: "-4px"
|
|
190
|
+
};
|
|
191
|
+
const staticAxis = data.placement.split("-")[0];
|
|
192
|
+
Object.assign(this.arrowEl.style, {
|
|
193
|
+
left: arrowX ? `${arrowX}px` : styles[staticAxis],
|
|
194
|
+
top: arrowY ? `${arrowY}px` : styles[staticAxis]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
get anchorEl() {
|
|
198
|
+
return this.anchor ?? null;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Shows the popup.
|
|
202
|
+
* Unlike toggling the `open` attribute, show() will wait for the popup to become visible and positioned correctly.
|
|
203
|
+
*/
|
|
204
|
+
show() {
|
|
205
|
+
this.open = true;
|
|
206
|
+
return this.#lastPositionUpdate ?? Promise.resolve();
|
|
207
|
+
}
|
|
208
|
+
hide() {
|
|
209
|
+
this.open = false;
|
|
210
|
+
}
|
|
17
211
|
}
|
|
18
212
|
__decorateClass([
|
|
19
|
-
fastElement.attr
|
|
20
|
-
|
|
213
|
+
fastElement.attr({
|
|
214
|
+
mode: "boolean"
|
|
215
|
+
})
|
|
216
|
+
], Popup.prototype, "open");
|
|
217
|
+
__decorateClass([
|
|
218
|
+
fastElement.attr({
|
|
219
|
+
mode: "boolean"
|
|
220
|
+
})
|
|
221
|
+
], Popup.prototype, "dismissible");
|
|
222
|
+
__decorateClass([
|
|
223
|
+
fastElement.attr({
|
|
224
|
+
mode: "boolean"
|
|
225
|
+
})
|
|
226
|
+
], Popup.prototype, "arrow");
|
|
21
227
|
__decorateClass([
|
|
22
|
-
fastElement.attr({
|
|
23
|
-
|
|
228
|
+
fastElement.attr({
|
|
229
|
+
mode: "boolean"
|
|
230
|
+
})
|
|
231
|
+
], Popup.prototype, "alternate");
|
|
24
232
|
__decorateClass([
|
|
25
|
-
fastElement.attr({
|
|
26
|
-
],
|
|
233
|
+
fastElement.attr({ mode: "fromView" })
|
|
234
|
+
], Popup.prototype, "placement");
|
|
235
|
+
__decorateClass([
|
|
236
|
+
fastElement.attr({ mode: "boolean", attribute: "animation-frame" })
|
|
237
|
+
], Popup.prototype, "animationFrame");
|
|
238
|
+
__decorateClass([
|
|
239
|
+
fastElement.attr({ mode: "fromView" })
|
|
240
|
+
], Popup.prototype, "strategy");
|
|
241
|
+
__decorateClass([
|
|
242
|
+
fastElement.attr({ attribute: "offset", converter: fastElement.nullableNumberConverter })
|
|
243
|
+
], Popup.prototype, "offset");
|
|
244
|
+
__decorateClass([
|
|
245
|
+
fastElement.observable
|
|
246
|
+
], Popup.prototype, "anchor");
|
|
27
247
|
|
|
28
|
-
const styles = ":host{display:
|
|
248
|
+
const styles = ":host{display:var(--_popup-display, inline)}.control{border-radius:inherit;background:var(--vvd-color-surface-4dp);contain:layout}.control:not(.open){display:none}.popup-wrapper{white-space:initial;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.popup-wrapper{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.popup-wrapper ::-webkit-scrollbar{width:4px}.popup-wrapper ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.popup-wrapper ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}.popup-wrapper{z-index:var(--_popup-z-index, 10);overflow:visible;padding:0;border:none;border-radius:8px;margin:0;inline-size:max-content}.popup-wrapper:not(.absolute){position:fixed}.popup-wrapper.absolute{position:absolute;top:0;left:0}.popup-content{display:grid;color:var(--vvd-color-canvas-text)}.dismissible .popup-content{align-content:start;grid-template-columns:1fr auto}.arrow{position:absolute;z-index:-1;width:8px;height:8px;background:var(--vvd-color-surface-4dp);transform:rotate(45deg)}.dismissible-button{align-self:flex-start;margin-block-start:4px;margin-inline-end:4px}";
|
|
29
249
|
|
|
30
|
-
const getClasses = ({
|
|
250
|
+
const getClasses = ({ open, dismissible, alternate }) => fastWebUtilities.classNames(
|
|
31
251
|
"control",
|
|
32
|
-
[
|
|
33
|
-
["
|
|
34
|
-
["
|
|
252
|
+
["open", Boolean(open)],
|
|
253
|
+
["dismissible", Boolean(dismissible)],
|
|
254
|
+
["alternate", Boolean(alternate)]
|
|
35
255
|
);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
256
|
+
function handlePopover(x) {
|
|
257
|
+
return x.strategy && x.strategy === "fixed" ? "manual" : null;
|
|
258
|
+
}
|
|
259
|
+
const popupTemplate = (context) => {
|
|
260
|
+
const elevationTag = context.tagFor(elevation_definition.Elevation);
|
|
261
|
+
const buttonTag = context.tagFor(button_definition.Button);
|
|
262
|
+
return fastElement.html`
|
|
263
|
+
<${elevationTag}>
|
|
264
|
+
<div popover="${handlePopover}" class="popup-wrapper ${(x) => x.strategy}" ${fastElement.ref("popupEl")} part="popup-base">
|
|
265
|
+
<div ${fastElement.ref("controlEl")} class="${getClasses}" aria-hidden="${(x) => x.open ? "false" : "true"}"
|
|
266
|
+
part="${(x) => x.alternate ? "vvd-theme-alternate" : ""}">
|
|
267
|
+
<div class="popup-content">
|
|
268
|
+
<slot></slot>
|
|
269
|
+
${fastElement.when(
|
|
270
|
+
(x) => x.dismissible,
|
|
271
|
+
fastElement.html`<${buttonTag} size="condensed" @click="${(x) => x.open = false}"
|
|
272
|
+
class="dismissible-button" icon="close-small-solid" shape="pill"></${buttonTag}>`
|
|
273
|
+
)}
|
|
274
|
+
</div>
|
|
275
|
+
${fastElement.when(
|
|
276
|
+
(x) => x.arrow,
|
|
277
|
+
fastElement.html`<div class="arrow" ${fastElement.ref("arrowEl")}></div>`
|
|
278
|
+
)}
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
</${elevationTag}>`;
|
|
282
|
+
};
|
|
42
283
|
|
|
43
|
-
const
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
[],
|
|
284
|
+
const popupDefinition = vividElement.defineVividComponent(
|
|
285
|
+
"popup",
|
|
286
|
+
Popup,
|
|
287
|
+
popupTemplate,
|
|
288
|
+
[elevation_definition.elevationDefinition, button_definition.buttonDefinition],
|
|
48
289
|
{
|
|
49
290
|
styles
|
|
50
291
|
}
|
|
51
292
|
);
|
|
52
|
-
const
|
|
293
|
+
const registerPopup = vividElement.createRegisterFunction(popupDefinition);
|
|
53
294
|
|
|
54
|
-
exports.
|
|
55
|
-
exports.
|
|
56
|
-
exports.
|
|
295
|
+
exports.PlacementStrategy = PlacementStrategy;
|
|
296
|
+
exports.Popup = Popup;
|
|
297
|
+
exports.popupDefinition = popupDefinition;
|
|
298
|
+
exports.registerPopup = registerPopup;
|
package/unbundled/definition5.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { B as Button, b as buttonDefinition } from './definition.js';
|
|
2
|
+
import { E as Elevation, e as elevationDefinition } from './definition6.js';
|
|
1
3
|
import { V as VividElement, d as defineVividComponent, c as createRegisterFunction } from './vivid-element.js';
|
|
2
|
-
import { attr, html } from '@microsoft/fast-element';
|
|
4
|
+
import { attr, nullableNumberConverter, observable, ref, when, html } from '@microsoft/fast-element';
|
|
5
|
+
import { inline, autoPlacement, flip, hide, size, arrow, offset, autoUpdate, computePosition } from '@floating-ui/dom';
|
|
3
6
|
import { classNames } from '@microsoft/fast-web-utilities';
|
|
4
7
|
|
|
5
8
|
var __defProp = Object.defineProperty;
|
|
@@ -11,42 +14,280 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
11
14
|
if (result) __defProp(target, key, result);
|
|
12
15
|
return result;
|
|
13
16
|
};
|
|
14
|
-
|
|
17
|
+
const PlacementStrategy = {
|
|
18
|
+
Flip: "flip",
|
|
19
|
+
AutoPlacementHorizontal: "auto-placement-horizontal",
|
|
20
|
+
AutoPlacementVertical: "auto-placement-vertical"
|
|
21
|
+
};
|
|
22
|
+
const placementStrategyMiddlewares = {
|
|
23
|
+
[PlacementStrategy.Flip]: flip(),
|
|
24
|
+
[PlacementStrategy.AutoPlacementHorizontal]: autoPlacement({
|
|
25
|
+
allowedPlacements: [
|
|
26
|
+
"bottom",
|
|
27
|
+
"top",
|
|
28
|
+
"bottom-start",
|
|
29
|
+
"bottom-end",
|
|
30
|
+
"top-start",
|
|
31
|
+
"top-end"
|
|
32
|
+
]
|
|
33
|
+
}),
|
|
34
|
+
[PlacementStrategy.AutoPlacementVertical]: autoPlacement({
|
|
35
|
+
allowedPlacements: [
|
|
36
|
+
"left",
|
|
37
|
+
"right",
|
|
38
|
+
"left-start",
|
|
39
|
+
"left-end",
|
|
40
|
+
"right-start",
|
|
41
|
+
"right-end"
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
class Popup extends VividElement {
|
|
46
|
+
constructor() {
|
|
47
|
+
super(...arguments);
|
|
48
|
+
this.open = false;
|
|
49
|
+
this.dismissible = false;
|
|
50
|
+
this.arrow = false;
|
|
51
|
+
this.alternate = false;
|
|
52
|
+
/**
|
|
53
|
+
* The placement strategy of the popup.
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
this.placementStrategy = PlacementStrategy.Flip;
|
|
58
|
+
this.animationFrame = false;
|
|
59
|
+
this.strategy = "fixed";
|
|
60
|
+
this.offset = null;
|
|
61
|
+
this.#autoUpdateCallback = () => {
|
|
62
|
+
this.#lastPositionUpdate = this.updatePosition();
|
|
63
|
+
return this.#lastPositionUpdate;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
get #middleware() {
|
|
67
|
+
let middleware = [
|
|
68
|
+
inline(),
|
|
69
|
+
placementStrategyMiddlewares[this.placementStrategy],
|
|
70
|
+
hide(),
|
|
71
|
+
size({
|
|
72
|
+
apply({ availableWidth, availableHeight, elements }) {
|
|
73
|
+
Object.assign(elements.floating.style, {
|
|
74
|
+
maxWidth: `${availableWidth}px`,
|
|
75
|
+
maxHeight: `${availableHeight}px`
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
];
|
|
80
|
+
let offsetValue = this.offset ?? 0;
|
|
81
|
+
if (this.arrow) {
|
|
82
|
+
offsetValue += 12;
|
|
83
|
+
middleware = [
|
|
84
|
+
...middleware,
|
|
85
|
+
arrow({ element: this.arrowEl, padding: 10 })
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
if (offsetValue > 0) {
|
|
89
|
+
middleware.unshift(offset(offsetValue));
|
|
90
|
+
}
|
|
91
|
+
return middleware;
|
|
92
|
+
}
|
|
93
|
+
#cleanup;
|
|
94
|
+
openChanged(_, newValue) {
|
|
95
|
+
this.#togglePopover();
|
|
96
|
+
this.#updateAutoUpdate();
|
|
97
|
+
this.$emit(newValue ? "vwc-popup:open" : "vwc-popup:close");
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
animationFrameChanged() {
|
|
103
|
+
this.#updateAutoUpdate();
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
anchorChanged() {
|
|
109
|
+
this.#updateAutoUpdate();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
strategyChanged() {
|
|
115
|
+
this.#togglePopover();
|
|
116
|
+
}
|
|
117
|
+
connectedCallback() {
|
|
118
|
+
super.connectedCallback();
|
|
119
|
+
this.#togglePopover();
|
|
120
|
+
this.#updateAutoUpdate();
|
|
121
|
+
}
|
|
122
|
+
disconnectedCallback() {
|
|
123
|
+
super.disconnectedCallback();
|
|
124
|
+
this.#updateAutoUpdate();
|
|
125
|
+
}
|
|
126
|
+
#updateAutoUpdate() {
|
|
127
|
+
this.#cleanup?.();
|
|
128
|
+
if (this.open && this.controlEl) {
|
|
129
|
+
this.controlEl.classList.add("open");
|
|
130
|
+
}
|
|
131
|
+
if (this.anchorEl && this.open && this.popupEl) {
|
|
132
|
+
this.#cleanup = autoUpdate(
|
|
133
|
+
this.anchorEl,
|
|
134
|
+
this.popupEl,
|
|
135
|
+
this.#autoUpdateCallback,
|
|
136
|
+
{
|
|
137
|
+
animationFrame: this.animationFrame
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
#togglePopover() {
|
|
143
|
+
if (this.popupEl && this.strategy === "fixed") {
|
|
144
|
+
if (this.open) {
|
|
145
|
+
this.popupEl.showPopover();
|
|
146
|
+
} else {
|
|
147
|
+
this.popupEl.hidePopover();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
#lastPositionUpdate;
|
|
152
|
+
#autoUpdateCallback;
|
|
153
|
+
/**
|
|
154
|
+
* Updates popup's position
|
|
155
|
+
*
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
async updatePosition() {
|
|
159
|
+
if (!this.open || !this.anchorEl) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const positionData = await computePosition(this.anchorEl, this.popupEl, {
|
|
163
|
+
placement: this.placement,
|
|
164
|
+
strategy: this.strategy,
|
|
165
|
+
middleware: this.#middleware
|
|
166
|
+
});
|
|
167
|
+
this.#assignPopupPosition(positionData);
|
|
168
|
+
if (this.arrow) {
|
|
169
|
+
this.#assignArrowPosition(positionData);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
#assignPopupPosition(data) {
|
|
173
|
+
const { x: popupX, y: popupY } = data;
|
|
174
|
+
const { referenceHidden } = data.middlewareData.hide;
|
|
175
|
+
Object.assign(this.popupEl.style, {
|
|
176
|
+
left: `${popupX}px`,
|
|
177
|
+
top: `${popupY}px`,
|
|
178
|
+
visibility: referenceHidden ? "hidden" : "visible"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
#assignArrowPosition(data) {
|
|
182
|
+
const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
|
|
183
|
+
const styles = {
|
|
184
|
+
left: "calc(100% - 4px)",
|
|
185
|
+
right: "-4px",
|
|
186
|
+
top: "calc(100% - 4px)",
|
|
187
|
+
bottom: "-4px"
|
|
188
|
+
};
|
|
189
|
+
const staticAxis = data.placement.split("-")[0];
|
|
190
|
+
Object.assign(this.arrowEl.style, {
|
|
191
|
+
left: arrowX ? `${arrowX}px` : styles[staticAxis],
|
|
192
|
+
top: arrowY ? `${arrowY}px` : styles[staticAxis]
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
get anchorEl() {
|
|
196
|
+
return this.anchor ?? null;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Shows the popup.
|
|
200
|
+
* Unlike toggling the `open` attribute, show() will wait for the popup to become visible and positioned correctly.
|
|
201
|
+
*/
|
|
202
|
+
show() {
|
|
203
|
+
this.open = true;
|
|
204
|
+
return this.#lastPositionUpdate ?? Promise.resolve();
|
|
205
|
+
}
|
|
206
|
+
hide() {
|
|
207
|
+
this.open = false;
|
|
208
|
+
}
|
|
15
209
|
}
|
|
16
210
|
__decorateClass([
|
|
17
|
-
attr
|
|
18
|
-
|
|
211
|
+
attr({
|
|
212
|
+
mode: "boolean"
|
|
213
|
+
})
|
|
214
|
+
], Popup.prototype, "open");
|
|
215
|
+
__decorateClass([
|
|
216
|
+
attr({
|
|
217
|
+
mode: "boolean"
|
|
218
|
+
})
|
|
219
|
+
], Popup.prototype, "dismissible");
|
|
220
|
+
__decorateClass([
|
|
221
|
+
attr({
|
|
222
|
+
mode: "boolean"
|
|
223
|
+
})
|
|
224
|
+
], Popup.prototype, "arrow");
|
|
19
225
|
__decorateClass([
|
|
20
|
-
attr({
|
|
21
|
-
|
|
226
|
+
attr({
|
|
227
|
+
mode: "boolean"
|
|
228
|
+
})
|
|
229
|
+
], Popup.prototype, "alternate");
|
|
22
230
|
__decorateClass([
|
|
23
|
-
attr({
|
|
24
|
-
],
|
|
231
|
+
attr({ mode: "fromView" })
|
|
232
|
+
], Popup.prototype, "placement");
|
|
233
|
+
__decorateClass([
|
|
234
|
+
attr({ mode: "boolean", attribute: "animation-frame" })
|
|
235
|
+
], Popup.prototype, "animationFrame");
|
|
236
|
+
__decorateClass([
|
|
237
|
+
attr({ mode: "fromView" })
|
|
238
|
+
], Popup.prototype, "strategy");
|
|
239
|
+
__decorateClass([
|
|
240
|
+
attr({ attribute: "offset", converter: nullableNumberConverter })
|
|
241
|
+
], Popup.prototype, "offset");
|
|
242
|
+
__decorateClass([
|
|
243
|
+
observable
|
|
244
|
+
], Popup.prototype, "anchor");
|
|
25
245
|
|
|
26
|
-
const styles = ":host{display:
|
|
246
|
+
const styles = ":host{display:var(--_popup-display, inline)}.control{border-radius:inherit;background:var(--vvd-color-surface-4dp);contain:layout}.control:not(.open){display:none}.popup-wrapper{white-space:initial;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.popup-wrapper{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.popup-wrapper ::-webkit-scrollbar{width:4px}.popup-wrapper ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.popup-wrapper ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}.popup-wrapper{z-index:var(--_popup-z-index, 10);overflow:visible;padding:0;border:none;border-radius:8px;margin:0;inline-size:max-content}.popup-wrapper:not(.absolute){position:fixed}.popup-wrapper.absolute{position:absolute;top:0;left:0}.popup-content{display:grid;color:var(--vvd-color-canvas-text)}.dismissible .popup-content{align-content:start;grid-template-columns:1fr auto}.arrow{position:absolute;z-index:-1;width:8px;height:8px;background:var(--vvd-color-surface-4dp);transform:rotate(45deg)}.dismissible-button{align-self:flex-start;margin-block-start:4px;margin-inline-end:4px}";
|
|
27
247
|
|
|
28
|
-
const getClasses = ({
|
|
248
|
+
const getClasses = ({ open, dismissible, alternate }) => classNames(
|
|
29
249
|
"control",
|
|
30
|
-
[
|
|
31
|
-
["
|
|
32
|
-
["
|
|
250
|
+
["open", Boolean(open)],
|
|
251
|
+
["dismissible", Boolean(dismissible)],
|
|
252
|
+
["alternate", Boolean(alternate)]
|
|
33
253
|
);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
254
|
+
function handlePopover(x) {
|
|
255
|
+
return x.strategy && x.strategy === "fixed" ? "manual" : null;
|
|
256
|
+
}
|
|
257
|
+
const popupTemplate = (context) => {
|
|
258
|
+
const elevationTag = context.tagFor(Elevation);
|
|
259
|
+
const buttonTag = context.tagFor(Button);
|
|
260
|
+
return html`
|
|
261
|
+
<${elevationTag}>
|
|
262
|
+
<div popover="${handlePopover}" class="popup-wrapper ${(x) => x.strategy}" ${ref("popupEl")} part="popup-base">
|
|
263
|
+
<div ${ref("controlEl")} class="${getClasses}" aria-hidden="${(x) => x.open ? "false" : "true"}"
|
|
264
|
+
part="${(x) => x.alternate ? "vvd-theme-alternate" : ""}">
|
|
265
|
+
<div class="popup-content">
|
|
266
|
+
<slot></slot>
|
|
267
|
+
${when(
|
|
268
|
+
(x) => x.dismissible,
|
|
269
|
+
html`<${buttonTag} size="condensed" @click="${(x) => x.open = false}"
|
|
270
|
+
class="dismissible-button" icon="close-small-solid" shape="pill"></${buttonTag}>`
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
${when(
|
|
274
|
+
(x) => x.arrow,
|
|
275
|
+
html`<div class="arrow" ${ref("arrowEl")}></div>`
|
|
276
|
+
)}
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
</${elevationTag}>`;
|
|
280
|
+
};
|
|
40
281
|
|
|
41
|
-
const
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[],
|
|
282
|
+
const popupDefinition = defineVividComponent(
|
|
283
|
+
"popup",
|
|
284
|
+
Popup,
|
|
285
|
+
popupTemplate,
|
|
286
|
+
[elevationDefinition, buttonDefinition],
|
|
46
287
|
{
|
|
47
288
|
styles
|
|
48
289
|
}
|
|
49
290
|
);
|
|
50
|
-
const
|
|
291
|
+
const registerPopup = createRegisterFunction(popupDefinition);
|
|
51
292
|
|
|
52
|
-
export {
|
|
293
|
+
export { Popup as P, PlacementStrategy as a, popupDefinition as p, registerPopup as r };
|