@vonage/vivid 3.9.0 → 3.11.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 (136) hide show
  1. package/accordion/index.js +1 -0
  2. package/alert/index.js +28 -0
  3. package/avatar/index.js +1 -1
  4. package/badge/index.js +1 -1
  5. package/banner/index.js +3 -3
  6. package/breadcrumb/index.js +2 -1
  7. package/breadcrumb-item/index.js +1 -1
  8. package/button/index.js +2 -2
  9. package/calendar/index.js +1 -1
  10. package/calendar-event/index.js +1 -1
  11. package/card/index.js +3 -2
  12. package/checkbox/index.js +1 -1
  13. package/combobox/index.js +7 -6
  14. package/custom-elements.json +589 -377
  15. package/data-grid/index.js +3 -2
  16. package/dialog/index.js +5 -4
  17. package/divider/index.js +1 -1
  18. package/elevation/index.js +1 -1
  19. package/fab/index.js +1 -1
  20. package/header/index.js +2 -2
  21. package/index.js +54 -52
  22. package/layout/index.js +1 -1
  23. package/lib/alert/alert.d.ts +24 -0
  24. package/lib/alert/alert.template.d.ts +4 -0
  25. package/lib/alert/definition.d.ts +2 -0
  26. package/lib/alert/index.d.ts +1 -0
  27. package/lib/components.d.ts +1 -0
  28. package/lib/enums.d.ts +10 -9
  29. package/lib/layout/layout.d.ts +2 -0
  30. package/lib/pagination/definition.d.ts +3 -0
  31. package/lib/pagination/index.d.ts +1 -0
  32. package/lib/pagination/pagination.d.ts +18 -0
  33. package/lib/pagination/pagination.template.d.ts +4 -0
  34. package/lib/popup/popup.d.ts +2 -2
  35. package/lib/text-area/text-area.d.ts +2 -1
  36. package/lib/tooltip/tooltip.d.ts +10 -4
  37. package/listbox/index.js +3 -2
  38. package/menu/index.js +7 -6
  39. package/menu-item/index.js +1 -1
  40. package/nav/index.js +1 -1
  41. package/nav-disclosure/index.js +1 -1
  42. package/nav-item/index.js +1 -1
  43. package/note/index.js +1 -1
  44. package/number-field/index.js +4 -4
  45. package/option/index.js +1 -1
  46. package/package.json +1 -1
  47. package/pagination/index.js +329 -0
  48. package/popup/index.js +4 -4
  49. package/progress/index.js +1 -1
  50. package/progress-ring/index.js +1 -1
  51. package/radio/index.js +1 -1
  52. package/radio-group/index.js +3 -2
  53. package/select/index.js +7 -6
  54. package/shared/children.js +1 -1
  55. package/shared/definition.js +3 -2
  56. package/shared/definition10.js +46 -63
  57. package/shared/definition11.js +38 -92
  58. package/shared/definition12.js +96 -31
  59. package/shared/definition13.js +85 -757
  60. package/shared/definition14.js +32 -95
  61. package/shared/definition15.js +758 -100
  62. package/shared/definition16.js +103 -24
  63. package/shared/definition17.js +96 -154
  64. package/shared/definition18.js +108 -663
  65. package/shared/definition19.js +667 -1532
  66. package/shared/definition2.js +1 -1
  67. package/shared/definition20.js +1532 -223
  68. package/shared/definition21.js +183 -964
  69. package/shared/definition22.js +1034 -218
  70. package/shared/definition23.js +226 -67
  71. package/shared/definition24.js +68 -77
  72. package/shared/definition25.js +76 -47
  73. package/shared/definition26.js +46 -32
  74. package/shared/definition27.js +39 -49
  75. package/shared/definition28.js +48 -344
  76. package/shared/definition29.js +273 -282
  77. package/shared/definition30.js +356 -14
  78. package/shared/definition31.js +13 -67
  79. package/shared/definition32.js +65 -21
  80. package/shared/definition33.js +21 -39
  81. package/shared/definition34.js +31 -432
  82. package/shared/definition35.js +432 -76
  83. package/shared/definition36.js +82 -33
  84. package/shared/definition37.js +31 -422
  85. package/shared/definition38.js +358 -564
  86. package/shared/definition39.js +628 -75
  87. package/shared/definition4.js +1 -1
  88. package/shared/definition40.js +70 -573
  89. package/shared/definition41.js +538 -81
  90. package/shared/definition42.js +127 -47
  91. package/shared/definition43.js +51 -16
  92. package/shared/definition44.js +17 -425
  93. package/shared/definition45.js +421 -103
  94. package/shared/definition46.js +114 -19
  95. package/shared/definition47.js +19 -269
  96. package/shared/definition48.js +244 -86
  97. package/shared/definition49.js +110 -70
  98. package/shared/definition5.js +1 -1
  99. package/shared/definition50.js +88 -67
  100. package/shared/definition51.js +69 -294
  101. package/shared/definition52.js +305 -0
  102. package/shared/definition6.js +142 -45
  103. package/shared/definition7.js +97 -24
  104. package/shared/definition8.js +22 -103
  105. package/shared/definition9.js +62 -102
  106. package/shared/enums.js +10 -9
  107. package/shared/es.object.assign.js +1 -1
  108. package/shared/form-associated.js +1 -1
  109. package/shared/form-elements.js +2 -2
  110. package/shared/index.js +1 -1
  111. package/shared/listbox.js +2 -2
  112. package/shared/node-observation.js +74 -0
  113. package/shared/patterns/form-elements/form-elements.d.ts +4 -4
  114. package/shared/repeat.js +1 -1
  115. package/shared/slotted.js +3 -73
  116. package/shared/text-field.js +1 -1
  117. package/shared/text-field2.js +1 -1
  118. package/side-drawer/index.js +1 -1
  119. package/slider/index.js +1 -1
  120. package/styles/core/all.css +1 -1
  121. package/styles/core/theme.css +1 -1
  122. package/styles/core/typography.css +1 -1
  123. package/styles/tokens/theme-dark.css +4 -4
  124. package/styles/tokens/theme-light.css +4 -4
  125. package/switch/index.js +1 -1
  126. package/tab/index.js +1 -1
  127. package/tab-panel/index.js +1 -1
  128. package/tabs/index.js +4 -3
  129. package/tag/index.js +1 -1
  130. package/tag-group/index.js +1 -1
  131. package/text-area/index.js +1 -1
  132. package/text-field/index.js +1 -1
  133. package/tooltip/index.js +5 -5
  134. package/tree-item/index.js +2 -1
  135. package/tree-view/index.js +2 -1
  136. package/vivid.api.json +128 -16
@@ -1,79 +1,100 @@
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 { s as slotted, e as elements } from './slotted.js';
10
- import { w as when } from './when.js';
11
- import { c as children } from './children.js';
1
+ import { F as FoundationElement, U as __classPrivateFieldGet, W as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactory } from './index.js';
2
+ import { P as Popup, p as popupRegistries } from './definition20.js';
12
3
  import { c as classNames } from './class-names.js';
13
- import { r as ref } from './ref.js';
14
4
 
15
- var css_248z = "/**\n * Do not edit directly\n * Generated on Mon, 24 Apr 2023 10:27:51 GMT\n */\n@supports selector(:focus-visible) {\n :host(:focus) {\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-400);\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 --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n --_connotation-color-primary-increment: var(--vvd-color-neutral-800);\n --_connotation-color-faint: var(--vvd-color-neutral-50);\n --_connotation-color-soft: var(--vvd-color-neutral-100);\n}\n@supports selector(:focus-visible) {\n .control:focus {\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}";
5
+ var css_248z = "/**\n * Do not edit directly\n * Generated on Mon, 08 May 2023 11:40:49 GMT\n */\n.control {\n pointer-events: none;\n}\n\n.tooltip {\n width: var(--tooltip-inline-size, auto);\n}\n.tooltip-text {\n padding: 8px 12px;\n color: var(--vvd-color-canvas-text);\n font: var(--vvd-typography-base-bold);\n}";
16
6
 
17
- class TreeItem extends TreeItem$1 {}
18
- __decorate([attr, __metadata("design:type", String)], TreeItem.prototype, "text", void 0);
19
- applyMixins(TreeItem, AffixIcon);
7
+ var _Tooltip_instances, _Tooltip_anchorEl, _Tooltip_anchorUpdated, _Tooltip_addEventListener, _Tooltip_removeEventListener, _Tooltip_show, _Tooltip_hide, _Tooltip_closeOnEscape;
8
+ class Tooltip extends FoundationElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ _Tooltip_instances.add(this);
12
+ _Tooltip_anchorEl.set(this, null);
13
+ this.open = false;
14
+ _Tooltip_show.set(this, () => {
15
+ this.open = true;
16
+ });
17
+ _Tooltip_hide.set(this, () => {
18
+ this.open = false;
19
+ });
20
+ _Tooltip_closeOnEscape.set(this, e => {
21
+ if (e.key === 'Escape') __classPrivateFieldGet(this, _Tooltip_hide, "f").call(this);
22
+ });
23
+ }
24
+ anchorChanged(_, newValue) {
25
+ if (__classPrivateFieldGet(this, _Tooltip_anchorEl, "f")) __classPrivateFieldGet(this, _Tooltip_instances, "m", _Tooltip_removeEventListener).call(this);
26
+ __classPrivateFieldSet(this, _Tooltip_anchorEl, newValue instanceof HTMLElement ? newValue : document.getElementById(newValue), "f");
27
+ if (__classPrivateFieldGet(this, _Tooltip_anchorEl, "f")) __classPrivateFieldGet(this, _Tooltip_instances, "m", _Tooltip_anchorUpdated).call(this);
28
+ }
29
+ disconnectedCallback() {
30
+ super.disconnectedCallback();
31
+ __classPrivateFieldGet(this, _Tooltip_instances, "m", _Tooltip_removeEventListener).call(this);
32
+ document.removeEventListener('keydown', __classPrivateFieldGet(this, _Tooltip_closeOnEscape, "f"));
33
+ }
34
+ openChanged(_, newValue) {
35
+ if (_ === undefined) return;
36
+ if (newValue) {
37
+ document.addEventListener('keydown', __classPrivateFieldGet(this, _Tooltip_closeOnEscape, "f"));
38
+ } else {
39
+ document.removeEventListener('keydown', __classPrivateFieldGet(this, _Tooltip_closeOnEscape, "f"));
40
+ }
41
+ }
42
+ }
43
+ _Tooltip_anchorEl = new WeakMap(), _Tooltip_show = new WeakMap(), _Tooltip_hide = new WeakMap(), _Tooltip_closeOnEscape = new WeakMap(), _Tooltip_instances = new WeakSet(), _Tooltip_anchorUpdated = function _Tooltip_anchorUpdated() {
44
+ __classPrivateFieldGet(this, _Tooltip_instances, "m", _Tooltip_removeEventListener).call(this);
45
+ __classPrivateFieldGet(this, _Tooltip_instances, "m", _Tooltip_addEventListener).call(this);
46
+ }, _Tooltip_addEventListener = function _Tooltip_addEventListener() {
47
+ if (__classPrivateFieldGet(this, _Tooltip_anchorEl, "f")) {
48
+ __classPrivateFieldGet(this, _Tooltip_anchorEl, "f").addEventListener('mouseover', __classPrivateFieldGet(this, _Tooltip_show, "f"));
49
+ __classPrivateFieldGet(this, _Tooltip_anchorEl, "f").addEventListener('mouseout', __classPrivateFieldGet(this, _Tooltip_hide, "f"));
50
+ __classPrivateFieldGet(this, _Tooltip_anchorEl, "f").addEventListener('focusin', __classPrivateFieldGet(this, _Tooltip_show, "f"));
51
+ __classPrivateFieldGet(this, _Tooltip_anchorEl, "f").addEventListener('focusout', __classPrivateFieldGet(this, _Tooltip_hide, "f"));
52
+ }
53
+ }, _Tooltip_removeEventListener = function _Tooltip_removeEventListener() {
54
+ var _a, _b, _c, _d;
55
+ (_a = __classPrivateFieldGet(this, _Tooltip_anchorEl, "f")) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseover', __classPrivateFieldGet(this, _Tooltip_show, "f"));
56
+ (_b = __classPrivateFieldGet(this, _Tooltip_anchorEl, "f")) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseout', __classPrivateFieldGet(this, _Tooltip_hide, "f"));
57
+ (_c = __classPrivateFieldGet(this, _Tooltip_anchorEl, "f")) === null || _c === void 0 ? void 0 : _c.removeEventListener('focusin', __classPrivateFieldGet(this, _Tooltip_show, "f"));
58
+ (_d = __classPrivateFieldGet(this, _Tooltip_anchorEl, "f")) === null || _d === void 0 ? void 0 : _d.removeEventListener('focusout', __classPrivateFieldGet(this, _Tooltip_hide, "f"));
59
+ };
60
+ __decorate([attr, __metadata("design:type", String)], Tooltip.prototype, "text", void 0);
61
+ __decorate([attr({
62
+ mode: 'fromView'
63
+ }), __metadata("design:type", String)], Tooltip.prototype, "placement", void 0);
64
+ __decorate([attr({
65
+ mode: 'boolean'
66
+ }), __metadata("design:type", Object)], Tooltip.prototype, "open", void 0);
67
+ __decorate([attr({
68
+ mode: 'fromView'
69
+ }), __metadata("design:type", Object)], Tooltip.prototype, "anchor", void 0);
20
70
 
21
71
  let _ = t => t,
22
- _t,
23
- _t2,
24
- _t3;
72
+ _t;
25
73
  const getClasses = ({
26
- disabled,
27
- selected
28
- }) => classNames('control', ['disabled', disabled], ['selected', Boolean(selected)]);
29
- const expandCollapseButton = context => {
30
- const iconTag = context.tagFor(Icon);
74
+ open
75
+ }) => classNames('control', ['open', Boolean(open)]);
76
+ const TooltipTemplate = context => {
77
+ const popupTag = context.tagFor(Popup);
31
78
  return html(_t || (_t = _`
32
- <div aria-hidden="true"
33
- class="expandCollapseButton"
34
- @click="${0}"
35
- ${0}
36
- >
37
- <${0} class="expandCollapseIcon" name="${0}"></${0}>
38
- </div>`), (x, c) => x.handleExpandCollapseButtonClick(c.event), ref('expandCollapseButton'), iconTag, x => x.expanded ? 'chevron-down-line' : 'chevron-right-line', iconTag);
39
- };
40
- const TreeItemTemplate = context => {
41
- const affixIconTemplate = affixIconTemplateFactory(context);
42
- const focusTemplate = focusTemplateFactory(context);
43
- return html(_t2 || (_t2 = _`
44
- <template
45
- role="treeitem"
46
- slot="${0}"
47
- tabindex="-1"
48
- aria-expanded="${0}"
49
- aria-selected="${0}"
50
- aria-disabled="${0}"
51
- @focusin="${0}"
52
- @focusout="${0}"
53
- ${0}
54
- >
55
- <div class="${0}">
56
- ${0}
57
- ${0}
58
- ${0}
59
- ${0}
60
- </div>
61
- ${0}
62
- </template>`), x => x.isNestedItem() ? 'item' : void 0, x => x.childItems && x.childItems.length > 0 ? x.expanded : void 0, x => x.selected, x => x.disabled, (x, c) => x.handleFocus(c.event), (x, c) => x.handleBlur(c.event), children({
63
- property: 'childItems',
64
- filter: elements()
65
- }), getClasses, () => focusTemplate, when(x => x.childItems && x.childItems.length > 0, expandCollapseButton(context)), x => affixIconTemplate(x.icon), x => x.text, when(x => x.childItems && x.childItems.length > 0 && x.expanded, html(_t3 || (_t3 = _`
66
- <div role="group" class="items">
67
- <slot name="item" ${0}></slot>
68
- </div>`), slotted('items'))));
79
+ <${0} class="${0}" arrow alternate
80
+ :placement=${0}
81
+ :anchor="${0}"
82
+ :open=${0}
83
+ exportparts="vvd-theme-alternate">
84
+ <div class="tooltip" role="tooltip">
85
+ <header part="vvd-theme-alternate" class="tooltip-header">
86
+ <div class="tooltip-text">${0}</div>
87
+ </header>
88
+ </div>
89
+ </${0}>`), popupTag, getClasses, x => x.placement, x => x.anchor, x => x.open, x => x.text, popupTag);
69
90
  };
70
91
 
71
- const treeItemDefinition = TreeItem.compose({
72
- baseName: 'tree-item',
73
- template: TreeItemTemplate,
92
+ const tooltipDefinition = Tooltip.compose({
93
+ baseName: 'tooltip',
94
+ template: TooltipTemplate,
74
95
  styles: css_248z
75
96
  });
76
- const treeItemRegistries = [treeItemDefinition(), ...iconRegistries, ...focusRegistries];
77
- const registerTreeItem = registerFactory(treeItemRegistries);
97
+ const tooltipRegistries = [tooltipDefinition(), ...popupRegistries];
98
+ const registerTooltip = registerFactory(tooltipRegistries);
78
99
 
79
- export { treeItemRegistries as a, registerTreeItem as r, treeItemDefinition as t };
100
+ export { tooltipRegistries as a, registerTooltip as r, tooltipDefinition as t };
@@ -1,305 +1,80 @@
1
- import { F as FoundationElement, W 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 { _ 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 { w as when } from './when.js';
5
11
  import { s as slotted } from './slotted.js';
6
- import { r as ref } from './ref.js';
12
+ import { c as children } from './children.js';
7
13
  import { c as classNames } from './class-names.js';
14
+ import { r as ref } from './ref.js';
8
15
 
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
- }
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);
272
-
273
- var css_248z = ".control {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}";
16
+ var css_248z = "/**\n * Do not edit directly\n * Generated on Mon, 08 May 2023 11:40:49 GMT\n */\n@supports selector(:focus-visible) {\n :host(:focus) {\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-400);\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 --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n --_connotation-color-primary-increment: var(--vvd-color-neutral-800);\n --_connotation-color-faint: var(--vvd-color-neutral-50);\n --_connotation-color-soft: var(--vvd-color-neutral-100);\n}\n@supports selector(:focus-visible) {\n .control:focus {\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}";
274
17
 
275
- class TreeView extends TreeView$1 {}
18
+ class TreeItem extends TreeItem$1 {}
19
+ __decorate([attr, __metadata("design:type", String)], TreeItem.prototype, "text", void 0);
20
+ applyMixins(TreeItem, AffixIcon);
276
21
 
277
- let _2 = t => t,
278
- _t;
279
- const getClasses = _ => classNames('control');
280
- const TreeViewTemplate = () => {
281
- return html(_t || (_t = _2`
282
- <template
283
- role="tree"
284
- ${0}
285
- @keydown="${0}"
286
- @focusin="${0}"
287
- @focusout="${0}"
22
+ let _ = t => t,
23
+ _t,
24
+ _t2,
25
+ _t3;
26
+ const getClasses = ({
27
+ disabled,
28
+ selected
29
+ }) => classNames('control', ['disabled', disabled], ['selected', Boolean(selected)]);
30
+ const expandCollapseButton = context => {
31
+ const iconTag = context.tagFor(Icon);
32
+ return html(_t || (_t = _`
33
+ <div aria-hidden="true"
34
+ class="expandCollapseButton"
288
35
  @click="${0}"
289
- @selected-change="${0}"
290
- >
291
- <div class="${0}">
292
- <slot ${0}></slot>
293
- </div>
294
- </template>`), ref('treeView'), (x, c) => x.handleKeyDown(c.event), (x, c) => x.handleFocus(c.event), (x, c) => x.handleBlur(c.event), (x, c) => x.handleClick(c.event), (x, c) => x.handleSelectedChange(c.event), getClasses, slotted('slottedTreeItems'));
36
+ ${0}
37
+ >
38
+ <${0} class="expandCollapseIcon" name="${0}"></${0}>
39
+ </div>`), (x, c) => x.handleExpandCollapseButtonClick(c.event), ref('expandCollapseButton'), iconTag, x => x.expanded ? 'chevron-down-line' : 'chevron-right-line', iconTag);
40
+ };
41
+ const TreeItemTemplate = context => {
42
+ const affixIconTemplate = affixIconTemplateFactory(context);
43
+ const focusTemplate = focusTemplateFactory(context);
44
+ return html(_t2 || (_t2 = _`
45
+ <template
46
+ role="treeitem"
47
+ slot="${0}"
48
+ tabindex="-1"
49
+ aria-expanded="${0}"
50
+ aria-selected="${0}"
51
+ aria-disabled="${0}"
52
+ @focusin="${0}"
53
+ @focusout="${0}"
54
+ ${0}
55
+ >
56
+ <div class="${0}">
57
+ ${0}
58
+ ${0}
59
+ ${0}
60
+ ${0}
61
+ </div>
62
+ ${0}
63
+ </template>`), x => x.isNestedItem() ? 'item' : void 0, x => x.childItems && x.childItems.length > 0 ? x.expanded : void 0, x => x.selected, x => x.disabled, (x, c) => x.handleFocus(c.event), (x, c) => x.handleBlur(c.event), children({
64
+ property: 'childItems',
65
+ filter: elements()
66
+ }), getClasses, () => focusTemplate, when(x => x.childItems && x.childItems.length > 0, expandCollapseButton(context)), x => affixIconTemplate(x.icon), x => x.text, when(x => x.childItems && x.childItems.length > 0 && x.expanded, html(_t3 || (_t3 = _`
67
+ <div role="group" class="items">
68
+ <slot name="item" ${0}></slot>
69
+ </div>`), slotted('items'))));
295
70
  };
296
71
 
297
- const treeViewDefinition = TreeView.compose({
298
- baseName: 'tree-view',
299
- template: TreeViewTemplate,
72
+ const treeItemDefinition = TreeItem.compose({
73
+ baseName: 'tree-item',
74
+ template: TreeItemTemplate,
300
75
  styles: css_248z
301
76
  });
302
- const treeViewRegistries = [treeViewDefinition()];
303
- const registerTreeView = registerFactory(treeViewRegistries);
77
+ const treeItemRegistries = [treeItemDefinition(), ...iconRegistries, ...focusRegistries];
78
+ const registerTreeItem = registerFactory(treeItemRegistries);
304
79
 
305
- export { treeViewRegistries as a, registerTreeView as r, treeViewDefinition as t };
80
+ export { treeItemRegistries as a, registerTreeItem as r, treeItemDefinition as t };