@vonage/vivid 3.49.0 → 3.50.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 (197) hide show
  1. package/accordion/index.cjs +1 -1
  2. package/accordion/index.js +1 -1
  3. package/accordion-item/index.cjs +1 -1
  4. package/accordion-item/index.js +1 -1
  5. package/alert/index.cjs +2 -2
  6. package/alert/index.js +2 -2
  7. package/audio-player/index.cjs +1 -1
  8. package/audio-player/index.js +1 -1
  9. package/banner/index.cjs +1 -1
  10. package/banner/index.js +1 -1
  11. package/breadcrumb-item/index.cjs +1 -1
  12. package/breadcrumb-item/index.js +1 -1
  13. package/button/index.cjs +1 -1
  14. package/button/index.js +1 -1
  15. package/card/index.cjs +1 -1
  16. package/card/index.js +1 -1
  17. package/checkbox/index.cjs +1 -2
  18. package/checkbox/index.js +1 -2
  19. package/combobox/index.cjs +3 -3
  20. package/combobox/index.js +3 -3
  21. package/custom-elements.json +797 -124
  22. package/date-picker/index.cjs +4 -3
  23. package/date-picker/index.js +4 -3
  24. package/date-range-picker/index.cjs +3 -2
  25. package/date-range-picker/index.js +3 -2
  26. package/dialog/index.cjs +2 -2
  27. package/dialog/index.js +2 -2
  28. package/elevation/index.cjs +1 -1
  29. package/elevation/index.js +1 -1
  30. package/fab/index.cjs +1 -1
  31. package/fab/index.js +1 -1
  32. package/file-picker/index.cjs +1 -1
  33. package/file-picker/index.js +1 -1
  34. package/focus/index.cjs +1 -1
  35. package/focus/index.js +1 -1
  36. package/header/index.cjs +1 -1
  37. package/header/index.js +1 -1
  38. package/index.cjs +21 -16
  39. package/index.js +10 -8
  40. package/lib/components.d.ts +1 -0
  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 +1 -1
  50. package/listbox/index.js +1 -1
  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 +3 -3
  60. package/menu/index.js +3 -3
  61. package/menu-item/index.cjs +1 -1
  62. package/menu-item/index.js +1 -1
  63. package/nav-disclosure/index.cjs +1 -1
  64. package/nav-disclosure/index.js +1 -1
  65. package/nav-item/index.cjs +1 -1
  66. package/nav-item/index.js +1 -1
  67. package/number-field/index.cjs +1 -1
  68. package/number-field/index.js +1 -1
  69. package/option/index.cjs +1 -1
  70. package/option/index.js +1 -1
  71. package/package.json +1 -1
  72. package/pagination/index.cjs +1 -1
  73. package/pagination/index.js +1 -1
  74. package/popup/index.cjs +3 -3
  75. package/popup/index.js +3 -3
  76. package/radio/index.cjs +1 -2
  77. package/radio/index.js +1 -2
  78. package/select/index.cjs +3 -3
  79. package/select/index.js +3 -3
  80. package/selectable-box/index.cjs +2 -2
  81. package/selectable-box/index.js +2 -2
  82. package/shared/date-picker/date-picker-base.d.ts +2 -2
  83. package/shared/definition.cjs +1 -1
  84. package/shared/definition.js +1 -1
  85. package/shared/definition11.cjs +1 -1
  86. package/shared/definition11.js +1 -1
  87. package/shared/definition14.cjs +1 -1
  88. package/shared/definition14.js +1 -1
  89. package/shared/definition15.cjs +2 -5
  90. package/shared/definition15.js +2 -5
  91. package/shared/definition16.cjs +2 -2
  92. package/shared/definition16.js +2 -2
  93. package/shared/definition18.cjs +2 -2
  94. package/shared/definition18.js +2 -2
  95. package/shared/definition19.cjs +2 -2
  96. package/shared/definition19.js +2 -2
  97. package/shared/definition20.cjs +1 -1
  98. package/shared/definition20.js +1 -1
  99. package/shared/definition23.cjs +1 -1
  100. package/shared/definition23.js +1 -1
  101. package/shared/definition24.cjs +1 -1
  102. package/shared/definition24.js +1 -1
  103. package/shared/definition25.cjs +1 -1
  104. package/shared/definition25.js +1 -1
  105. package/shared/definition28.cjs +1 -1
  106. package/shared/definition28.js +1 -1
  107. package/shared/definition29.cjs +1 -1
  108. package/shared/definition29.js +1 -1
  109. package/shared/definition30.cjs +1 -1
  110. package/shared/definition30.js +1 -1
  111. package/shared/definition31.cjs +1 -1
  112. package/shared/definition31.js +1 -1
  113. package/shared/definition35.cjs +1 -1
  114. package/shared/definition35.js +1 -1
  115. package/shared/definition4.cjs +1 -1
  116. package/shared/definition4.js +1 -1
  117. package/shared/definition40.cjs +3 -6
  118. package/shared/definition40.js +3 -6
  119. package/shared/definition41.cjs +2 -2
  120. package/shared/definition41.js +2 -2
  121. package/shared/definition42.cjs +1 -1
  122. package/shared/definition42.js +1 -1
  123. package/shared/definition44.cjs +1 -1
  124. package/shared/definition44.js +1 -1
  125. package/shared/definition45.cjs +1 -1
  126. package/shared/definition45.js +1 -1
  127. package/shared/definition46.cjs +1 -1
  128. package/shared/definition46.js +1 -1
  129. package/shared/definition48.cjs +1 -1
  130. package/shared/definition48.js +1 -1
  131. package/shared/definition5.cjs +1 -1
  132. package/shared/definition5.js +1 -1
  133. package/shared/definition51.cjs +1 -1
  134. package/shared/definition51.js +1 -1
  135. package/shared/definition52.cjs +1 -1
  136. package/shared/definition52.js +1 -1
  137. package/shared/definition53.cjs +1 -1
  138. package/shared/definition53.js +1 -1
  139. package/shared/definition54.cjs +769 -91
  140. package/shared/definition54.js +768 -90
  141. package/shared/definition55.cjs +76 -58
  142. package/shared/definition55.js +75 -57
  143. package/shared/definition56.cjs +100 -71
  144. package/shared/definition56.js +99 -70
  145. package/shared/definition57.cjs +80 -291
  146. package/shared/definition57.js +81 -292
  147. package/shared/definition58.cjs +303 -13
  148. package/shared/definition58.js +302 -13
  149. package/shared/definition59.cjs +11 -42
  150. package/shared/definition59.js +11 -41
  151. package/shared/definition60.cjs +23 -1782
  152. package/shared/definition60.js +22 -1781
  153. package/shared/definition61.cjs +1810 -0
  154. package/shared/definition61.js +1806 -0
  155. package/shared/definition9.cjs +1 -1
  156. package/shared/definition9.js +1 -1
  157. package/shared/localization/Locale.d.ts +2 -0
  158. package/shared/patterns/index.d.ts +1 -0
  159. package/shared/patterns/trapped-focus.d.ts +4 -0
  160. package/shared/presentationDate.cjs +11 -25
  161. package/shared/presentationDate.js +11 -25
  162. package/shared/trapped-focus.cjs +29 -0
  163. package/shared/trapped-focus.js +27 -0
  164. package/slider/index.cjs +1 -1
  165. package/slider/index.js +1 -1
  166. package/split-button/index.cjs +1 -1
  167. package/split-button/index.js +1 -1
  168. package/style.css +1 -1
  169. package/styles/core/all.css +1 -1
  170. package/styles/core/theme.css +1 -1
  171. package/styles/core/typography.css +1 -1
  172. package/styles/tokens/theme-dark.css +4 -4
  173. package/styles/tokens/theme-light.css +4 -4
  174. package/styles/tokens/vivid-2-compat.css +1 -1
  175. package/switch/index.cjs +1 -1
  176. package/switch/index.js +1 -1
  177. package/tab/index.cjs +1 -1
  178. package/tab/index.js +1 -1
  179. package/tabs/index.cjs +1 -1
  180. package/tabs/index.js +1 -1
  181. package/tag/index.cjs +1 -1
  182. package/tag/index.js +1 -1
  183. package/text-area/index.cjs +1 -1
  184. package/text-area/index.js +1 -1
  185. package/text-field/index.cjs +1 -1
  186. package/text-field/index.js +1 -1
  187. package/time-picker/index.cjs +38 -0
  188. package/time-picker/index.js +36 -0
  189. package/toggletip/index.cjs +4 -4
  190. package/toggletip/index.js +4 -4
  191. package/tooltip/index.cjs +4 -4
  192. package/tooltip/index.js +4 -4
  193. package/tree-item/index.cjs +2 -2
  194. package/tree-item/index.js +2 -2
  195. package/tree-view/index.cjs +1 -1
  196. package/tree-view/index.js +1 -1
  197. package/vivid.api.json +105 -0
@@ -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 './definition61.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,99 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
+ const definition = require('./definition26.cjs');
5
+ const definition$1 = require('./definition59.cjs');
6
+ const affix = require('./affix.cjs');
4
7
  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');
8
+ const applyMixins = require('./apply-mixins.cjs');
9
+ const icon = require('./icon.cjs');
10
+ const focus = require('./focus2.cjs');
8
11
  const slotted = require('./slotted.cjs');
12
+ const children = require('./children.cjs');
13
+ const when = require('./when.cjs');
9
14
  const classNames = require('./class-names.cjs');
15
+ const ref = require('./ref.cjs');
10
16
 
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";
17
+ 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";
276
18
 
277
- class TreeView extends TreeView$1 {
19
+ var __defProp = Object.defineProperty;
20
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
21
+ var __decorateClass = (decorators, target, key, kind) => {
22
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
23
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
24
+ if (decorator = decorators[i])
25
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
26
+ if (kind && result)
27
+ __defProp(target, key, result);
28
+ return result;
29
+ };
30
+ class TreeItem extends treeItem.TreeItem {
278
31
  }
32
+ __decorateClass([
33
+ index.attr
34
+ ], TreeItem.prototype, "text", 2);
35
+ applyMixins.applyMixins(TreeItem, affix.AffixIcon);
279
36
 
280
- const getClasses = (_) => classNames.classNames("control");
281
- const TreeViewTemplate = () => {
37
+ const getClasses = ({
38
+ disabled,
39
+ selected
40
+ }) => classNames.classNames(
41
+ "control",
42
+ ["disabled", disabled],
43
+ ["selected", Boolean(selected)]
44
+ );
45
+ const expandCollapseButton = (context) => {
46
+ const iconTag = context.tagFor(icon.Icon);
47
+ return index.html`
48
+ <div aria-hidden="true"
49
+ class="expandCollapseButton"
50
+ @click="${(x, c) => x.handleExpandCollapseButtonClick(c.event)}"
51
+ ${ref.ref("expandCollapseButton")}
52
+ >
53
+ <${iconTag} class="expandCollapseIcon" name="${(x) => x.expanded ? "chevron-down-line" : "chevron-right-line"}"></${iconTag}>
54
+ </div>`;
55
+ };
56
+ const TreeItemTemplate = (context) => {
57
+ const affixIconTemplate = affix.affixIconTemplateFactory(context);
58
+ const focusTemplate = focus.focusTemplateFactory(context);
282
59
  return index.html`
283
60
  <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>`;
61
+ role="treeitem"
62
+ slot="${(x) => x.isNestedItem() ? "item" : void 0}"
63
+ tabindex="-1"
64
+ aria-expanded="${(x) => x.childItems && x.childItems.length > 0 ? x.expanded : void 0}"
65
+ aria-selected="${(x) => x.selected}"
66
+ aria-disabled="${(x) => x.disabled}"
67
+ @focusin="${(x, c) => x.handleFocus(c.event)}"
68
+ @focusout="${(x, c) => x.handleBlur(c.event)}"
69
+ ${children.children({ property: "childItems", filter: slotted.elements(context.tagFor(TreeItem)) })}
70
+ >
71
+ <div class="${getClasses}">
72
+ ${() => focusTemplate}
73
+ ${when.when((x) => x.childItems && x.childItems.length > 0, expandCollapseButton(context))}
74
+ ${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)}
75
+ ${(x) => x.text}
76
+ </div>
77
+ ${when.when(
78
+ (x) => x.childItems && x.childItems.length > 0 && x.expanded,
79
+ index.html`
80
+ <div role="group" class="items">
81
+ <slot name="item" ${slotted.slotted("items")}></slot>
82
+ </div>`
83
+ )}
84
+ </template>`;
296
85
  };
297
86
 
298
- const treeViewDefinition = TreeView.compose(
87
+ const treeItemDefinition = TreeItem.compose(
299
88
  {
300
- baseName: "tree-view",
301
- template: TreeViewTemplate,
89
+ baseName: "tree-item",
90
+ template: TreeItemTemplate,
302
91
  styles
303
92
  }
304
93
  );
305
- const treeViewRegistries = [treeViewDefinition()];
306
- const registerTreeView = index.registerFactory(treeViewRegistries);
94
+ const treeItemRegistries = [treeItemDefinition(), ...definition.iconRegistries, ...definition$1.focusRegistries];
95
+ const registerTreeItem = index.registerFactory(treeItemRegistries);
307
96
 
308
- exports.registerTreeView = registerTreeView;
309
- exports.treeViewDefinition = treeViewDefinition;
310
- exports.treeViewRegistries = treeViewRegistries;
97
+ exports.registerTreeItem = registerTreeItem;
98
+ exports.treeItemDefinition = treeItemDefinition;
99
+ exports.treeItemRegistries = treeItemRegistries;