@vonage/vivid 3.49.0 → 3.50.1

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 (195) hide show
  1. package/accordion/index.cjs +0 -2
  2. package/accordion/index.js +0 -2
  3. package/accordion-item/index.cjs +0 -2
  4. package/accordion-item/index.js +0 -2
  5. package/alert/index.cjs +0 -2
  6. package/alert/index.js +0 -2
  7. package/audio-player/index.cjs +0 -2
  8. package/audio-player/index.js +0 -2
  9. package/banner/index.cjs +0 -2
  10. package/banner/index.js +0 -2
  11. package/breadcrumb-item/index.cjs +0 -2
  12. package/breadcrumb-item/index.js +0 -2
  13. package/button/index.cjs +0 -2
  14. package/button/index.js +0 -2
  15. package/checkbox/index.cjs +0 -3
  16. package/checkbox/index.js +0 -3
  17. package/combobox/index.cjs +4 -4
  18. package/combobox/index.js +4 -4
  19. package/custom-elements.json +749 -230
  20. package/data-grid/index.cjs +0 -2
  21. package/data-grid/index.js +0 -2
  22. package/date-picker/index.cjs +3 -2
  23. package/date-picker/index.js +3 -2
  24. package/date-range-picker/index.cjs +3 -2
  25. package/date-range-picker/index.js +3 -2
  26. package/dialog/index.cjs +0 -3
  27. package/dialog/index.js +0 -3
  28. package/fab/index.cjs +0 -2
  29. package/fab/index.js +0 -2
  30. package/file-picker/index.cjs +1 -2
  31. package/file-picker/index.js +1 -2
  32. package/focus/index.cjs +1 -1
  33. package/focus/index.js +1 -1
  34. package/index.cjs +20 -15
  35. package/index.js +9 -7
  36. package/lib/components.d.ts +1 -0
  37. package/lib/file-picker/file-picker.d.ts +2 -2
  38. package/lib/menu/definition.d.ts +2 -2
  39. package/lib/radio-group/definition.d.ts +2 -2
  40. package/lib/switch/switch.d.ts +2 -2
  41. package/lib/time-picker/definition.d.ts +3 -0
  42. package/lib/time-picker/locale.d.ts +12 -0
  43. package/lib/time-picker/time/picker.d.ts +9 -0
  44. package/lib/time-picker/time/presentationTime.d.ts +5 -0
  45. package/lib/time-picker/time/time.d.ts +15 -0
  46. package/lib/time-picker/time-picker.d.ts +16 -0
  47. package/lib/time-picker/time-picker.form-associated.d.ts +10 -0
  48. package/lib/time-picker/time-picker.template.d.ts +4 -0
  49. package/listbox/index.cjs +4 -12
  50. package/listbox/index.js +4 -12
  51. package/locales/en-GB.cjs +15 -0
  52. package/locales/en-GB.js +15 -0
  53. package/locales/en-US.cjs +15 -0
  54. package/locales/en-US.js +15 -0
  55. package/locales/ja-JP.cjs +15 -0
  56. package/locales/ja-JP.js +15 -0
  57. package/locales/zh-CN.cjs +15 -0
  58. package/locales/zh-CN.js +15 -0
  59. package/menu/index.cjs +0 -2
  60. package/menu/index.js +0 -2
  61. package/menu-item/index.cjs +0 -2
  62. package/menu-item/index.js +0 -2
  63. package/nav-disclosure/index.cjs +0 -2
  64. package/nav-disclosure/index.js +0 -2
  65. package/nav-item/index.cjs +0 -2
  66. package/nav-item/index.js +0 -2
  67. package/number-field/index.cjs +1 -2
  68. package/number-field/index.js +1 -2
  69. package/option/index.cjs +0 -5
  70. package/option/index.js +0 -5
  71. package/package.json +1 -1
  72. package/pagination/index.cjs +0 -2
  73. package/pagination/index.js +0 -2
  74. package/popup/index.cjs +0 -2
  75. package/popup/index.js +0 -2
  76. package/radio/index.cjs +0 -3
  77. package/radio/index.js +0 -3
  78. package/select/index.cjs +0 -3
  79. package/select/index.js +0 -3
  80. package/selectable-box/index.cjs +0 -3
  81. package/selectable-box/index.js +0 -3
  82. package/shared/date-picker/date-picker-base.d.ts +2 -2
  83. package/shared/definition.cjs +2 -6
  84. package/shared/definition.js +2 -6
  85. package/shared/definition11.cjs +1 -2
  86. package/shared/definition11.js +1 -2
  87. package/shared/definition15.cjs +2 -6
  88. package/shared/definition15.js +2 -6
  89. package/shared/definition16.cjs +1 -1
  90. package/shared/definition16.js +1 -1
  91. package/shared/definition17.cjs +1 -4
  92. package/shared/definition17.js +1 -4
  93. package/shared/definition18.cjs +2 -4
  94. package/shared/definition18.js +0 -2
  95. package/shared/definition19.cjs +2 -4
  96. package/shared/definition19.js +0 -2
  97. package/shared/definition20.cjs +1 -4
  98. package/shared/definition20.js +1 -4
  99. package/shared/definition23.cjs +1 -2
  100. package/shared/definition23.js +1 -2
  101. package/shared/definition24.cjs +2 -5
  102. package/shared/definition24.js +2 -5
  103. package/shared/definition28.cjs +2 -3
  104. package/shared/definition28.js +2 -3
  105. package/shared/definition30.cjs +2 -3
  106. package/shared/definition30.js +2 -3
  107. package/shared/definition31.cjs +2 -3
  108. package/shared/definition31.js +2 -3
  109. package/shared/definition34.cjs +1 -1
  110. package/shared/definition34.js +1 -1
  111. package/shared/definition35.cjs +2 -7
  112. package/shared/definition35.js +2 -7
  113. package/shared/definition4.cjs +3 -3
  114. package/shared/definition4.js +4 -4
  115. package/shared/definition40.cjs +3 -7
  116. package/shared/definition40.js +3 -7
  117. package/shared/definition41.cjs +5 -6
  118. package/shared/definition41.js +4 -5
  119. package/shared/definition42.cjs +5 -10
  120. package/shared/definition42.js +3 -8
  121. package/shared/definition44.cjs +1 -2
  122. package/shared/definition44.js +1 -2
  123. package/shared/definition45.cjs +1 -2
  124. package/shared/definition45.js +1 -2
  125. package/shared/definition46.cjs +1 -2
  126. package/shared/definition46.js +1 -2
  127. package/shared/definition48.cjs +2 -6
  128. package/shared/definition48.js +2 -6
  129. package/shared/definition5.cjs +1 -2
  130. package/shared/definition5.js +1 -2
  131. package/shared/definition51.cjs +2 -6
  132. package/shared/definition51.js +2 -6
  133. package/shared/definition52.cjs +2 -3
  134. package/shared/definition52.js +2 -3
  135. package/shared/definition53.cjs +1 -1
  136. package/shared/definition53.js +1 -1
  137. package/shared/definition54.cjs +768 -90
  138. package/shared/definition54.js +767 -89
  139. package/shared/definition55.cjs +75 -57
  140. package/shared/definition55.js +74 -56
  141. package/shared/definition56.cjs +100 -71
  142. package/shared/definition56.js +99 -70
  143. package/shared/definition57.cjs +76 -291
  144. package/shared/definition57.js +77 -292
  145. package/shared/definition58.cjs +303 -13
  146. package/shared/definition58.js +302 -13
  147. package/shared/definition61.cjs +20 -0
  148. package/shared/definition61.js +17 -0
  149. package/shared/definition9.cjs +1 -2
  150. package/shared/definition9.js +1 -2
  151. package/shared/icon.cjs +1 -1
  152. package/shared/icon.js +1 -1
  153. package/shared/localization/Locale.d.ts +2 -0
  154. package/shared/patterns/index.d.ts +1 -0
  155. package/shared/patterns/trapped-focus.d.ts +4 -0
  156. package/shared/presentationDate.cjs +15 -34
  157. package/shared/presentationDate.js +15 -34
  158. package/shared/text-field.cjs +1 -1
  159. package/shared/text-field.js +1 -1
  160. package/shared/trapped-focus.cjs +29 -0
  161. package/shared/trapped-focus.js +27 -0
  162. package/slider/index.cjs +0 -2
  163. package/slider/index.js +0 -2
  164. package/split-button/index.cjs +0 -2
  165. package/split-button/index.js +0 -2
  166. package/styles/core/all.css +1 -1
  167. package/styles/core/theme.css +1 -1
  168. package/styles/core/typography.css +1 -1
  169. package/styles/tokens/theme-dark.css +4 -4
  170. package/styles/tokens/theme-light.css +4 -4
  171. package/styles/tokens/vivid-2-compat.css +1 -1
  172. package/switch/index.cjs +0 -2
  173. package/switch/index.js +0 -2
  174. package/tab/index.cjs +0 -3
  175. package/tab/index.js +0 -3
  176. package/tabs/index.cjs +0 -3
  177. package/tabs/index.js +0 -3
  178. package/tag/index.cjs +0 -3
  179. package/tag/index.js +0 -3
  180. package/text-area/index.cjs +0 -2
  181. package/text-area/index.js +0 -2
  182. package/text-field/index.cjs +1 -1
  183. package/text-field/index.js +1 -1
  184. package/time-picker/index.cjs +38 -0
  185. package/time-picker/index.js +36 -0
  186. package/toggletip/index.cjs +1 -3
  187. package/toggletip/index.js +1 -3
  188. package/tooltip/index.cjs +1 -3
  189. package/tooltip/index.js +1 -3
  190. package/tree-item/index.cjs +1 -4
  191. package/tree-item/index.js +1 -4
  192. package/tree-view/index.cjs +1 -1
  193. package/tree-view/index.js +1 -1
  194. package/vivid.api.json +111 -42
  195. package/style.css +0 -1
@@ -1,18 +1,9 @@
1
- import { a as attr, h as html, r as registerFactory } from './index.js';
2
- import { a as iconRegistries } from './definition26.js';
3
- import { f as focusRegistries } from './definition58.js';
4
- import { A as AffixIcon, a as affixIconTemplateFactory, I as IconWrapper } 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, s as slotted } from './slotted.js';
10
- import { c as children } from './children.js';
11
- import { w as when } from './when.js';
1
+ import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
2
+ import { P as Popup, p as popupRegistries } from './definition60.js';
3
+ import { a as anchored } from './anchored.js';
12
4
  import { c as classNames } from './class-names.js';
13
- import { r as ref } from './ref.js';
14
5
 
15
- const styles = "@supports selector(:focus-visible){:host(:focus-visible){outline:none}}:host([disabled]){cursor:not-allowed}.control{position:relative;display:inline-flex;box-sizing:border-box;align-items:center;background-color:var(--_appearance-color-fill);border-radius:8px;box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:12px;hyphens:auto;inline-size:100%;min-block-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-inline:16px;text-decoration:none;vertical-align:middle;word-break:break-word}.control{--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(:disabled,.disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.control:where(:active,.active):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.control:where(.selected,[aria-current]):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary);--_appearance-color-outline: transparent}.control:where(.selected,[aria-current]):where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary-increment);--_appearance-color-outline: transparent}.control{--_connotation-color-primary: var(--vvd-tree-item-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-tree-item-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-tree-item-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-faint: var(--vvd-tree-item-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-tree-item-accent-soft, var(--vvd-color-neutral-100))}@supports selector(:focus-visible){.control:focus-visible{outline:none}}@supports (user-select: none){.control{user-select:none}}.control:not(.disabled){cursor:pointer}.control.disabled{pointer-events:none}.control .text{font:var(--vvd-typography-base)}.expandCollapseButton{display:flex;align-items:center;border-radius:8px;font-size:20px}.expandCollapseButton .expandCollapseIcon{margin:4px}.expandCollapseButton:hover{background-color:var(--vvd-color-neutral-100)}.selected .expandCollapseButton:hover{background-color:var(--vvd-color-neutral-700)}.items{display:flex;flex-direction:column;gap:4px;margin-block:4px;padding-inline-start:48px}:host(:not(:focus-visible)) .focus-indicator{display:none}slot[name=icon]{font-size:20px;line-height:1}.control:not(.disabled,.selected) slot[name=icon]{color:var(--vvd-color-neutral-600)}\n";
6
+ const styles = ".control{pointer-events:none}.tooltip{width:var(--tooltip-inline-size, auto)}.tooltip-text{padding:8px 12px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold)}\n";
16
7
 
17
8
  var __defProp = Object.defineProperty;
18
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -25,71 +16,109 @@ var __decorateClass = (decorators, target, key, kind) => {
25
16
  __defProp(target, key, result);
26
17
  return result;
27
18
  };
28
- class TreeItem extends TreeItem$1 {
29
- }
19
+ let Tooltip = class extends FoundationElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.open = false;
23
+ this.#show = () => {
24
+ this.open = true;
25
+ };
26
+ this.#hide = () => {
27
+ this.open = false;
28
+ };
29
+ this.#closeOnEscape = (e) => {
30
+ if (e.key === "Escape")
31
+ this.#hide();
32
+ };
33
+ }
34
+ connectedCallback() {
35
+ super.connectedCallback();
36
+ this.#updateListeners();
37
+ }
38
+ disconnectedCallback() {
39
+ super.disconnectedCallback();
40
+ this.#updateListeners();
41
+ }
42
+ /**
43
+ * @internal
44
+ */
45
+ _anchorElChanged(oldValue, newValue) {
46
+ if (oldValue)
47
+ this.#cleanupAnchor(oldValue);
48
+ if (newValue)
49
+ this.#setupAnchor(newValue);
50
+ }
51
+ #setupAnchor(a) {
52
+ a.addEventListener("mouseover", this.#show);
53
+ a.addEventListener("mouseout", this.#hide);
54
+ a.addEventListener("focusin", this.#show);
55
+ a.addEventListener("focusout", this.#hide);
56
+ }
57
+ #cleanupAnchor(a) {
58
+ a.removeEventListener("mouseover", this.#show);
59
+ a.removeEventListener("mouseout", this.#hide);
60
+ a.removeEventListener("focusin", this.#show);
61
+ a.removeEventListener("focusout", this.#hide);
62
+ }
63
+ #show;
64
+ #hide;
65
+ #updateListeners() {
66
+ document.removeEventListener("keydown", this.#closeOnEscape);
67
+ if (this.open && this.isConnected) {
68
+ document.addEventListener("keydown", this.#closeOnEscape);
69
+ }
70
+ }
71
+ #closeOnEscape;
72
+ /**
73
+ * @internal
74
+ */
75
+ openChanged(oldValue) {
76
+ if (oldValue === void 0)
77
+ return;
78
+ this.#updateListeners();
79
+ }
80
+ };
30
81
  __decorateClass([
31
82
  attr
32
- ], TreeItem.prototype, "text", 2);
33
- applyMixins(TreeItem, AffixIcon);
83
+ ], Tooltip.prototype, "text", 2);
84
+ __decorateClass([
85
+ attr({ mode: "fromView" })
86
+ ], Tooltip.prototype, "placement", 2);
87
+ __decorateClass([
88
+ attr({ mode: "boolean" })
89
+ ], Tooltip.prototype, "open", 2);
90
+ Tooltip = __decorateClass([
91
+ anchored
92
+ ], Tooltip);
34
93
 
35
94
  const getClasses = ({
36
- disabled,
37
- selected
95
+ open
38
96
  }) => classNames(
39
97
  "control",
40
- ["disabled", disabled],
41
- ["selected", Boolean(selected)]
98
+ ["open", Boolean(open)]
42
99
  );
43
- const expandCollapseButton = (context) => {
44
- const iconTag = context.tagFor(Icon);
100
+ const TooltipTemplate = (context) => {
101
+ const popupTag = context.tagFor(Popup);
45
102
  return html`
46
- <div aria-hidden="true"
47
- class="expandCollapseButton"
48
- @click="${(x, c) => x.handleExpandCollapseButtonClick(c.event)}"
49
- ${ref("expandCollapseButton")}
50
- >
51
- <${iconTag} class="expandCollapseIcon" name="${(x) => x.expanded ? "chevron-down-line" : "chevron-right-line"}"></${iconTag}>
52
- </div>`;
53
- };
54
- const TreeItemTemplate = (context) => {
55
- const affixIconTemplate = affixIconTemplateFactory(context);
56
- const focusTemplate = focusTemplateFactory(context);
57
- return html`
58
- <template
59
- role="treeitem"
60
- slot="${(x) => x.isNestedItem() ? "item" : void 0}"
61
- tabindex="-1"
62
- aria-expanded="${(x) => x.childItems && x.childItems.length > 0 ? x.expanded : void 0}"
63
- aria-selected="${(x) => x.selected}"
64
- aria-disabled="${(x) => x.disabled}"
65
- @focusin="${(x, c) => x.handleFocus(c.event)}"
66
- @focusout="${(x, c) => x.handleBlur(c.event)}"
67
- ${children({ property: "childItems", filter: elements(context.tagFor(TreeItem)) })}
68
- >
69
- <div class="${getClasses}">
70
- ${() => focusTemplate}
71
- ${when((x) => x.childItems && x.childItems.length > 0, expandCollapseButton(context))}
72
- ${(x) => affixIconTemplate(x.icon, IconWrapper.Slot)}
73
- ${(x) => x.text}
74
- </div>
75
- ${when(
76
- (x) => x.childItems && x.childItems.length > 0 && x.expanded,
77
- html`
78
- <div role="group" class="items">
79
- <slot name="item" ${slotted("items")}></slot>
80
- </div>`
81
- )}
82
- </template>`;
103
+ <${popupTag} class="${getClasses}" arrow alternate
104
+ :placement=${(x) => x.placement}
105
+ :anchor="${(x) => x._anchorEl}"
106
+ :open=${(x) => x.open}
107
+ exportparts="vvd-theme-alternate">
108
+ <div class="tooltip" role="tooltip">
109
+ <header part="vvd-theme-alternate" class="tooltip-header">
110
+ <div class="tooltip-text">${(x) => x.text}</div>
111
+ </header>
112
+ </div>
113
+ </${popupTag}>`;
83
114
  };
84
115
 
85
- const treeItemDefinition = TreeItem.compose(
86
- {
87
- baseName: "tree-item",
88
- template: TreeItemTemplate,
89
- styles
90
- }
91
- );
92
- const treeItemRegistries = [treeItemDefinition(), ...iconRegistries, ...focusRegistries];
93
- const registerTreeItem = registerFactory(treeItemRegistries);
116
+ const tooltipDefinition = Tooltip.compose({
117
+ baseName: "tooltip",
118
+ template: TooltipTemplate,
119
+ styles
120
+ });
121
+ const tooltipRegistries = [tooltipDefinition(), ...popupRegistries];
122
+ const registerTooltip = registerFactory(tooltipRegistries);
94
123
 
95
- export { treeItemRegistries as a, registerTreeItem as r, treeItemDefinition as t };
124
+ export { tooltipRegistries as a, registerTooltip as r, tooltipDefinition as t };
@@ -1,310 +1,95 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
+ const definition = require('./definition26.cjs');
5
+ const affix = require('./affix.cjs');
4
6
  const treeItem = require('./tree-item.cjs');
5
- const dom = require('./dom.cjs');
6
- const keyCodes = require('./key-codes.cjs');
7
- const ref = require('./ref.cjs');
7
+ const applyMixins = require('./apply-mixins.cjs');
8
+ const icon = require('./icon.cjs');
8
9
  const slotted = require('./slotted.cjs');
10
+ const children = require('./children.cjs');
11
+ const when = require('./when.cjs');
9
12
  const classNames = require('./class-names.cjs');
13
+ const ref = require('./ref.cjs');
10
14
 
11
- /**
12
- * A Tree view Custom HTML Element.
13
- * Implements the {@link https://w3c.github.io/aria-practices/#TreeView | ARIA TreeView }.
14
- *
15
- * @slot - The default slot for tree items
16
- *
17
- * @public
18
- */
19
- let TreeView$1 = class TreeView extends index.FoundationElement {
20
- constructor() {
21
- super(...arguments);
22
- /**
23
- * The tree item that is designated to be in the tab queue.
24
- *
25
- * @internal
26
- */
27
- this.currentFocused = null;
28
- /**
29
- * Handle focus events
30
- *
31
- * @internal
32
- */
33
- this.handleFocus = (e) => {
34
- if (this.slottedTreeItems.length < 1) {
35
- // no child items, nothing to do
36
- return;
37
- }
38
- if (e.target === this) {
39
- if (this.currentFocused === null) {
40
- this.currentFocused = this.getValidFocusableItem();
41
- }
42
- if (this.currentFocused !== null) {
43
- treeItem.TreeItem.focusItem(this.currentFocused);
44
- }
45
- return;
46
- }
47
- if (this.contains(e.target)) {
48
- this.setAttribute("tabindex", "-1");
49
- this.currentFocused = e.target;
50
- }
51
- };
52
- /**
53
- * Handle blur events
54
- *
55
- * @internal
56
- */
57
- this.handleBlur = (e) => {
58
- if (e.target instanceof HTMLElement &&
59
- (e.relatedTarget === null || !this.contains(e.relatedTarget))) {
60
- this.setAttribute("tabindex", "0");
61
- }
62
- };
63
- /**
64
- * KeyDown handler
65
- *
66
- * @internal
67
- */
68
- this.handleKeyDown = (e) => {
69
- if (e.defaultPrevented) {
70
- return;
71
- }
72
- if (this.slottedTreeItems.length < 1) {
73
- return true;
74
- }
75
- const treeItems = this.getVisibleNodes();
76
- switch (e.key) {
77
- case keyCodes.keyHome:
78
- if (treeItems.length) {
79
- treeItem.TreeItem.focusItem(treeItems[0]);
80
- }
81
- return;
82
- case keyCodes.keyEnd:
83
- if (treeItems.length) {
84
- treeItem.TreeItem.focusItem(treeItems[treeItems.length - 1]);
85
- }
86
- return;
87
- case keyCodes.keyArrowLeft:
88
- if (e.target && this.isFocusableElement(e.target)) {
89
- const item = e.target;
90
- if (item instanceof treeItem.TreeItem &&
91
- item.childItemLength() > 0 &&
92
- item.expanded) {
93
- item.expanded = false;
94
- }
95
- else if (item instanceof treeItem.TreeItem &&
96
- item.parentElement instanceof treeItem.TreeItem) {
97
- treeItem.TreeItem.focusItem(item.parentElement);
98
- }
99
- }
100
- return false;
101
- case keyCodes.keyArrowRight:
102
- if (e.target && this.isFocusableElement(e.target)) {
103
- const item = e.target;
104
- if (item instanceof treeItem.TreeItem &&
105
- item.childItemLength() > 0 &&
106
- !item.expanded) {
107
- item.expanded = true;
108
- }
109
- else if (item instanceof treeItem.TreeItem && item.childItemLength() > 0) {
110
- this.focusNextNode(1, e.target);
111
- }
112
- }
113
- return;
114
- case keyCodes.keyArrowDown:
115
- if (e.target && this.isFocusableElement(e.target)) {
116
- this.focusNextNode(1, e.target);
117
- }
118
- return;
119
- case keyCodes.keyArrowUp:
120
- if (e.target && this.isFocusableElement(e.target)) {
121
- this.focusNextNode(-1, e.target);
122
- }
123
- return;
124
- case keyCodes.keyEnter:
125
- // In single-select trees where selection does not follow focus (see note below),
126
- // the default action is typically to select the focused node.
127
- this.handleClick(e);
128
- return;
129
- }
130
- // don't prevent default if we took no action
131
- return true;
132
- };
133
- /**
134
- * Handles the selected-changed events bubbling up
135
- * from child tree items
136
- *
137
- * @internal
138
- */
139
- this.handleSelectedChange = (e) => {
140
- if (e.defaultPrevented) {
141
- return;
142
- }
143
- if (!(e.target instanceof Element) || !treeItem.isTreeItemElement(e.target)) {
144
- return true;
145
- }
146
- const item = e.target;
147
- if (item.selected) {
148
- if (this.currentSelected && this.currentSelected !== item) {
149
- this.currentSelected.selected = false;
150
- }
151
- // new selected item
152
- this.currentSelected = item;
153
- }
154
- else if (!item.selected && this.currentSelected === item) {
155
- // selected item deselected
156
- this.currentSelected = null;
157
- }
158
- return;
159
- };
160
- /**
161
- * Updates the tree view when slottedTreeItems changes
162
- */
163
- this.setItems = () => {
164
- // force single selection
165
- // defaults to first one found
166
- const selectedItem = this.treeView.querySelector("[aria-selected='true']");
167
- this.currentSelected = selectedItem;
168
- // invalidate the current focused item if it is no longer valid
169
- if (this.currentFocused === null || !this.contains(this.currentFocused)) {
170
- this.currentFocused = this.getValidFocusableItem();
171
- }
172
- // toggle properties on child elements
173
- this.nested = this.checkForNestedItems();
174
- const treeItems = this.getVisibleNodes();
175
- treeItems.forEach(node => {
176
- if (treeItem.isTreeItemElement(node)) {
177
- node.nested = this.nested;
178
- }
179
- });
180
- };
181
- /**
182
- * check if the item is focusable
183
- */
184
- this.isFocusableElement = (el) => {
185
- return treeItem.isTreeItemElement(el);
186
- };
187
- this.isSelectedElement = (el) => {
188
- return el.selected;
189
- };
190
- }
191
- slottedTreeItemsChanged() {
192
- if (this.$fastController.isConnected) {
193
- // update for slotted children change
194
- this.setItems();
195
- }
196
- }
197
- connectedCallback() {
198
- super.connectedCallback();
199
- this.setAttribute("tabindex", "0");
200
- index.DOM.queueUpdate(() => {
201
- this.setItems();
202
- });
203
- }
204
- /**
205
- * Handles click events bubbling up
206
- *
207
- * @internal
208
- */
209
- handleClick(e) {
210
- if (e.defaultPrevented) {
211
- // handled, do nothing
212
- return;
213
- }
214
- if (!(e.target instanceof Element) || !treeItem.isTreeItemElement(e.target)) {
215
- // not a tree item, ignore
216
- return true;
217
- }
218
- const item = e.target;
219
- if (!item.disabled) {
220
- item.selected = !item.selected;
221
- }
222
- return;
223
- }
224
- /**
225
- * Move focus to a tree item based on its offset from the provided item
226
- */
227
- focusNextNode(delta, item) {
228
- const visibleNodes = this.getVisibleNodes();
229
- if (!visibleNodes) {
230
- return;
231
- }
232
- const focusItem = visibleNodes[visibleNodes.indexOf(item) + delta];
233
- if (dom.isHTMLElement(focusItem)) {
234
- treeItem.TreeItem.focusItem(focusItem);
235
- }
236
- }
237
- /**
238
- * checks if there are any nested tree items
239
- */
240
- getValidFocusableItem() {
241
- const treeItems = this.getVisibleNodes();
242
- // default to selected element if there is one
243
- let focusIndex = treeItems.findIndex(this.isSelectedElement);
244
- if (focusIndex === -1) {
245
- // otherwise first focusable tree item
246
- focusIndex = treeItems.findIndex(this.isFocusableElement);
247
- }
248
- if (focusIndex !== -1) {
249
- return treeItems[focusIndex];
250
- }
251
- return null;
252
- }
253
- /**
254
- * checks if there are any nested tree items
255
- */
256
- checkForNestedItems() {
257
- return this.slottedTreeItems.some((node) => {
258
- return treeItem.isTreeItemElement(node) && node.querySelector("[role='treeitem']");
259
- });
260
- }
261
- getVisibleNodes() {
262
- return dom.getDisplayedNodes(this, "[role='treeitem']") || [];
263
- }
264
- };
265
- index.__decorate([
266
- index.attr({ attribute: "render-collapsed-nodes" })
267
- ], TreeView$1.prototype, "renderCollapsedNodes", void 0);
268
- index.__decorate([
269
- index.observable
270
- ], TreeView$1.prototype, "currentSelected", void 0);
271
- index.__decorate([
272
- index.observable
273
- ], TreeView$1.prototype, "slottedTreeItems", void 0);
274
-
275
- const styles = ".control{position:relative;display:flex;flex-direction:column;gap:4px}\n";
15
+ const styles = ":host(:focus-visible){outline:none}:host([disabled]){cursor:not-allowed}.control{position:relative;display:inline-flex;box-sizing:border-box;align-items:center;background-color:var(--_appearance-color-fill);border-radius:8px;box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:12px;hyphens:auto;inline-size:100%;min-block-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-inline:16px;text-decoration:none;vertical-align:middle;word-break:break-word}.control{--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(:disabled,.disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.control:where(:active,.active):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.control:where(.selected,[aria-current]):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary);--_appearance-color-outline: transparent}.control:where(.selected,[aria-current]):where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary-increment);--_appearance-color-outline: transparent}.control{--_connotation-color-primary: var(--vvd-tree-item-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-tree-item-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-tree-item-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-faint: var(--vvd-tree-item-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-tree-item-accent-soft, var(--vvd-color-neutral-100))}@supports (user-select: none){.control{user-select:none}}.control:not(.disabled){cursor:pointer}.control.disabled{pointer-events:none}:host(:focus-visible) .control{box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}:host(:focus-visible) .control:not(.selected){--focus-stroke-gap-color: transparent}.control .text{font:var(--vvd-typography-base)}.expandCollapseButton{display:flex;align-items:center;border-radius:8px;font-size:20px}.expandCollapseButton .expandCollapseIcon{margin:4px}.expandCollapseButton:hover{background-color:var(--vvd-color-neutral-100)}.selected .expandCollapseButton:hover{background-color:var(--vvd-color-neutral-700)}.items{display:flex;flex-direction:column;gap:4px;margin-block:4px;padding-inline-start:48px}slot[name=icon]{font-size:20px;line-height:1}.control:not(.disabled,.selected) slot[name=icon]{color:var(--vvd-color-neutral-600)}\n";
276
16
 
277
- class TreeView extends TreeView$1 {
17
+ var __defProp = Object.defineProperty;
18
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
19
+ var __decorateClass = (decorators, target, key, kind) => {
20
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
21
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
22
+ if (decorator = decorators[i])
23
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
24
+ if (kind && result)
25
+ __defProp(target, key, result);
26
+ return result;
27
+ };
28
+ class TreeItem extends treeItem.TreeItem {
278
29
  }
30
+ __decorateClass([
31
+ index.attr
32
+ ], TreeItem.prototype, "text", 2);
33
+ applyMixins.applyMixins(TreeItem, affix.AffixIcon);
279
34
 
280
- const getClasses = (_) => classNames.classNames("control");
281
- const TreeViewTemplate = () => {
35
+ const getClasses = ({
36
+ disabled,
37
+ selected
38
+ }) => classNames.classNames(
39
+ "control",
40
+ ["disabled", disabled],
41
+ ["selected", Boolean(selected)]
42
+ );
43
+ const expandCollapseButton = (context) => {
44
+ const iconTag = context.tagFor(icon.Icon);
45
+ return index.html`
46
+ <div aria-hidden="true"
47
+ class="expandCollapseButton"
48
+ @click="${(x, c) => x.handleExpandCollapseButtonClick(c.event)}"
49
+ ${ref.ref("expandCollapseButton")}
50
+ >
51
+ <${iconTag} class="expandCollapseIcon" name="${(x) => x.expanded ? "chevron-down-line" : "chevron-right-line"}"></${iconTag}>
52
+ </div>`;
53
+ };
54
+ const TreeItemTemplate = (context) => {
55
+ const affixIconTemplate = affix.affixIconTemplateFactory(context);
282
56
  return index.html`
283
57
  <template
284
- role="tree"
285
- ${ref.ref("treeView")}
286
- @keydown="${(x, c) => x.handleKeyDown(c.event)}"
287
- @focusin="${(x, c) => x.handleFocus(c.event)}"
288
- @focusout="${(x, c) => x.handleBlur(c.event)}"
289
- @click="${(x, c) => x.handleClick(c.event)}"
290
- @selected-change="${(x, c) => x.handleSelectedChange(c.event)}"
291
- >
292
- <div class="${getClasses}">
293
- <slot ${slotted.slotted("slottedTreeItems")}></slot>
294
- </div>
295
- </template>`;
58
+ role="treeitem"
59
+ slot="${(x) => x.isNestedItem() ? "item" : void 0}"
60
+ tabindex="-1"
61
+ aria-expanded="${(x) => x.childItems && x.childItems.length > 0 ? x.expanded : void 0}"
62
+ aria-selected="${(x) => x.selected}"
63
+ aria-disabled="${(x) => x.disabled}"
64
+ @focusin="${(x, c) => x.handleFocus(c.event)}"
65
+ @focusout="${(x, c) => x.handleBlur(c.event)}"
66
+ ${children.children({ property: "childItems", filter: slotted.elements(context.tagFor(TreeItem)) })}
67
+ >
68
+ <div class="${getClasses}">
69
+ ${when.when((x) => x.childItems && x.childItems.length > 0, expandCollapseButton(context))}
70
+ ${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)}
71
+ ${(x) => x.text}
72
+ </div>
73
+ ${when.when(
74
+ (x) => x.childItems && x.childItems.length > 0 && x.expanded,
75
+ index.html`
76
+ <div role="group" class="items">
77
+ <slot name="item" ${slotted.slotted("items")}></slot>
78
+ </div>`
79
+ )}
80
+ </template>`;
296
81
  };
297
82
 
298
- const treeViewDefinition = TreeView.compose(
83
+ const treeItemDefinition = TreeItem.compose(
299
84
  {
300
- baseName: "tree-view",
301
- template: TreeViewTemplate,
85
+ baseName: "tree-item",
86
+ template: TreeItemTemplate,
302
87
  styles
303
88
  }
304
89
  );
305
- const treeViewRegistries = [treeViewDefinition()];
306
- const registerTreeView = index.registerFactory(treeViewRegistries);
90
+ const treeItemRegistries = [treeItemDefinition(), ...definition.iconRegistries];
91
+ const registerTreeItem = index.registerFactory(treeItemRegistries);
307
92
 
308
- exports.registerTreeView = registerTreeView;
309
- exports.treeViewDefinition = treeViewDefinition;
310
- exports.treeViewRegistries = treeViewRegistries;
93
+ exports.registerTreeItem = registerTreeItem;
94
+ exports.treeItemDefinition = treeItemDefinition;
95
+ exports.treeItemRegistries = treeItemRegistries;