@vonage/vivid 3.32.0 → 3.35.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 (221) hide show
  1. package/accordion/index.js +5 -5
  2. package/accordion-item/index.js +4 -4
  3. package/action-group/index.js +1 -1
  4. package/alert/index.js +6 -6
  5. package/avatar/index.js +2 -2
  6. package/badge/index.js +2 -2
  7. package/banner/index.js +5 -5
  8. package/breadcrumb/index.js +1 -1
  9. package/breadcrumb-item/index.js +3 -3
  10. package/button/index.js +4 -4
  11. package/calendar/index.js +1 -1
  12. package/calendar-event/index.js +1 -1
  13. package/card/index.js +3 -3
  14. package/checkbox/index.js +5 -3
  15. package/combobox/index.js +8 -8
  16. package/custom-elements.json +256 -18
  17. package/data-grid/index.js +2 -2
  18. package/date-picker/index.js +9 -9
  19. package/dialog/index.js +6 -6
  20. package/divider/index.js +1 -1
  21. package/elevation/index.js +1 -1
  22. package/empty-state/index.js +2 -2
  23. package/fab/index.js +4 -4
  24. package/file-picker/index.js +5 -5
  25. package/focus/index.js +1 -1
  26. package/header/index.js +2 -2
  27. package/icon/index.js +1 -1
  28. package/index.js +59 -59
  29. package/layout/index.js +1 -1
  30. package/lib/avatar/avatar.d.ts +1 -1
  31. package/lib/calendar/calendar.d.ts +1 -1
  32. package/lib/date-picker/calendar/dateStr.d.ts +1 -0
  33. package/lib/date-picker/calendar/month.d.ts +1 -0
  34. package/lib/date-picker/calendar/year.d.ts +2 -0
  35. package/lib/date-picker/date-picker.d.ts +2 -0
  36. package/lib/icon/icon.d.ts +0 -1
  37. package/lib/listbox/listbox.d.ts +9 -1
  38. package/lib/progress-ring/progress-ring.d.ts +1 -1
  39. package/lib/text-field/text-field.d.ts +1 -0
  40. package/listbox/index.js +20 -16
  41. package/locales/en-GB.js +48 -14
  42. package/locales/en-US.js +48 -14
  43. package/locales/ja-JP.js +48 -14
  44. package/locales/zh-CN.js +48 -14
  45. package/menu/index.js +8 -8
  46. package/menu-item/index.js +4 -4
  47. package/nav/index.js +1 -1
  48. package/nav-disclosure/index.js +3 -3
  49. package/nav-item/index.js +3 -3
  50. package/note/index.js +2 -3
  51. package/number-field/index.js +6 -6
  52. package/option/index.js +3 -3
  53. package/package.json +2 -16
  54. package/pagination/index.js +5 -5
  55. package/popup/index.js +6 -6
  56. package/progress/index.js +1 -1
  57. package/progress-ring/index.js +1 -1
  58. package/radio/index.js +2 -2
  59. package/radio-group/index.js +1 -1
  60. package/select/index.js +8 -8
  61. package/shared/affix.js +25 -9
  62. package/shared/apply-mixins.js +1 -1
  63. package/shared/breadcrumb-item.js +5 -5
  64. package/shared/button.js +13 -13
  65. package/shared/calendar-event.js +36 -16
  66. package/shared/definition.js +133 -194
  67. package/shared/definition10.js +225 -40
  68. package/shared/definition11.js +36 -32
  69. package/shared/definition12.js +763 -98
  70. package/shared/definition13.js +125 -89
  71. package/shared/definition14.js +207 -27
  72. package/shared/definition15.js +710 -731
  73. package/shared/definition16.js +1289 -47
  74. package/shared/definition17.js +6113 -93
  75. package/shared/definition18.js +242 -164
  76. package/shared/definition19.js +47 -692
  77. package/shared/definition2.js +199 -117
  78. package/shared/definition20.js +59 -1671
  79. package/shared/definition21.js +95 -255
  80. package/shared/definition22.js +2218 -1167
  81. package/shared/definition23.js +61 -5784
  82. package/shared/definition24.js +28 -117
  83. package/shared/definition25.js +52 -66
  84. package/shared/definition26.js +391 -214
  85. package/shared/definition27.js +441 -34
  86. package/shared/definition28.js +85 -73
  87. package/shared/definition29.js +21 -2283
  88. package/shared/definition3.js +61 -24
  89. package/shared/definition30.js +13 -49
  90. package/shared/definition31.js +54 -39
  91. package/shared/definition32.js +413 -375
  92. package/shared/definition33.js +223 -304
  93. package/shared/definition34.js +197 -13
  94. package/shared/definition35.js +88 -73
  95. package/shared/definition36.js +75 -25
  96. package/shared/definition37.js +434 -34
  97. package/shared/definition38.js +32 -432
  98. package/shared/definition39.js +677 -187
  99. package/shared/definition4.js +157 -12
  100. package/shared/definition40.js +95 -48
  101. package/shared/definition41.js +577 -31
  102. package/shared/definition42.js +126 -424
  103. package/shared/definition43.js +114 -618
  104. package/shared/definition44.js +24 -80
  105. package/shared/definition45.js +71 -543
  106. package/shared/definition46.js +499 -92
  107. package/shared/definition47.js +19 -133
  108. package/shared/definition48.js +129 -52
  109. package/shared/definition49.js +281 -17
  110. package/shared/definition5.js +71 -36
  111. package/shared/definition50.js +153 -484
  112. package/shared/definition51.js +131 -98
  113. package/shared/definition52.js +131 -16
  114. package/shared/definition53.js +80 -264
  115. package/shared/definition54.js +293 -118
  116. package/shared/definition55.js +12 -117
  117. package/shared/definition56.js +39 -68
  118. package/shared/definition57.js +166 -288
  119. package/shared/definition6.js +56 -111
  120. package/shared/definition7.js +120 -195
  121. package/shared/definition8.js +58 -23
  122. package/shared/definition9.js +92 -66
  123. package/shared/focus.js +2 -1
  124. package/shared/focus2.js +1 -1
  125. package/shared/form-associated.js +2 -2
  126. package/shared/icon.js +48 -27
  127. package/shared/index.js +7 -27
  128. package/shared/index2.js +108 -80
  129. package/shared/key-codes.js +1 -1
  130. package/shared/listbox.js +88 -11
  131. package/shared/patterns/form-elements/form-elements.d.ts +4 -4
  132. package/shared/radio.js +23 -7
  133. package/shared/repeat.js +1 -1
  134. package/shared/text-anchor.js +21 -4
  135. package/shared/text-anchor.template.js +37 -40
  136. package/shared/text-field.js +2 -2
  137. package/shared/text-field2.js +15 -15
  138. package/shared/tree-item.js +12 -12
  139. package/side-drawer/index.js +1 -1
  140. package/slider/index.js +2 -2
  141. package/split-button/index.js +3 -3
  142. package/style.css +6106 -0
  143. package/styles/core/all.css +1 -1
  144. package/styles/core/theme.css +1 -1
  145. package/styles/core/typography.css +1 -1
  146. package/styles/tokens/theme-dark.css +4 -4
  147. package/styles/tokens/theme-light.css +4 -4
  148. package/styles/tokens/vivid-2-compat.css +1 -1
  149. package/switch/index.js +3 -3
  150. package/tab/index.js +3 -3
  151. package/tab-panel/index.js +1 -1
  152. package/tabs/index.js +5 -5
  153. package/tag/index.js +3 -3
  154. package/tag-group/index.js +1 -1
  155. package/text-anchor/index.js +1 -1
  156. package/text-area/index.js +3 -3
  157. package/text-field/index.js +3 -3
  158. package/toggletip/index.js +7 -7
  159. package/tooltip/index.js +7 -7
  160. package/tree-item/index.js +3 -3
  161. package/tree-view/index.js +1 -1
  162. package/vivid.api.json +10 -1
  163. package/lib/accordion/index.d.ts +0 -1
  164. package/lib/accordion-item/index.d.ts +0 -1
  165. package/lib/action-group/index.d.ts +0 -1
  166. package/lib/alert/index.d.ts +0 -1
  167. package/lib/avatar/index.d.ts +0 -1
  168. package/lib/badge/index.d.ts +0 -1
  169. package/lib/banner/index.d.ts +0 -1
  170. package/lib/breadcrumb/index.d.ts +0 -1
  171. package/lib/breadcrumb-item/index.d.ts +0 -1
  172. package/lib/button/index.d.ts +0 -1
  173. package/lib/calendar/index.d.ts +0 -1
  174. package/lib/calendar-event/index.d.ts +0 -1
  175. package/lib/card/index.d.ts +0 -1
  176. package/lib/checkbox/index.d.ts +0 -1
  177. package/lib/combobox/index.d.ts +0 -1
  178. package/lib/data-grid/index.d.ts +0 -1
  179. package/lib/date-picker/index.d.ts +0 -1
  180. package/lib/dialog/index.d.ts +0 -1
  181. package/lib/divider/index.d.ts +0 -1
  182. package/lib/elevation/index.d.ts +0 -1
  183. package/lib/empty-state/index.d.ts +0 -1
  184. package/lib/fab/index.d.ts +0 -1
  185. package/lib/file-picker/index.d.ts +0 -1
  186. package/lib/focus/index.d.ts +0 -1
  187. package/lib/header/index.d.ts +0 -1
  188. package/lib/icon/index.d.ts +0 -1
  189. package/lib/layout/index.d.ts +0 -1
  190. package/lib/listbox/index.d.ts +0 -1
  191. package/lib/menu/index.d.ts +0 -1
  192. package/lib/menu-item/index.d.ts +0 -1
  193. package/lib/nav/index.d.ts +0 -1
  194. package/lib/nav-disclosure/index.d.ts +0 -1
  195. package/lib/nav-item/index.d.ts +0 -1
  196. package/lib/note/index.d.ts +0 -1
  197. package/lib/number-field/index.d.ts +0 -1
  198. package/lib/option/index.d.ts +0 -1
  199. package/lib/pagination/index.d.ts +0 -1
  200. package/lib/popup/index.d.ts +0 -1
  201. package/lib/progress/index.d.ts +0 -1
  202. package/lib/progress-ring/index.d.ts +0 -1
  203. package/lib/radio/index.d.ts +0 -1
  204. package/lib/radio-group/index.d.ts +0 -1
  205. package/lib/select/index.d.ts +0 -1
  206. package/lib/side-drawer/index.d.ts +0 -1
  207. package/lib/slider/index.d.ts +0 -1
  208. package/lib/split-button/index.d.ts +0 -1
  209. package/lib/switch/index.d.ts +0 -1
  210. package/lib/tab/index.d.ts +0 -1
  211. package/lib/tab-panel/index.d.ts +0 -1
  212. package/lib/tabs/index.d.ts +0 -1
  213. package/lib/tag/index.d.ts +0 -1
  214. package/lib/tag-group/index.d.ts +0 -1
  215. package/lib/text-anchor/index.d.ts +0 -1
  216. package/lib/text-area/index.d.ts +0 -1
  217. package/lib/text-field/index.d.ts +0 -1
  218. package/lib/toggletip/index.d.ts +0 -1
  219. package/lib/tooltip/index.d.ts +0 -1
  220. package/lib/tree-item/index.d.ts +0 -1
  221. package/lib/tree-view/index.d.ts +0 -1
@@ -1,76 +1,47 @@
1
- import { _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactory } from './index.js';
2
- import { i as iconRegistries } from './definition3.js';
3
- import { f as focusRegistries } from './definition4.js';
4
- import { b as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
5
- import { T as TreeItem$1 } from './tree-item.js';
6
- import { a as applyMixins } from './apply-mixins.js';
7
- import { I as Icon } from './icon.js';
8
- import { f as focusTemplateFactory } from './focus2.js';
9
- import { e as elements } from './node-observation.js';
10
- import { c as children } from './children.js';
11
- import { w as when } from './when.js';
12
- import { s as slotted } from './slotted.js';
1
+ import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
13
2
  import { c as classNames } from './class-names.js';
14
- import { r as ref } from './ref.js';
15
3
 
16
- var css_248z = "/**\n * Do not edit directly\n * Generated on Tue, 22 Aug 2023 13:37:39 GMT\n */\n@supports selector(:focus-visible) {\n :host(:focus-visible) {\n outline: none;\n }\n}\n.control {\n position: relative;\n display: inline-flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n border-radius: 6px;\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n color: var(--_appearance-color-text);\n font: var(--vvd-typography-base);\n gap: 12px;\n hyphens: auto;\n inline-size: 100%;\n min-block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n padding-inline: 16px;\n text-decoration: none;\n vertical-align: middle;\n word-break: break-word;\n}\n.control {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.control:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.control:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: transparent;\n}\n.control:where(:active, .active):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: transparent;\n}\n.control:where(.selected, [aria-current]):where(:not(:disabled, .disabled, :hover, .hover)) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: transparent;\n}\n.control:where(.selected, [aria-current]):where(:hover, .hover) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary-increment);\n --_appearance-color-outline: transparent;\n}\n.control {\n /* @cssprop [--vvd-tree-item-accent-primary=var(--vvd-color-canvas-text)] */\n --_connotation-color-primary: var(--vvd-tree-item-accent-primary, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-tree-item-accent-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-tree-item-accent-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-tree-item-accent-primary-increment=var(--vvd-color-neutral-800)] */\n --_connotation-color-primary-increment: var(--vvd-tree-item-accent-primary-increment, var(--vvd-color-neutral-800));\n /* @cssprop [--vvd-tree-item-accent-faint=var(--vvd-color-neutral-50)] */\n --_connotation-color-faint: var(--vvd-tree-item-accent-faint, var(--vvd-color-neutral-50));\n /* @cssprop [--vvd-tree-item-accent-soft=var(--vvd-color-neutral-100)] */\n --_connotation-color-soft: var(--vvd-tree-item-accent-soft, var(--vvd-color-neutral-100));\n}\n@supports selector(:focus-visible) {\n .control:focus-visible {\n outline: none;\n }\n}\n@supports (user-select: none) {\n .control {\n user-select: none;\n }\n}\n.control:not(.disabled) {\n cursor: pointer;\n}\n.control.disabled {\n cursor: not-allowed;\n pointer-events: none;\n}\n.control .text {\n font: var(--vvd-typography-base);\n}\n\n.expandCollapseButton {\n display: flex;\n align-items: center;\n border-radius: 6px;\n font-size: 20px;\n}\n.expandCollapseButton .expandCollapseIcon {\n margin: 4px;\n}\n.expandCollapseButton:hover {\n background-color: var(--vvd-color-neutral-100);\n}\n\n.items {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin-block: 4px;\n padding-inline-start: 48px;\n}\n\n:host(:not(:focus-visible)) .focus-indicator {\n display: none;\n}\n\n.icon {\n font-size: 20px;\n line-height: 1;\n}\n.control:not(.disabled, .selected) .icon {\n color: var(--vvd-color-neutral-600);\n}";
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);
17
23
 
18
- class TreeItem extends TreeItem$1 {}
19
- __decorate([attr, __metadata("design:type", String)], TreeItem.prototype, "text", void 0);
20
- applyMixins(TreeItem, AffixIcon);
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}";
21
25
 
22
26
  const getClasses = ({
23
- disabled,
24
- selected
25
- }) => classNames('control', ['disabled', disabled], ['selected', Boolean(selected)]);
26
- const expandCollapseButton = context => {
27
- const iconTag = context.tagFor(Icon);
28
- return html`
29
- <div aria-hidden="true"
30
- class="expandCollapseButton"
31
- @click="${(x, c) => x.handleExpandCollapseButtonClick(c.event)}"
32
- ${ref('expandCollapseButton')}
33
- >
34
- <${iconTag} class="expandCollapseIcon" name="${x => x.expanded ? 'chevron-down-line' : 'chevron-right-line'}"></${iconTag}>
35
- </div>`;
36
- };
37
- const TreeItemTemplate = context => {
38
- const affixIconTemplate = affixIconTemplateFactory(context);
39
- const focusTemplate = focusTemplateFactory(context);
40
- return html`
41
- <template
42
- role="treeitem"
43
- slot="${x => x.isNestedItem() ? 'item' : void 0}"
44
- tabindex="-1"
45
- aria-expanded="${x => x.childItems && x.childItems.length > 0 ? x.expanded : void 0}"
46
- aria-selected="${x => x.selected}"
47
- aria-disabled="${x => x.disabled}"
48
- @focusin="${(x, c) => x.handleFocus(c.event)}"
49
- @focusout="${(x, c) => x.handleBlur(c.event)}"
50
- ${children({
51
- property: 'childItems',
52
- filter: elements()
53
- })}
54
- >
55
- <div class="${getClasses}">
56
- ${() => focusTemplate}
57
- ${when(x => x.childItems && x.childItems.length > 0, expandCollapseButton(context))}
58
- ${x => affixIconTemplate(x.icon)}
59
- ${x => x.text}
60
- </div>
61
- ${when(x => x.childItems && x.childItems.length > 0 && x.expanded, html`
62
- <div role="group" class="items">
63
- <slot name="item" ${slotted('items')}></slot>
64
- </div>`)}
65
- </template>`;
66
- };
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>`;
67
38
 
68
- const treeItemDefinition = TreeItem.compose({
69
- baseName: 'tree-item',
70
- template: TreeItemTemplate,
71
- styles: css_248z
39
+ const elevationDefinition = Elevation.compose({
40
+ baseName: "elevation",
41
+ template: elevationTemplate,
42
+ styles
72
43
  });
73
- const treeItemRegistries = [treeItemDefinition(), ...iconRegistries, ...focusRegistries];
74
- const registerTreeItem = registerFactory(treeItemRegistries);
44
+ const elevationRegistries = [elevationDefinition()];
45
+ const registerElevation = registerFactory(elevationRegistries);
75
46
 
76
- export { treeItemRegistries as a, registerTreeItem as r, treeItemDefinition as t };
47
+ export { Elevation as E, elevationRegistries as e, registerElevation as r };
@@ -1,303 +1,181 @@
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, i as isTreeItemElement } from './tree-item.js';
3
- import { i as isHTMLElement, g as getDisplayedNodes } from './dom.js';
4
- import { d as keyEnter, c as keyArrowUp, b as keyArrowDown, h as keyArrowRight, i as keyArrowLeft, k as keyEnd, a as keyHome } from './key-codes.js';
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';
5
4
  import { r as ref } from './ref.js';
6
- import { s as slotted } from './slotted.js';
5
+ import { w as when } from './when.js';
7
6
  import { c as classNames } from './class-names.js';
8
7
 
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
- class TreeView$1 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.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.focusItem(treeItems[0]);
78
- }
79
- return;
80
- case keyEnd:
81
- if (treeItems.length) {
82
- TreeItem.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 &&
89
- item.childItemLength() > 0 &&
90
- item.expanded) {
91
- item.expanded = false;
92
- }
93
- else if (item instanceof TreeItem &&
94
- item.parentElement instanceof TreeItem) {
95
- TreeItem.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 &&
103
- item.childItemLength() > 0 &&
104
- !item.expanded) {
105
- item.expanded = true;
106
- }
107
- else if (item instanceof TreeItem && 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.focusItem(focusItem);
233
- }
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
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __decorateClass = (decorators, target, key, kind) => {
15
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
16
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
17
+ if (decorator = decorators[i])
18
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
19
+ if (kind && result)
20
+ __defProp(target, key, result);
21
+ return result;
22
+ };
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 })];
234
36
  }
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;
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());
250
52
  }
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
- });
53
+ }
54
+ /**
55
+ * Updates popup's position
56
+ *
57
+ * @public
58
+ */
59
+ async updatePosition() {
60
+ if (!this.open || !this.anchorEl) {
61
+ return;
258
62
  }
259
- getVisibleNodes() {
260
- return getDisplayedNodes(this, "[role='treeitem']") || [];
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);
261
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
+ }
262
108
  }
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);
272
-
273
- var css_248z = ".control {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}";
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
+ __decorateClass([
136
+ attr
137
+ ], Popup.prototype, "anchor", 2);
274
138
 
275
- class TreeView extends TreeView$1 {}
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}";
276
140
 
277
- const getClasses = _ => classNames('control');
278
- const TreeViewTemplate = () => {
141
+ const getClasses = ({
142
+ open,
143
+ dismissible,
144
+ alternate
145
+ }) => classNames(
146
+ "control",
147
+ ["open", Boolean(open)],
148
+ ["dismissible", Boolean(dismissible)],
149
+ ["alternate", Boolean(alternate)]
150
+ );
151
+ const popupTemplate = (context) => {
152
+ const elevationTag = context.tagFor(Elevation);
153
+ const buttonTag = context.tagFor(Button);
279
154
  return html`
280
- <template
281
- role="tree"
282
- ${ref('treeView')}
283
- @keydown="${(x, c) => x.handleKeyDown(c.event)}"
284
- @focusin="${(x, c) => x.handleFocus(c.event)}"
285
- @focusout="${(x, c) => x.handleBlur(c.event)}"
286
- @click="${(x, c) => x.handleClick(c.event)}"
287
- @selected-change="${(x, c) => x.handleSelectedChange(c.event)}"
288
- >
289
- <div class="${getClasses}">
290
- <slot ${slotted('slottedTreeItems')}></slot>
291
- </div>
292
- </template>`;
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}>`;
293
171
  };
294
172
 
295
- const treeViewDefinition = TreeView.compose({
296
- baseName: 'tree-view',
297
- template: TreeViewTemplate,
298
- styles: css_248z
173
+ const popupDefinition = Popup.compose({
174
+ baseName: "popup",
175
+ template: popupTemplate,
176
+ styles
299
177
  });
300
- const treeViewRegistries = [treeViewDefinition()];
301
- const registerTreeView = registerFactory(treeViewRegistries);
178
+ const popupRegistries = [popupDefinition(), ...elevationRegistries, ...buttonRegistries];
179
+ const registerPopup = registerFactory(popupRegistries);
302
180
 
303
- export { treeViewRegistries as a, registerTreeView as r, treeViewDefinition as t };
181
+ export { Popup as P, popupRegistries as p, registerPopup as r };