@vonage/vivid 3.37.0 → 3.39.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.
Files changed (157) hide show
  1. package/accordion/index.js +2 -2
  2. package/accordion-item/index.js +2 -2
  3. package/alert/index.js +4 -4
  4. package/avatar/index.js +1 -1
  5. package/badge/index.js +1 -1
  6. package/banner/index.js +3 -3
  7. package/breadcrumb-item/index.js +2 -2
  8. package/button/index.js +3 -3
  9. package/card/index.js +2 -2
  10. package/checkbox/index.js +2 -2
  11. package/combobox/index.js +6 -6
  12. package/custom-elements.json +4199 -3875
  13. package/data-grid/index.js +1 -1
  14. package/date-picker/index.js +9 -7
  15. package/date-range-picker/index.js +36 -0
  16. package/dialog/index.js +5 -5
  17. package/divider/index.js +1 -1
  18. package/elevation/index.js +1 -1
  19. package/empty-state/index.js +2 -2
  20. package/fab/index.js +3 -3
  21. package/file-picker/index.js +5 -4
  22. package/focus/index.js +1 -1
  23. package/header/index.js +2 -2
  24. package/icon/index.js +1 -1
  25. package/index.js +43 -40
  26. package/layout/index.js +1 -1
  27. package/lib/components.d.ts +1 -0
  28. package/lib/date-picker/date-picker.d.ts +4 -14
  29. package/lib/date-range-picker/date-range-picker.d.ts +15 -0
  30. package/lib/date-range-picker/definition.d.ts +3 -0
  31. package/lib/file-picker/file-picker.d.ts +8 -5
  32. package/lib/file-picker/file-picker.form-associated.d.ts +10 -0
  33. package/lib/file-picker/locale.d.ts +6 -0
  34. package/lib/menu-item/menu-item.d.ts +6 -0
  35. package/lib/tag-group/tag-group.d.ts +1 -0
  36. package/listbox/index.js +4 -4
  37. package/locales/en-GB.js +27 -3
  38. package/locales/en-US.js +27 -3
  39. package/locales/ja-JP.js +25 -1
  40. package/locales/zh-CN.js +25 -1
  41. package/menu/index.js +7 -7
  42. package/menu-item/index.js +3 -3
  43. package/nav/index.js +1 -1
  44. package/nav-disclosure/index.js +3 -3
  45. package/nav-item/index.js +3 -3
  46. package/note/index.js +2 -2
  47. package/number-field/index.js +5 -5
  48. package/option/index.js +3 -3
  49. package/package.json +1 -1
  50. package/pagination/index.js +4 -4
  51. package/popup/index.js +5 -5
  52. package/progress/index.js +1 -1
  53. package/progress-ring/index.js +1 -1
  54. package/radio/index.js +2 -2
  55. package/radio-group/index.js +1 -1
  56. package/select/index.js +7 -7
  57. package/shared/date-picker/calendar/dateRange.d.ts +5 -0
  58. package/shared/date-picker/calendar/presentationDateRange.d.ts +5 -0
  59. package/shared/date-picker/date-picker-base.d.ts +19 -0
  60. package/shared/date-picker/date-picker-base.form-associated.d.ts +10 -0
  61. package/shared/date-picker/date-picker-base.template.d.ts +4 -0
  62. package/{lib → shared}/date-picker/locale.d.ts +6 -0
  63. package/shared/definition.js +4 -4
  64. package/shared/definition10.js +9 -14
  65. package/shared/definition11.js +1 -1
  66. package/shared/definition12.js +1 -1
  67. package/shared/definition13.js +3 -3
  68. package/shared/definition14.js +3 -3
  69. package/shared/definition15.js +5 -5
  70. package/shared/definition16.js +3 -3
  71. package/shared/definition17.js +44 -6055
  72. package/shared/definition18.js +353 -213
  73. package/shared/definition19.js +251 -67
  74. package/shared/definition2.js +1 -1
  75. package/shared/definition20.js +66 -58
  76. package/shared/definition21.js +43 -84
  77. package/shared/definition22.js +75 -2298
  78. package/shared/definition23.js +2361 -45
  79. package/shared/definition24.js +63 -27
  80. package/shared/definition25.js +24 -51
  81. package/shared/definition26.js +36 -805
  82. package/shared/definition27.js +828 -49
  83. package/shared/definition28.js +52 -89
  84. package/shared/definition29.js +88 -24
  85. package/shared/definition3.js +1 -1
  86. package/shared/definition30.js +25 -12
  87. package/shared/definition31.js +12 -53
  88. package/shared/definition32.js +28 -487
  89. package/shared/definition33.js +427 -197
  90. package/shared/definition34.js +260 -174
  91. package/shared/definition35.js +187 -69
  92. package/shared/definition36.js +68 -55
  93. package/shared/definition37.js +61 -421
  94. package/shared/definition38.js +435 -35
  95. package/shared/definition39.js +30 -679
  96. package/shared/definition4.js +3 -3
  97. package/shared/definition40.js +661 -77
  98. package/shared/definition41.js +77 -557
  99. package/shared/definition42.js +559 -106
  100. package/shared/definition43.js +105 -136
  101. package/shared/definition44.js +153 -17
  102. package/shared/definition45.js +16 -79
  103. package/shared/definition46.js +53 -475
  104. package/shared/definition47.js +506 -20
  105. package/shared/definition48.js +22 -121
  106. package/shared/definition49.js +115 -262
  107. package/shared/definition5.js +2 -2
  108. package/shared/definition50.js +248 -120
  109. package/shared/definition51.js +139 -123
  110. package/shared/definition52.js +84 -74
  111. package/shared/definition53.js +114 -69
  112. package/shared/definition54.js +81 -292
  113. package/shared/definition55.js +302 -13
  114. package/shared/definition56.js +11 -41
  115. package/shared/definition57.js +20 -154
  116. package/shared/definition58.js +181 -0
  117. package/shared/definition6.js +2 -2
  118. package/shared/definition7.js +2 -2
  119. package/shared/definition8.js +3 -3
  120. package/shared/index2.js +1 -1
  121. package/shared/listbox.js +1 -1
  122. package/shared/localization/Locale.d.ts +3 -1
  123. package/shared/localized.js +9 -0
  124. package/shared/presentationDate.js +6133 -0
  125. package/shared/text-anchor.template.js +4 -4
  126. package/shared/text-field.js +1 -1
  127. package/side-drawer/index.js +1 -1
  128. package/slider/index.js +2 -2
  129. package/split-button/index.js +3 -3
  130. package/style.css +246 -183
  131. package/styles/core/all.css +1 -1
  132. package/styles/core/theme.css +1 -1
  133. package/styles/core/typography.css +1 -1
  134. package/styles/tokens/theme-dark.css +4 -4
  135. package/styles/tokens/theme-light.css +4 -4
  136. package/styles/tokens/vivid-2-compat.css +1 -1
  137. package/switch/index.js +3 -3
  138. package/tab/index.js +3 -3
  139. package/tab-panel/index.js +1 -1
  140. package/tabs/index.js +5 -5
  141. package/tag/index.js +3 -3
  142. package/tag-group/index.js +1 -1
  143. package/text-area/index.js +3 -3
  144. package/text-field/index.js +3 -3
  145. package/toggletip/index.js +6 -6
  146. package/tooltip/index.js +6 -6
  147. package/tree-item/index.js +3 -3
  148. package/tree-view/index.js +1 -1
  149. package/vivid.api.json +105 -0
  150. package/lib/date-picker/date-picker.form-associated.d.ts +0 -11
  151. package/lib/date-picker/date-picker.template.d.ts +0 -4
  152. /package/{lib → shared}/date-picker/calendar/calendarGrid.d.ts +0 -0
  153. /package/{lib → shared}/date-picker/calendar/dateStr.d.ts +0 -0
  154. /package/{lib → shared}/date-picker/calendar/month.d.ts +0 -0
  155. /package/{lib → shared}/date-picker/calendar/monthPickerGrid.d.ts +0 -0
  156. /package/{lib → shared}/date-picker/calendar/presentationDate.d.ts +0 -0
  157. /package/{lib → shared}/date-picker/calendar/year.d.ts +0 -0
@@ -1,17 +1,306 @@
1
- import { h as html, r as registerFactory } from './index.js';
2
- import { F as Focus } from './focus.js';
1
+ import { F as FoundationElement, D as DOM, _ as __decorate, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { T as TreeItem$1, i as isTreeItemElement } from './tree-item.js';
3
+ import { i as isHTMLElement, g as getDisplayedNodes } from './dom.js';
4
+ import { k as keyEnter, e as keyArrowUp, d as keyArrowDown, h as keyArrowRight, i as keyArrowLeft, b as keyEnd, c as keyHome } from './key-codes.js';
5
+ import { r as ref } from './ref.js';
6
+ import { s as slotted } from './slotted.js';
7
+ import { c as classNames } from './class-names.js';
3
8
 
4
- const styles = "/**\n * Do not edit directly\n * Generated on Tue, 26 Sep 2023 13:00:58 GMT\n */\n:host {\n display: contents;\n border-radius: inherit;\n}\n\n.control {\n position: absolute;\n z-index: 1;\n box-sizing: border-box;\n border-radius: inherit;\n box-shadow: inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);\n inset: var(--focus-inset, 0);\n outline: 2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));\n outline-offset: -2px;\n}";
9
+ /**
10
+ * A Tree view Custom HTML Element.
11
+ * Implements the {@link https://w3c.github.io/aria-practices/#TreeView | ARIA TreeView }.
12
+ *
13
+ * @slot - The default slot for tree items
14
+ *
15
+ * @public
16
+ */
17
+ let TreeView$1 = class TreeView extends FoundationElement {
18
+ constructor() {
19
+ super(...arguments);
20
+ /**
21
+ * The tree item that is designated to be in the tab queue.
22
+ *
23
+ * @internal
24
+ */
25
+ this.currentFocused = null;
26
+ /**
27
+ * Handle focus events
28
+ *
29
+ * @internal
30
+ */
31
+ this.handleFocus = (e) => {
32
+ if (this.slottedTreeItems.length < 1) {
33
+ // no child items, nothing to do
34
+ return;
35
+ }
36
+ if (e.target === this) {
37
+ if (this.currentFocused === null) {
38
+ this.currentFocused = this.getValidFocusableItem();
39
+ }
40
+ if (this.currentFocused !== null) {
41
+ TreeItem$1.focusItem(this.currentFocused);
42
+ }
43
+ return;
44
+ }
45
+ if (this.contains(e.target)) {
46
+ this.setAttribute("tabindex", "-1");
47
+ this.currentFocused = e.target;
48
+ }
49
+ };
50
+ /**
51
+ * Handle blur events
52
+ *
53
+ * @internal
54
+ */
55
+ this.handleBlur = (e) => {
56
+ if (e.target instanceof HTMLElement &&
57
+ (e.relatedTarget === null || !this.contains(e.relatedTarget))) {
58
+ this.setAttribute("tabindex", "0");
59
+ }
60
+ };
61
+ /**
62
+ * KeyDown handler
63
+ *
64
+ * @internal
65
+ */
66
+ this.handleKeyDown = (e) => {
67
+ if (e.defaultPrevented) {
68
+ return;
69
+ }
70
+ if (this.slottedTreeItems.length < 1) {
71
+ return true;
72
+ }
73
+ const treeItems = this.getVisibleNodes();
74
+ switch (e.key) {
75
+ case keyHome:
76
+ if (treeItems.length) {
77
+ TreeItem$1.focusItem(treeItems[0]);
78
+ }
79
+ return;
80
+ case keyEnd:
81
+ if (treeItems.length) {
82
+ TreeItem$1.focusItem(treeItems[treeItems.length - 1]);
83
+ }
84
+ return;
85
+ case keyArrowLeft:
86
+ if (e.target && this.isFocusableElement(e.target)) {
87
+ const item = e.target;
88
+ if (item instanceof TreeItem$1 &&
89
+ item.childItemLength() > 0 &&
90
+ item.expanded) {
91
+ item.expanded = false;
92
+ }
93
+ else if (item instanceof TreeItem$1 &&
94
+ item.parentElement instanceof TreeItem$1) {
95
+ TreeItem$1.focusItem(item.parentElement);
96
+ }
97
+ }
98
+ return false;
99
+ case keyArrowRight:
100
+ if (e.target && this.isFocusableElement(e.target)) {
101
+ const item = e.target;
102
+ if (item instanceof TreeItem$1 &&
103
+ item.childItemLength() > 0 &&
104
+ !item.expanded) {
105
+ item.expanded = true;
106
+ }
107
+ else if (item instanceof TreeItem$1 && item.childItemLength() > 0) {
108
+ this.focusNextNode(1, e.target);
109
+ }
110
+ }
111
+ return;
112
+ case keyArrowDown:
113
+ if (e.target && this.isFocusableElement(e.target)) {
114
+ this.focusNextNode(1, e.target);
115
+ }
116
+ return;
117
+ case keyArrowUp:
118
+ if (e.target && this.isFocusableElement(e.target)) {
119
+ this.focusNextNode(-1, e.target);
120
+ }
121
+ return;
122
+ case keyEnter:
123
+ // In single-select trees where selection does not follow focus (see note below),
124
+ // the default action is typically to select the focused node.
125
+ this.handleClick(e);
126
+ return;
127
+ }
128
+ // don't prevent default if we took no action
129
+ return true;
130
+ };
131
+ /**
132
+ * Handles the selected-changed events bubbling up
133
+ * from child tree items
134
+ *
135
+ * @internal
136
+ */
137
+ this.handleSelectedChange = (e) => {
138
+ if (e.defaultPrevented) {
139
+ return;
140
+ }
141
+ if (!(e.target instanceof Element) || !isTreeItemElement(e.target)) {
142
+ return true;
143
+ }
144
+ const item = e.target;
145
+ if (item.selected) {
146
+ if (this.currentSelected && this.currentSelected !== item) {
147
+ this.currentSelected.selected = false;
148
+ }
149
+ // new selected item
150
+ this.currentSelected = item;
151
+ }
152
+ else if (!item.selected && this.currentSelected === item) {
153
+ // selected item deselected
154
+ this.currentSelected = null;
155
+ }
156
+ return;
157
+ };
158
+ /**
159
+ * Updates the tree view when slottedTreeItems changes
160
+ */
161
+ this.setItems = () => {
162
+ // force single selection
163
+ // defaults to first one found
164
+ const selectedItem = this.treeView.querySelector("[aria-selected='true']");
165
+ this.currentSelected = selectedItem;
166
+ // invalidate the current focused item if it is no longer valid
167
+ if (this.currentFocused === null || !this.contains(this.currentFocused)) {
168
+ this.currentFocused = this.getValidFocusableItem();
169
+ }
170
+ // toggle properties on child elements
171
+ this.nested = this.checkForNestedItems();
172
+ const treeItems = this.getVisibleNodes();
173
+ treeItems.forEach(node => {
174
+ if (isTreeItemElement(node)) {
175
+ node.nested = this.nested;
176
+ }
177
+ });
178
+ };
179
+ /**
180
+ * check if the item is focusable
181
+ */
182
+ this.isFocusableElement = (el) => {
183
+ return isTreeItemElement(el);
184
+ };
185
+ this.isSelectedElement = (el) => {
186
+ return el.selected;
187
+ };
188
+ }
189
+ slottedTreeItemsChanged() {
190
+ if (this.$fastController.isConnected) {
191
+ // update for slotted children change
192
+ this.setItems();
193
+ }
194
+ }
195
+ connectedCallback() {
196
+ super.connectedCallback();
197
+ this.setAttribute("tabindex", "0");
198
+ DOM.queueUpdate(() => {
199
+ this.setItems();
200
+ });
201
+ }
202
+ /**
203
+ * Handles click events bubbling up
204
+ *
205
+ * @internal
206
+ */
207
+ handleClick(e) {
208
+ if (e.defaultPrevented) {
209
+ // handled, do nothing
210
+ return;
211
+ }
212
+ if (!(e.target instanceof Element) || !isTreeItemElement(e.target)) {
213
+ // not a tree item, ignore
214
+ return true;
215
+ }
216
+ const item = e.target;
217
+ if (!item.disabled) {
218
+ item.selected = !item.selected;
219
+ }
220
+ return;
221
+ }
222
+ /**
223
+ * Move focus to a tree item based on its offset from the provided item
224
+ */
225
+ focusNextNode(delta, item) {
226
+ const visibleNodes = this.getVisibleNodes();
227
+ if (!visibleNodes) {
228
+ return;
229
+ }
230
+ const focusItem = visibleNodes[visibleNodes.indexOf(item) + delta];
231
+ if (isHTMLElement(focusItem)) {
232
+ TreeItem$1.focusItem(focusItem);
233
+ }
234
+ }
235
+ /**
236
+ * checks if there are any nested tree items
237
+ */
238
+ getValidFocusableItem() {
239
+ const treeItems = this.getVisibleNodes();
240
+ // default to selected element if there is one
241
+ let focusIndex = treeItems.findIndex(this.isSelectedElement);
242
+ if (focusIndex === -1) {
243
+ // otherwise first focusable tree item
244
+ focusIndex = treeItems.findIndex(this.isFocusableElement);
245
+ }
246
+ if (focusIndex !== -1) {
247
+ return treeItems[focusIndex];
248
+ }
249
+ return null;
250
+ }
251
+ /**
252
+ * checks if there are any nested tree items
253
+ */
254
+ checkForNestedItems() {
255
+ return this.slottedTreeItems.some((node) => {
256
+ return isTreeItemElement(node) && node.querySelector("[role='treeitem']");
257
+ });
258
+ }
259
+ getVisibleNodes() {
260
+ return getDisplayedNodes(this, "[role='treeitem']") || [];
261
+ }
262
+ };
263
+ __decorate([
264
+ attr({ attribute: "render-collapsed-nodes" })
265
+ ], TreeView$1.prototype, "renderCollapsedNodes", void 0);
266
+ __decorate([
267
+ observable
268
+ ], TreeView$1.prototype, "currentSelected", void 0);
269
+ __decorate([
270
+ observable
271
+ ], TreeView$1.prototype, "slottedTreeItems", void 0);
5
272
 
6
- const focusTemplate = () => html`
7
- <span class="control"></span>`;
273
+ const styles = ".control {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}";
8
274
 
9
- const focusDefinition = Focus.compose({
10
- baseName: "focus",
11
- template: focusTemplate,
12
- styles
13
- });
14
- const focusRegistries = [focusDefinition()];
15
- const registerFocus = registerFactory(focusRegistries);
275
+ class TreeView extends TreeView$1 {
276
+ }
16
277
 
17
- export { focusRegistries as f, registerFocus as r };
278
+ const getClasses = (_) => classNames("control");
279
+ const TreeViewTemplate = () => {
280
+ return html`
281
+ <template
282
+ role="tree"
283
+ ${ref("treeView")}
284
+ @keydown="${(x, c) => x.handleKeyDown(c.event)}"
285
+ @focusin="${(x, c) => x.handleFocus(c.event)}"
286
+ @focusout="${(x, c) => x.handleBlur(c.event)}"
287
+ @click="${(x, c) => x.handleClick(c.event)}"
288
+ @selected-change="${(x, c) => x.handleSelectedChange(c.event)}"
289
+ >
290
+ <div class="${getClasses}">
291
+ <slot ${slotted("slottedTreeItems")}></slot>
292
+ </div>
293
+ </template>`;
294
+ };
295
+
296
+ const treeViewDefinition = TreeView.compose(
297
+ {
298
+ baseName: "tree-view",
299
+ template: TreeViewTemplate,
300
+ styles
301
+ }
302
+ );
303
+ const treeViewRegistries = [treeViewDefinition()];
304
+ const registerTreeView = registerFactory(treeViewRegistries);
305
+
306
+ export { treeViewRegistries as a, registerTreeView as r, treeViewDefinition as t };
@@ -1,47 +1,17 @@
1
- import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
2
- import { c as classNames } from './class-names.js';
1
+ import { h as html, r as registerFactory } from './index.js';
2
+ import { F as Focus } from './focus.js';
3
3
 
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __decorateClass = (decorators, target, key, kind) => {
7
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
8
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
- if (decorator = decorators[i])
10
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
11
- if (kind && result)
12
- __defProp(target, key, result);
13
- return result;
14
- };
15
- class Elevation extends FoundationElement {
16
- }
17
- __decorateClass([
18
- attr
19
- ], Elevation.prototype, "dp", 2);
20
- __decorateClass([
21
- attr({ attribute: "no-shadow", mode: "boolean" })
22
- ], Elevation.prototype, "noShadow", 2);
4
+ const styles = "/**\n * Do not edit directly\n * Generated on Tue, 17 Oct 2023 15:27:52 GMT\n */\n:host {\n display: contents;\n border-radius: inherit;\n}\n\n.control {\n position: absolute;\n z-index: 1;\n box-sizing: border-box;\n border-radius: inherit;\n box-shadow: inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);\n inset: var(--focus-inset, 0);\n outline: 2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));\n outline-offset: -2px;\n}";
23
5
 
24
- const styles = ":host {\n display: contents;\n}\n\n.control {\n display: contents;\n}\n.control.dp-0 {\n --_elevation-fill: var(--vvd-color-surface-0dp);\n --_elevation-shadow: var(--vvd-shadow-surface-0dp);\n}\n.control.dp-4 {\n --_elevation-fill: var(--vvd-color-surface-4dp);\n --_elevation-shadow: var(--vvd-shadow-surface-4dp);\n}\n.control.dp-8 {\n --_elevation-fill: var(--vvd-color-surface-8dp);\n --_elevation-shadow: var(--vvd-shadow-surface-8dp);\n}\n.control.dp-12 {\n --_elevation-fill: var(--vvd-color-surface-12dp);\n --_elevation-shadow: var(--vvd-shadow-surface-12dp);\n}\n.control.dp-16 {\n --_elevation-fill: var(--vvd-color-surface-16dp);\n --_elevation-shadow: var(--vvd-shadow-surface-16dp);\n}\n.control.dp-24 {\n --_elevation-fill: var(--vvd-color-surface-24dp);\n --_elevation-shadow: var(--vvd-shadow-surface-24dp);\n}\n.control:not(.dp-0, .dp-4, .dp-8, .dp-12, .dp-16, .dp-24) {\n --_elevation-fill: var(--vvd-color-surface-2dp);\n --_elevation-shadow: var(--vvd-shadow-surface-2dp);\n}\n.control ::slotted(*) {\n position: relative;\n isolation: isolate;\n}\n.control ::slotted(*)::before {\n position: absolute;\n z-index: -1;\n background: var(--_elevation-fill);\n block-size: 100%;\n border-radius: inherit;\n content: \"\";\n filter: var(--_elevation-shadow);\n inline-size: 100%;\n inset-block-start: 0;\n inset-inline-start: 0;\n transition: background-color 0.15s linear, filter 0.15s linear;\n}\n.control.no-shadow ::slotted(*)::before {\n filter: none;\n}";
6
+ const focusTemplate = () => html`
7
+ <span class="control"></span>`;
25
8
 
26
- const getClasses = ({
27
- dp,
28
- noShadow
29
- }) => classNames(
30
- "control",
31
- [`dp-${dp}`, Boolean(dp)],
32
- ["no-shadow", Boolean(noShadow)]
33
- );
34
- const elevationTemplate = () => html`
35
- <div class="${getClasses}" part="base">
36
- <slot></slot>
37
- </div>`;
38
-
39
- const elevationDefinition = Elevation.compose({
40
- baseName: "elevation",
41
- template: elevationTemplate,
9
+ const focusDefinition = Focus.compose({
10
+ baseName: "focus",
11
+ template: focusTemplate,
42
12
  styles
43
13
  });
44
- const elevationRegistries = [elevationDefinition()];
45
- const registerElevation = registerFactory(elevationRegistries);
14
+ const focusRegistries = [focusDefinition()];
15
+ const registerFocus = registerFactory(focusRegistries);
46
16
 
47
- export { Elevation as E, elevationRegistries as e, registerElevation as r };
17
+ export { focusRegistries as f, registerFocus as r };
@@ -1,14 +1,6 @@
1
1
  import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
2
- import { B as Button, a as buttonRegistries } from './definition10.js';
3
- import { E as Elevation, e as elevationRegistries } from './definition56.js';
4
- import { r as ref } from './ref.js';
5
- import { w as when } from './when.js';
6
2
  import { c as classNames } from './class-names.js';
7
3
 
8
- function t(t){return t.split("-")[1]}function e(t){return "y"===t?"height":"width"}function n$1(t){return t.split("-")[0]}function o$1(t){return ["top","bottom"].includes(n$1(t))?"x":"y"}function i$1(i,r,a){let{reference:l,floating:s}=i;const c=l.x+l.width/2-s.width/2,f=l.y+l.height/2-s.height/2,m=o$1(r),u=e(m),g=l[u]/2-s[u]/2,d="x"===m;let p;switch(n$1(r)){case"top":p={x:c,y:l.y-s.height};break;case"bottom":p={x:c,y:l.y+l.height};break;case"right":p={x:l.x+l.width,y:f};break;case"left":p={x:l.x-s.width,y:f};break;default:p={x:l.x,y:l.y};}switch(t(r)){case"start":p[m]-=g*(a&&d?-1:1);break;case"end":p[m]+=g*(a&&d?-1:1);}return p}const r$1=async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:l}=n,s=a.filter(Boolean),c=await(null==l.isRTL?void 0:l.isRTL(e));let f=await l.getElementRects({reference:t,floating:e,strategy:r}),{x:m,y:u}=i$1(f,o,c),g=o,d={},p=0;for(let n=0;n<s.length;n++){const{name:a,fn:h}=s[n],{x:y,y:x,data:w,reset:v}=await h({x:m,y:u,initialPlacement:o,placement:g,strategy:r,middlewareData:d,rects:f,platform:l,elements:{reference:t,floating:e}});m=null!=y?y:m,u=null!=x?x:u,d={...d,[a]:{...d[a],...w}},v&&p<=50&&(p++,"object"==typeof v&&(v.placement&&(g=v.placement),v.rects&&(f=!0===v.rects?await l.getElementRects({reference:t,floating:e,strategy:r}):v.rects),({x:m,y:u}=i$1(f,g,c))),n=-1);}return {x:m,y:u,placement:g,strategy:r,middlewareData:d}};function a$1(t,e){return "function"==typeof t?t(e):t}function l$1(t){return "number"!=typeof t?function(t){return {top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function s$1(t){return {...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function c$1(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:c,elements:f,strategy:m}=t,{boundary:u="clippingAncestors",rootBoundary:g="viewport",elementContext:d="floating",altBoundary:p=!1,padding:h=0}=a$1(e,t),y=l$1(h),x=f[p?"floating"===d?"reference":"floating":d],w=s$1(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(x)))||n?x:x.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(f.floating)),boundary:u,rootBoundary:g,strategy:m})),v="floating"===d?{...c.floating,x:o,y:i}:c.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(f.floating)),A=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},R=s$1(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:v,offsetParent:b,strategy:m}):v);return {top:(w.top-R.top+y.top)/A.y,bottom:(R.bottom-w.bottom+y.bottom)/A.y,left:(w.left-R.left+y.left)/A.x,right:(R.right-w.right+y.right)/A.x}}const f$1=Math.min,m$1=Math.max;function u$1(t,e,n){return m$1(t,f$1(e,n))}const g$1=n=>({name:"arrow",options:n,async fn(i){const{x:r,y:s,placement:c,rects:m,platform:g,elements:d}=i,{element:p,padding:h=0}=a$1(n,i)||{};if(null==p)return {};const y=l$1(h),x={x:r,y:s},w=o$1(c),v=e(w),b=await g.getDimensions(p),A="y"===w,R=A?"top":"left",P=A?"bottom":"right",E=A?"clientHeight":"clientWidth",T=m.reference[v]+m.reference[w]-x[w]-m.floating[v],D=x[w]-m.reference[w],L=await(null==g.getOffsetParent?void 0:g.getOffsetParent(p));let k=L?L[E]:0;k&&await(null==g.isElement?void 0:g.isElement(L))||(k=d.floating[E]||m.floating[v]);const O=T/2-D/2,B=k/2-b[v]/2-1,C=f$1(y[R],B),H=f$1(y[P],B),S=C,F=k-b[v]-H,M=k/2-b[v]/2+O,V=u$1(S,M,F),W=null!=t(c)&&M!=V&&m.reference[v]/2-(M<S?C:H)-b[v]/2<0?M<S?S-M:F-M:0;return {[w]:x[w]-W,data:{[w]:V,centerOffset:M-V+W}}}}),d$1=["top","right","bottom","left"];d$1.reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);const h$1={left:"right",right:"left",bottom:"top",top:"bottom"};function y$1(t){return t.replace(/left|right|bottom|top/g,(t=>h$1[t]))}function x$1(n,i,r){void 0===r&&(r=!1);const a=t(n),l=o$1(n),s=e(l);let c="x"===l?a===(r?"end":"start")?"right":"left":"start"===a?"bottom":"top";return i.reference[s]>i.floating[s]&&(c=y$1(c)),{main:c,cross:y$1(c)}}const w$1={start:"end",end:"start"};function v$1(t){return t.replace(/start|end/g,(t=>w$1[t]))}const A$1=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(o){var i;const{placement:r,middlewareData:l,rects:s,initialPlacement:f,platform:m,elements:u}=o,{mainAxis:g=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:b=!0,...A}=a$1(e,o),R=n$1(r),P=n$1(f)===f,E=await(null==m.isRTL?void 0:m.isRTL(u.floating)),T=p||(P||!b?[y$1(f)]:function(t){const e=y$1(t);return [v$1(t),e,v$1(e)]}(f));p||"none"===w||T.push(...function(e,o,i,r){const a=t(e);let l=function(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:a;default:return []}}(n$1(e),"start"===i,r);return a&&(l=l.map((t=>t+"-"+a)),o&&(l=l.concat(l.map(v$1)))),l}(f,b,w,E));const D=[f,...T],L=await c$1(o,A),k=[];let O=(null==(i=l.flip)?void 0:i.overflows)||[];if(g&&k.push(L[R]),d){const{main:t,cross:e}=x$1(r,s,E);k.push(L[t],L[e]);}if(O=[...O,{placement:r,overflows:k}],!k.every((t=>t<=0))){var B,C;const t=((null==(B=l.flip)?void 0:B.index)||0)+1,e=D[t];if(e)return {data:{index:t,overflows:O},reset:{placement:e}};let n=null==(C=O.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:C.placement;if(!n)switch(h){case"bestFit":{var H;const t=null==(H=O.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:H[0];t&&(n=t);break}case"initialPlacement":n=f;}if(r!==n)return {reset:{placement:n}}}return {}}}};function R$1(t,e){return {top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function P$1(t){return d$1.some((e=>t[e]>=0))}const E$1=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:o="referenceHidden",...i}=a$1(t,e);switch(o){case"referenceHidden":{const t=R$1(await c$1(e,{...i,elementContext:"reference"}),n.reference);return {data:{referenceHiddenOffsets:t,referenceHidden:P$1(t)}}}case"escaped":{const t=R$1(await c$1(e,{...i,altBoundary:!0}),n.floating);return {data:{escapedOffsets:t,escaped:P$1(t)}}}default:return {}}}}};function T$1(t){const e=f$1(...t.map((t=>t.left))),n=f$1(...t.map((t=>t.top)));return {x:e,y:n,width:m$1(...t.map((t=>t.right)))-e,height:m$1(...t.map((t=>t.bottom)))-n}}const D$1=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:i,elements:r,rects:c,platform:u,strategy:g}=e,{padding:d=2,x:p,y:h}=a$1(t,e),y=Array.from(await(null==u.getClientRects?void 0:u.getClientRects(r.reference))||[]),x=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let o=null;for(let t=0;t<e.length;t++){const i=e[t];!o||i.y-o.y>o.height/2?n.push([i]):n[n.length-1].push(i),o=i;}return n.map((t=>s$1(T$1(t))))}(y),w=s$1(T$1(y)),v=l$1(d);const b=await u.getElementRects({reference:{getBoundingClientRect:function(){if(2===x.length&&x[0].left>x[1].right&&null!=p&&null!=h)return x.find((t=>p>t.left-v.left&&p<t.right+v.right&&h>t.top-v.top&&h<t.bottom+v.bottom))||w;if(x.length>=2){if("x"===o$1(i)){const t=x[0],e=x[x.length-1],o="top"===n$1(i),r=t.top,a=e.bottom,l=o?t.left:e.left,s=o?t.right:e.right;return {top:r,bottom:a,left:l,right:s,width:s-l,height:a-r,x:l,y:r}}const t="left"===n$1(i),e=m$1(...x.map((t=>t.right))),r=f$1(...x.map((t=>t.left))),a=x.filter((n=>t?n.left===r:n.right===e)),l=a[0].top,s=a[a.length-1].bottom;return {top:l,bottom:s,left:r,right:e,width:e-r,height:s-l,x:r,y:l}}return w}},floating:r.floating,strategy:g});return c.reference.x!==b.reference.x||c.reference.y!==b.reference.y||c.reference.width!==b.reference.width||c.reference.height!==b.reference.height?{reset:{rects:b}}:{}}}};const L$1=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(i){const{x:r,y:l}=i,s=await async function(e,i){const{placement:r,platform:l,elements:s}=e,c=await(null==l.isRTL?void 0:l.isRTL(s.floating)),f=n$1(r),m=t(r),u="x"===o$1(r),g=["left","top"].includes(f)?-1:1,d=c&&u?-1:1,p=a$1(i,e);let{mainAxis:h,crossAxis:y,alignmentAxis:x}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return m&&"number"==typeof x&&(y="end"===m?-1*x:x),u?{x:y*d,y:h*g}:{x:h*g,y:y*d}}(i,e);return {x:r+s.x,y:l+s.y,data:s}}}};
9
-
10
- function n(t){var e;return (null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function o(t){return n(t).getComputedStyle(t)}function i(t){return t instanceof n(t).Node}function r(t){return i(t)?(t.nodeName||"").toLowerCase():"#document"}function c(t){return t instanceof HTMLElement||t instanceof n(t).HTMLElement}function l(t){return "undefined"!=typeof ShadowRoot&&(t instanceof n(t).ShadowRoot||t instanceof ShadowRoot)}function s(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=o(t);return /auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!["inline","contents"].includes(r)}function f(t){return ["table","td","th"].includes(r(t))}function u(t){const e=a(),n=o(t);return "none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function a(){return !("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function d(t){return ["html","body","#document"].includes(r(t))}const h=Math.min,p=Math.max,m=Math.round,g=Math.floor,y=t=>({x:t,y:t});function w(t){const e=o(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=c(t),l=r?t.offsetWidth:n,s=r?t.offsetHeight:i,f=m(n)!==l||m(i)!==s;return f&&(n=l,i=s),{width:n,height:i,$:f}}function x(t){return t instanceof Element||t instanceof n(t).Element}function v(t){return x(t)?t:t.contextElement}function b(t){const e=v(t);if(!c(e))return y(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=w(e);let l=(r?m(n.width):n.width)/o,s=(r?m(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),s&&Number.isFinite(s)||(s=1),{x:l,y:s}}const L=y(0);function T(t){const e=n(t);return a()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:L}function R(e,o,i,r){void 0===o&&(o=!1),void 0===i&&(i=!1);const c=e.getBoundingClientRect(),l=v(e);let s=y(1);o&&(r?x(r)&&(s=b(r)):s=b(e));const f=function(t,e,o){return void 0===e&&(e=!1),!(!o||e&&o!==n(t))&&e}(l,i,r)?T(l):y(0);let u=(c.left+f.x)/s.x,a=(c.top+f.y)/s.y,d=c.width/s.x,h=c.height/s.y;if(l){const t=n(l),e=r&&x(r)?n(r):r;let o=t.frameElement;for(;o&&r&&e!==t;){const t=b(o),e=o.getBoundingClientRect(),i=getComputedStyle(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;u*=t.x,a*=t.y,d*=t.x,h*=t.y,u+=r,a+=c,o=n(o).frameElement;}}return s$1({width:d,height:h,x:u,y:a})}function E(t){return x(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function S(t){var e;return null==(e=(i(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function C(t){return R(S(t)).left+E(t).scrollLeft}function F(t){if("html"===r(t))return t;const e=t.assignedSlot||t.parentNode||l(t)&&t.host||S(t);return l(e)?e.host:e}function O(t){const e=F(t);return d(e)?t.ownerDocument?t.ownerDocument.body:t.body:c(e)&&s(e)?e:O(e)}function D(t,e){var o;void 0===e&&(e=[]);const i=O(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=n(i);return r?e.concat(c,c.visualViewport||[],s(i)?i:[]):e.concat(i,D(i))}function H(e,i,r){let l;if("viewport"===i)l=function(t,e){const o=n(t),i=S(t),r=o.visualViewport;let c=i.clientWidth,l=i.clientHeight,s=0,f=0;if(r){c=r.width,l=r.height;const t=a();(!t||t&&"fixed"===e)&&(s=r.offsetLeft,f=r.offsetTop);}return {width:c,height:l,x:s,y:f}}(e,r);else if("document"===i)l=function(t){const e=S(t),n=E(t),i=t.ownerDocument.body,r=p(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=p(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-n.scrollLeft+C(t);const s=-n.scrollTop;return "rtl"===o(i).direction&&(l+=p(e.clientWidth,i.clientWidth)-r),{width:r,height:c,x:l,y:s}}(S(e));else if(x(i))l=function(t,e){const n=R(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=c(t)?b(t):y(1);return {width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(i,r);else {const t=T(e);l={...i,x:i.x-t.x,y:i.y-t.y};}return s$1(l)}function W(t,e){const n=F(t);return !(n===e||!x(n)||d(n))&&("fixed"===o(n).position||W(n,e))}function M(t,e,n){const o=c(e),i=S(e),l="fixed"===n,f=R(t,!0,l,e);let u={scrollLeft:0,scrollTop:0};const a=y(0);if(o||!o&&!l)if(("body"!==r(e)||s(i))&&(u=E(e)),c(e)){const t=R(e,!0,l,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop;}else i&&(a.x=C(i));return {x:f.left+u.scrollLeft-a.x,y:f.top+u.scrollTop-a.y,width:f.width,height:f.height}}function z(t,e){return c(t)&&"fixed"!==o(t).position?e?e(t):t.offsetParent:null}function P(t,e){const i=n(t);if(!c(t))return i;let l=z(t,e);for(;l&&f(l)&&"static"===o(l).position;)l=z(l,e);return l&&("html"===r(l)||"body"===r(l)&&"static"===o(l).position&&!u(l))?i:l||function(t){let e=F(t);for(;c(e)&&!d(e);){if(u(e))return e;e=F(e);}return null}(t)||i}const V={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=c(n),l=S(n);if(n===l)return e;let f={scrollLeft:0,scrollTop:0},u=y(1);const a=y(0);if((i||!i&&"fixed"!==o)&&(("body"!==r(n)||s(l))&&(f=E(n)),c(n))){const t=R(n);u=b(n),a.x=t.x+n.clientLeft,a.y=t.y+n.clientTop;}return {width:e.width*u.x,height:e.height*u.y,x:e.x*u.x-f.scrollLeft*u.x+a.x,y:e.y*u.y-f.scrollTop*u.y+a.y}},getDocumentElement:S,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:i,strategy:c}=t;const l=[..."clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let i=D(t).filter((t=>x(t)&&"body"!==r(t))),c=null;const l="fixed"===o(t).position;let f=l?F(t):t;for(;x(f)&&!d(f);){const e=o(f),n=u(f);n||"fixed"!==e.position||(c=null),(l?!n&&!c:!n&&"static"===e.position&&c&&["absolute","fixed"].includes(c.position)||s(f)&&!n&&W(t,f))?i=i.filter((t=>t!==f)):c=e,f=F(f);}return e.set(t,i),i}(e,this._c):[].concat(n),i],f=l[0],a=l.reduce(((t,n)=>{const o=H(e,n,c);return t.top=p(o.top,t.top),t.right=h(o.right,t.right),t.bottom=h(o.bottom,t.bottom),t.left=p(o.left,t.left),t}),H(e,f,c));return {width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:P,getElementRects:async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||P,r=this.getDimensions;return {reference:M(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return w(t)},getScale:b,isElement:x,isRTL:function(t){return "rtl"===getComputedStyle(t).direction}};function A(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:c="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:s=!1}=o,f=v(t),u=i||r?[...f?D(f):[],...D(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n);}));const a=f&&l?function(t,e){let n,o=null;const i=S(t);function r(){clearTimeout(n),o&&o.disconnect(),o=null;}return function c(l,s){void 0===l&&(l=!1),void 0===s&&(s=1),r();const{left:f,top:u,width:a,height:d}=t.getBoundingClientRect();if(l||e(),!a||!d)return;const m={rootMargin:-g(u)+"px "+-g(i.clientWidth-(f+a))+"px "+-g(i.clientHeight-(u+d))+"px "+-g(f)+"px",threshold:p(0,h(1,s))||1};let y=!0;function w(t){const e=t[0].intersectionRatio;if(e!==s){if(!y)return c();e?c(!1,e):n=setTimeout((()=>{c(!1,1e-7);}),100);}y=!1;}try{o=new IntersectionObserver(w,{...m,root:i.ownerDocument});}catch(t){o=new IntersectionObserver(w,m);}o.observe(t);}(!0),r}(f,n):null;let d,m=-1,y=null;c&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===f&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{y&&y.observe(e);}))),n();})),f&&!s&&y.observe(f),y.observe(e));let w=s?R(t):null;return s&&function e(){const o=R(t);!w||o.x===w.x&&o.y===w.y&&o.width===w.width&&o.height===w.height||n();w=o,d=requestAnimationFrame(e);}(),n(),()=>{u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n);})),a&&a(),y&&y.disconnect(),y=null,s&&cancelAnimationFrame(d);}}const B=(t,n,o)=>{const i=new Map,r={platform:V,...o},c={...r.platform,_c:i};return r$1(t,n,{...r,platform:c})};
11
-
12
4
  var __defProp = Object.defineProperty;
13
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
6
  var __decorateClass = (decorators, target, key, kind) => {
@@ -20,162 +12,36 @@ var __decorateClass = (decorators, target, key, kind) => {
20
12
  __defProp(target, key, result);
21
13
  return result;
22
14
  };
23
- class Popup extends FoundationElement {
24
- constructor() {
25
- super(...arguments);
26
- this.open = false;
27
- this.dismissible = false;
28
- this.arrow = false;
29
- this.alternate = false;
30
- this.strategy = "fixed";
31
- }
32
- get #middleware() {
33
- let middleware = [D$1(), A$1(), E$1()];
34
- if (this.arrow) {
35
- middleware = [L$1(12), ...middleware, g$1({ element: this.arrowEl, padding: 10 })];
36
- }
37
- return middleware;
38
- }
39
- #cleanup;
40
- openChanged(_, newValue) {
41
- newValue ? this.$emit("vwc-popup:open") : this.$emit("vwc-popup:close");
42
- }
43
- disconnectedCallback() {
44
- super.disconnectedCallback();
45
- this.#cleanup?.();
46
- }
47
- attributeChangedCallback(name, oldValue, newValue) {
48
- super.attributeChangedCallback(name, oldValue, newValue);
49
- this.#cleanup?.();
50
- if (this.anchorEl && this.popupEl) {
51
- this.#cleanup = A(this.anchorEl, this.popupEl, () => this.updatePosition());
52
- }
53
- }
54
- /**
55
- * Updates popup's position
56
- *
57
- * @public
58
- */
59
- async updatePosition() {
60
- if (!this.open || !this.anchorEl) {
61
- return;
62
- }
63
- const positionData = await B(this.anchorEl, this.popupEl, {
64
- placement: this.placement,
65
- strategy: this.strategy,
66
- middleware: this.#middleware
67
- });
68
- this.#assignPopupPosition(positionData);
69
- if (this.arrow) {
70
- this.#assignArrowPosition(positionData);
71
- }
72
- }
73
- #assignPopupPosition(data) {
74
- const { x: popupX, y: popupY } = data;
75
- const { referenceHidden } = data.middlewareData.hide;
76
- Object.assign(this.popupEl.style, {
77
- left: `${popupX}px`,
78
- top: `${popupY}px`,
79
- visibility: referenceHidden ? "hidden" : "visible"
80
- });
81
- }
82
- #assignArrowPosition(data) {
83
- const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
84
- const styles = {
85
- "left": "calc(100% - 4px)",
86
- "right": "-4px",
87
- "top": "calc(100% - 4px)",
88
- "bottom": "-4px"
89
- };
90
- const staticAxis = data.placement.split("-")[0];
91
- Object.assign(this.arrowEl.style, {
92
- left: arrowX ? `${arrowX}px` : styles[staticAxis],
93
- top: arrowY ? `${arrowY}px` : styles[staticAxis]
94
- });
95
- }
96
- /**
97
- * Gets the anchor element by id
98
- */
99
- get anchorEl() {
100
- return this.anchor instanceof HTMLElement ? this.anchor : document.getElementById(this.anchor ? this.anchor : "");
101
- }
102
- show() {
103
- this.open = true;
104
- }
105
- hide() {
106
- this.open = false;
107
- }
15
+ class Elevation extends FoundationElement {
108
16
  }
109
- __decorateClass([
110
- attr({
111
- mode: "boolean"
112
- })
113
- ], Popup.prototype, "open", 2);
114
- __decorateClass([
115
- attr({
116
- mode: "boolean"
117
- })
118
- ], Popup.prototype, "dismissible", 2);
119
- __decorateClass([
120
- attr({
121
- mode: "boolean"
122
- })
123
- ], Popup.prototype, "arrow", 2);
124
- __decorateClass([
125
- attr({
126
- mode: "boolean"
127
- })
128
- ], Popup.prototype, "alternate", 2);
129
- __decorateClass([
130
- attr({ mode: "fromView" })
131
- ], Popup.prototype, "placement", 2);
132
- __decorateClass([
133
- attr({ mode: "fromView" })
134
- ], Popup.prototype, "strategy", 2);
135
17
  __decorateClass([
136
18
  attr
137
- ], Popup.prototype, "anchor", 2);
19
+ ], Elevation.prototype, "dp", 2);
20
+ __decorateClass([
21
+ attr({ attribute: "no-shadow", mode: "boolean" })
22
+ ], Elevation.prototype, "noShadow", 2);
138
23
 
139
- const styles = ".control {\n background: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n z-index: 10;\n border-radius: 6px;\n inline-size: fit-content;\n}\n.popup-wrapper:not(.absolute) {\n position: fixed;\n}\n.popup-wrapper.absolute {\n position: absolute;\n}\n\n.popup-content {\n display: grid;\n color: var(--vvd-color-canvas-text); /* neutral-100 */\n}\n.dismissible .popup-content {\n align-content: start;\n grid-template-columns: 1fr auto;\n}\n\n.arrow {\n position: absolute;\n z-index: -1;\n width: 8px;\n height: 8px;\n background: var(--vvd-color-surface-4dp);\n transform: rotate(45deg);\n}\n\n.dismissible-button {\n align-self: flex-start;\n margin-block-start: 4px;\n margin-inline-end: 4px;\n}";
24
+ const styles = ":host {\n display: contents;\n}\n\n.control {\n display: contents;\n}\n.control.dp-0 {\n --_elevation-fill: var(--vvd-color-surface-0dp);\n --_elevation-shadow: var(--vvd-shadow-surface-0dp);\n}\n.control.dp-4 {\n --_elevation-fill: var(--vvd-color-surface-4dp);\n --_elevation-shadow: var(--vvd-shadow-surface-4dp);\n}\n.control.dp-8 {\n --_elevation-fill: var(--vvd-color-surface-8dp);\n --_elevation-shadow: var(--vvd-shadow-surface-8dp);\n}\n.control.dp-12 {\n --_elevation-fill: var(--vvd-color-surface-12dp);\n --_elevation-shadow: var(--vvd-shadow-surface-12dp);\n}\n.control.dp-16 {\n --_elevation-fill: var(--vvd-color-surface-16dp);\n --_elevation-shadow: var(--vvd-shadow-surface-16dp);\n}\n.control.dp-24 {\n --_elevation-fill: var(--vvd-color-surface-24dp);\n --_elevation-shadow: var(--vvd-shadow-surface-24dp);\n}\n.control:not(.dp-0, .dp-4, .dp-8, .dp-12, .dp-16, .dp-24) {\n --_elevation-fill: var(--vvd-color-surface-2dp);\n --_elevation-shadow: var(--vvd-shadow-surface-2dp);\n}\n.control ::slotted(*) {\n position: relative;\n isolation: isolate;\n}\n.control ::slotted(*)::before {\n position: absolute;\n z-index: -1;\n background: var(--_elevation-fill);\n block-size: 100%;\n border-radius: inherit;\n content: \"\";\n filter: var(--_elevation-shadow);\n inline-size: 100%;\n inset-block-start: 0;\n inset-inline-start: 0;\n transition: background-color 0.15s linear, filter 0.15s linear;\n}\n.control.no-shadow ::slotted(*)::before {\n filter: none;\n}";
140
25
 
141
26
  const getClasses = ({
142
- open,
143
- dismissible,
144
- alternate
27
+ dp,
28
+ noShadow
145
29
  }) => classNames(
146
30
  "control",
147
- ["open", Boolean(open)],
148
- ["dismissible", Boolean(dismissible)],
149
- ["alternate", Boolean(alternate)]
31
+ [`dp-${dp}`, Boolean(dp)],
32
+ ["no-shadow", Boolean(noShadow)]
150
33
  );
151
- const popupTemplate = (context) => {
152
- const elevationTag = context.tagFor(Elevation);
153
- const buttonTag = context.tagFor(Button);
154
- return html`
155
- <${elevationTag}>
156
- <div class="popup-wrapper ${(x) => x.strategy}" ${ref("popupEl")} part="popup-base">
157
- <div class="${getClasses}" aria-hidden="${(x) => x.open ? "false" : "true"}"
158
- part="${(x) => x.alternate ? "vvd-theme-alternate" : ""}">
159
- <div class="popup-content">
160
- <slot></slot>
161
- ${when(
162
- (x) => x.dismissible,
163
- html`<${buttonTag} size="condensed" @click="${(x) => x.open = false}"
164
- class="dismissible-button" icon="close-small-solid" shape="pill"></${buttonTag}>`
165
- )}
166
- </div>
167
- ${when((x) => x.arrow, html`<div class="arrow" ${ref("arrowEl")}></div>`)}
168
- </div>
169
- </div>
170
- </${elevationTag}>`;
171
- };
34
+ const elevationTemplate = () => html`
35
+ <div class="${getClasses}" part="base">
36
+ <slot></slot>
37
+ </div>`;
172
38
 
173
- const popupDefinition = Popup.compose({
174
- baseName: "popup",
175
- template: popupTemplate,
39
+ const elevationDefinition = Elevation.compose({
40
+ baseName: "elevation",
41
+ template: elevationTemplate,
176
42
  styles
177
43
  });
178
- const popupRegistries = [popupDefinition(), ...elevationRegistries, ...buttonRegistries];
179
- const registerPopup = registerFactory(popupRegistries);
44
+ const elevationRegistries = [elevationDefinition()];
45
+ const registerElevation = registerFactory(elevationRegistries);
180
46
 
181
- export { Popup as P, popupRegistries as p, registerPopup as r };
47
+ export { Elevation as E, elevationRegistries as e, registerElevation as r };