@aquera/nile-elements 0.0.1-beta.3 → 0.0.1-beta.4

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 (187) hide show
  1. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/index.d.ts +4 -0
  2. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/index.js +4 -0
  3. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/index.js.map +1 -1
  4. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/internal/tabbable.d.ts +8 -0
  5. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/internal/tabbable.js +65 -0
  6. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/internal/tabbable.js.map +1 -0
  7. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/index.d.ts +1 -0
  8. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/index.js +2 -0
  9. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/index.js.map +1 -0
  10. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/nile-auto-complete.css.d.ts +12 -0
  11. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/nile-auto-complete.css.js +23 -0
  12. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/nile-auto-complete.css.js.map +1 -0
  13. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/nile-auto-complete.d.ts +27 -0
  14. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/nile-auto-complete.js +127 -0
  15. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -0
  16. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/index.d.ts +1 -0
  17. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/index.js +2 -0
  18. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/index.js.map +1 -0
  19. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/nile-chip.css.d.ts +12 -0
  20. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/nile-chip.css.js +146 -0
  21. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/nile-chip.css.js.map +1 -0
  22. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/nile-chip.d.ts +44 -0
  23. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/nile-chip.js +175 -0
  24. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-chip/nile-chip.js.map +1 -0
  25. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/index.d.ts +1 -0
  26. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/index.js +2 -0
  27. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/index.js.map +1 -0
  28. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/nile-dropdown.css.d.ts +12 -0
  29. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/nile-dropdown.css.js +60 -0
  30. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/nile-dropdown.css.js.map +1 -0
  31. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/nile-dropdown.d.ts +105 -0
  32. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/nile-dropdown.js +412 -0
  33. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-dropdown/nile-dropdown.js.map +1 -0
  34. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-input/nile-input.css.js +20 -0
  35. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-input/nile-input.css.js.map +1 -1
  36. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/index.d.ts +1 -41
  37. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/index.js +1 -119
  38. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/index.js.map +1 -1
  39. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/nile-menu.css.d.ts +12 -0
  40. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/nile-menu.css.js +28 -0
  41. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/nile-menu.css.js.map +1 -0
  42. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/nile-menu.d.ts +43 -0
  43. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/nile-menu.js +142 -0
  44. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu/nile-menu.js.map +1 -0
  45. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/index.d.ts +1 -0
  46. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/index.js +2 -0
  47. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/index.js.map +1 -0
  48. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/nile-menu-item.css.d.ts +12 -0
  49. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/nile-menu-item.css.js +121 -0
  50. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/nile-menu-item.css.js.map +1 -0
  51. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/nile-menu-item.d.ts +62 -0
  52. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/nile-menu-item.js +173 -0
  53. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/src/nile-menu-item/nile-menu-item.js.map +1 -0
  54. package/.rollup.cache/Users/ravisankar/aquera/nile/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  55. package/dist/index.cjs.js +1 -1
  56. package/dist/index.esm.js +1 -1
  57. package/dist/internal/slot.cjs.js +1 -1
  58. package/dist/internal/slot.cjs.js.map +1 -1
  59. package/dist/internal/slot.esm.js +1 -1
  60. package/dist/internal/tabbable.cjs.js +2 -0
  61. package/dist/internal/tabbable.cjs.js.map +1 -0
  62. package/dist/internal/tabbable.esm.js +1 -0
  63. package/dist/nile-auto-complete/index.cjs.js +2 -0
  64. package/dist/nile-auto-complete/index.cjs.js.map +1 -0
  65. package/dist/nile-auto-complete/index.esm.js +1 -0
  66. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +2 -0
  67. package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -0
  68. package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js +2 -0
  69. package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js.map +1 -0
  70. package/dist/nile-auto-complete/nile-auto-complete.css.esm.js +11 -0
  71. package/dist/nile-auto-complete/nile-auto-complete.esm.js +21 -0
  72. package/dist/nile-chip/index.cjs.js +2 -0
  73. package/dist/nile-chip/index.cjs.js.map +1 -0
  74. package/dist/nile-chip/index.esm.js +1 -0
  75. package/dist/nile-chip/nile-chip.cjs.js +2 -0
  76. package/dist/nile-chip/nile-chip.cjs.js.map +1 -0
  77. package/dist/nile-chip/nile-chip.css.cjs.js +2 -0
  78. package/dist/nile-chip/nile-chip.css.cjs.js.map +1 -0
  79. package/dist/nile-chip/nile-chip.css.esm.js +134 -0
  80. package/dist/nile-chip/nile-chip.esm.js +46 -0
  81. package/dist/nile-dropdown/index.cjs.js +2 -0
  82. package/dist/nile-dropdown/index.cjs.js.map +1 -0
  83. package/dist/nile-dropdown/index.esm.js +1 -0
  84. package/dist/nile-dropdown/nile-dropdown.cjs.js +2 -0
  85. package/dist/nile-dropdown/nile-dropdown.cjs.js.map +1 -0
  86. package/dist/nile-dropdown/nile-dropdown.css.cjs.js +2 -0
  87. package/dist/nile-dropdown/nile-dropdown.css.cjs.js.map +1 -0
  88. package/dist/nile-dropdown/nile-dropdown.css.esm.js +48 -0
  89. package/dist/nile-dropdown/nile-dropdown.esm.js +33 -0
  90. package/dist/nile-input/nile-input.css.cjs.js +1 -1
  91. package/dist/nile-input/nile-input.css.cjs.js.map +1 -1
  92. package/dist/nile-input/nile-input.css.esm.js +20 -0
  93. package/dist/nile-menu/index.cjs.js +1 -1
  94. package/dist/nile-menu/index.cjs.js.map +1 -1
  95. package/dist/nile-menu/index.esm.js +1 -53
  96. package/dist/nile-menu/nile-menu.cjs.js +2 -0
  97. package/dist/nile-menu/nile-menu.cjs.js.map +1 -0
  98. package/dist/nile-menu/nile-menu.css.cjs.js +2 -0
  99. package/dist/nile-menu/nile-menu.css.cjs.js.map +1 -0
  100. package/dist/nile-menu/nile-menu.css.esm.js +16 -0
  101. package/dist/nile-menu/nile-menu.esm.js +8 -0
  102. package/dist/nile-menu-item/index.cjs.js +2 -0
  103. package/dist/nile-menu-item/index.cjs.js.map +1 -0
  104. package/dist/nile-menu-item/index.esm.js +1 -0
  105. package/dist/nile-menu-item/nile-menu-item.cjs.js +2 -0
  106. package/dist/nile-menu-item/nile-menu-item.cjs.js.map +1 -0
  107. package/dist/nile-menu-item/nile-menu-item.css.cjs.js +2 -0
  108. package/dist/nile-menu-item/nile-menu-item.css.cjs.js.map +1 -0
  109. package/dist/nile-menu-item/nile-menu-item.css.esm.js +109 -0
  110. package/dist/nile-menu-item/nile-menu-item.esm.js +20 -0
  111. package/dist/src/index.d.ts +4 -0
  112. package/dist/src/index.js +4 -0
  113. package/dist/src/index.js.map +1 -1
  114. package/dist/src/internal/tabbable.d.ts +8 -0
  115. package/dist/src/internal/tabbable.js +65 -0
  116. package/dist/src/internal/tabbable.js.map +1 -0
  117. package/dist/src/nile-auto-complete/index.d.ts +1 -0
  118. package/dist/src/nile-auto-complete/index.js +2 -0
  119. package/dist/src/nile-auto-complete/index.js.map +1 -0
  120. package/dist/src/nile-auto-complete/nile-auto-complete.css.d.ts +12 -0
  121. package/dist/src/nile-auto-complete/nile-auto-complete.css.js +23 -0
  122. package/dist/src/nile-auto-complete/nile-auto-complete.css.js.map +1 -0
  123. package/dist/src/nile-auto-complete/nile-auto-complete.d.ts +27 -0
  124. package/dist/src/nile-auto-complete/nile-auto-complete.js +127 -0
  125. package/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -0
  126. package/dist/src/nile-chip/index.d.ts +1 -0
  127. package/dist/src/nile-chip/index.js +2 -0
  128. package/dist/src/nile-chip/index.js.map +1 -0
  129. package/dist/src/nile-chip/nile-chip.css.d.ts +12 -0
  130. package/dist/src/nile-chip/nile-chip.css.js +146 -0
  131. package/dist/src/nile-chip/nile-chip.css.js.map +1 -0
  132. package/dist/src/nile-chip/nile-chip.d.ts +44 -0
  133. package/dist/src/nile-chip/nile-chip.js +175 -0
  134. package/dist/src/nile-chip/nile-chip.js.map +1 -0
  135. package/dist/src/nile-dropdown/index.d.ts +1 -0
  136. package/dist/src/nile-dropdown/index.js +2 -0
  137. package/dist/src/nile-dropdown/index.js.map +1 -0
  138. package/dist/src/nile-dropdown/nile-dropdown.css.d.ts +12 -0
  139. package/dist/src/nile-dropdown/nile-dropdown.css.js +60 -0
  140. package/dist/src/nile-dropdown/nile-dropdown.css.js.map +1 -0
  141. package/dist/src/nile-dropdown/nile-dropdown.d.ts +105 -0
  142. package/dist/src/nile-dropdown/nile-dropdown.js +412 -0
  143. package/dist/src/nile-dropdown/nile-dropdown.js.map +1 -0
  144. package/dist/src/nile-input/nile-input.css.js +20 -0
  145. package/dist/src/nile-input/nile-input.css.js.map +1 -1
  146. package/dist/src/nile-menu/index.d.ts +1 -41
  147. package/dist/src/nile-menu/index.js +1 -119
  148. package/dist/src/nile-menu/index.js.map +1 -1
  149. package/dist/src/nile-menu/nile-menu.css.d.ts +12 -0
  150. package/dist/src/nile-menu/nile-menu.css.js +28 -0
  151. package/dist/src/nile-menu/nile-menu.css.js.map +1 -0
  152. package/dist/src/nile-menu/nile-menu.d.ts +43 -0
  153. package/dist/src/nile-menu/nile-menu.js +142 -0
  154. package/dist/src/nile-menu/nile-menu.js.map +1 -0
  155. package/dist/src/nile-menu-item/index.d.ts +1 -0
  156. package/dist/src/nile-menu-item/index.js +2 -0
  157. package/dist/src/nile-menu-item/index.js.map +1 -0
  158. package/dist/src/nile-menu-item/nile-menu-item.css.d.ts +12 -0
  159. package/dist/src/nile-menu-item/nile-menu-item.css.js +121 -0
  160. package/dist/src/nile-menu-item/nile-menu-item.css.js.map +1 -0
  161. package/dist/src/nile-menu-item/nile-menu-item.d.ts +62 -0
  162. package/dist/src/nile-menu-item/nile-menu-item.js +173 -0
  163. package/dist/src/nile-menu-item/nile-menu-item.js.map +1 -0
  164. package/dist/tsconfig.tsbuildinfo +1 -1
  165. package/dist/watch.cjs.js +1 -1
  166. package/dist/watch.cjs.js.map +1 -1
  167. package/dist/watch.esm.js +1 -1
  168. package/package.json +1 -1
  169. package/src/index.ts +4 -0
  170. package/src/internal/tabbable.ts +81 -0
  171. package/src/nile-auto-complete/index.ts +1 -0
  172. package/src/nile-auto-complete/nile-auto-complete.css.ts +25 -0
  173. package/src/nile-auto-complete/nile-auto-complete.ts +132 -0
  174. package/src/nile-chip/index.ts +1 -0
  175. package/src/nile-chip/nile-chip.css.ts +148 -0
  176. package/src/nile-chip/nile-chip.ts +183 -0
  177. package/src/nile-dropdown/index.ts +1 -0
  178. package/src/nile-dropdown/nile-dropdown.css.ts +62 -0
  179. package/src/nile-dropdown/nile-dropdown.ts +461 -0
  180. package/src/nile-input/nile-input.css.ts +20 -0
  181. package/src/nile-menu/index.ts +1 -116
  182. package/src/nile-menu/nile-menu.css.ts +30 -0
  183. package/src/nile-menu/nile-menu.ts +169 -0
  184. package/src/nile-menu-item/index.ts +1 -0
  185. package/src/nile-menu-item/nile-menu-item.css.ts +123 -0
  186. package/src/nile-menu-item/nile-menu-item.ts +171 -0
  187. package/src/nile-menu/nile-menu.scss +0 -0
@@ -0,0 +1,461 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import {LitElement, html, property, CSSResultArray, TemplateResult} from 'lit-element';
9
+ import { customElement } from 'lit/decorators.js';
10
+ import {styles} from './nile-dropdown.css';
11
+ import { animateTo, stopAnimations } from '../internal/animate';
12
+ import { classMap } from 'lit/directives/class-map.js';
13
+ import { query } from 'lit/decorators.js';
14
+ import { getAnimation, setDefaultAnimation } from '../utilities/animation-registry';
15
+ import { getTabbableBoundary } from '../internal/tabbable';
16
+ import { waitForEvent } from '../internal/event';
17
+ import { watch } from '../internal/watch';
18
+ import NileElement from '../internal/nile-element';
19
+ import type { CSSResultGroup } from 'lit';
20
+ import type NileButton from '../nile-button/nile-button';
21
+ import type NileIconButton from '../nile-icon-button/nile-icon-button';
22
+ import type { NileMenu } from '../nile-menu';
23
+ import type { NilePopup } from '../nile-popup';
24
+ import '../nile-popup';
25
+
26
+ /**
27
+ * Nile icon component.
28
+ *
29
+ * @tag nile-dropdown
30
+ * @summary Dropdowns expose additional content that "drops down" in a panel.
31
+ * @dependency nile-popup
32
+ *
33
+ * @slot - The dropdown's main content.
34
+ * @slot trigger - The dropdown's trigger, usually a `<nile-button>` element.
35
+ *
36
+ * @event nile-show - Emitted when the dropdown opens.
37
+ * @event nile-after-show - Emitted after the dropdown opens and all animations are complete.
38
+ * @event nile-hide - Emitted when the dropdown closes.
39
+ * @event nile-after-hide - Emitted after the dropdown closes and all animations are complete.
40
+ *
41
+ * @csspart base - The component's base wrapper.
42
+ * @csspart trigger - The container that wraps the trigger.
43
+ * @csspart panel - The panel that gets shown when the dropdown is open.
44
+ *
45
+ * @animation dropdown.show - The animation to use when showing the dropdown.
46
+ * @animation dropdown.hide - The animation to use when hiding the dropdown.
47
+ */
48
+ @customElement('nile-dropdown')
49
+ export class NileDropdown extends NileElement {
50
+ static styles: CSSResultGroup = styles;
51
+
52
+ @query('.dropdown') popup: NilePopup;
53
+ @query('.dropdown__trigger') trigger: HTMLSlotElement;
54
+ @query('.dropdown__panel') panel: HTMLSlotElement;
55
+
56
+
57
+ /**
58
+ * Indicates whether or not the dropdown is open. You can toggle this attribute to show and hide the dropdown, or you
59
+ * can use the `show()` and `hide()` methods and this attribute will reflect the dropdown's open state.
60
+ */
61
+ @property({ type: Boolean, reflect: true }) open = false;
62
+
63
+ /**
64
+ * The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel
65
+ * inside of the viewport.
66
+ */
67
+ @property({ reflect: true }) placement:
68
+ | 'top'
69
+ | 'top-start'
70
+ | 'top-end'
71
+ | 'bottom'
72
+ | 'bottom-start'
73
+ | 'bottom-end'
74
+ | 'right'
75
+ | 'right-start'
76
+ | 'right-end'
77
+ | 'left'
78
+ | 'left-start'
79
+ | 'left-end' = 'bottom-start';
80
+
81
+ /** Disables the dropdown so the panel will not open. */
82
+ @property({ type: Boolean, reflect: true }) disabled = false;
83
+
84
+ /**
85
+ * By default, the dropdown is closed when an item is selected. This attribute will keep it open instead. Useful for
86
+ * dropdowns that allow for multiple interactions.
87
+ */
88
+ @property({ attribute: 'stay-open-on-select', type: Boolean, reflect: true }) stayOpenOnSelect = false;
89
+
90
+ /**
91
+ * The dropdown will close when the user interacts outside of this element (e.g. clicking). Useful for composing other
92
+ * components that use a dropdown internally.
93
+ */
94
+ @property({ attribute: false }) containingElement?: HTMLElement;
95
+
96
+ /** The distance in pixels from which to offset the panel away from its trigger. */
97
+ @property({ type: Number }) distance = 0;
98
+
99
+
100
+ @property({ type: Boolean }) noOpenOnClick = false;
101
+
102
+ /** The distance in pixels from which to offset the panel along its trigger. */
103
+ @property({ type: Number }) skidding = 0;
104
+
105
+ /**
106
+ * Enable this option to prevent the panel from being clipped when the component is placed inside a container with
107
+ * `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios.
108
+ */
109
+ @property({ type: Boolean }) hoist = false;
110
+
111
+ connectedCallback() {
112
+ super.connectedCallback();
113
+ this.handlePanelSelect = this.handlePanelSelect.bind(this);
114
+ this.handleKeyDown = this.handleKeyDown.bind(this);
115
+ this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);
116
+ this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
117
+
118
+ if (!this.containingElement) {
119
+ this.containingElement = this;
120
+ }
121
+ }
122
+
123
+ firstUpdated() {
124
+ this.panel.hidden = !this.open;
125
+
126
+ // If the dropdown is visible on init, update its position
127
+ if (this.open) {
128
+ this.addOpenListeners();
129
+ this.popup.active = true;
130
+ }
131
+ }
132
+
133
+ disconnectedCallback() {
134
+ super.disconnectedCallback();
135
+ this.removeOpenListeners();
136
+ this.hide();
137
+ }
138
+
139
+ focusOnTrigger() {
140
+ const trigger = this.trigger.assignedElements({ flatten: true })[0] as HTMLElement | undefined;
141
+ if (typeof trigger?.focus === 'function') {
142
+ trigger.focus();
143
+ }
144
+ }
145
+
146
+ getMenu() {
147
+ return this.panel.assignedElements({ flatten: true }).find(el => el.tagName.toLowerCase() === 'nile-menu') as
148
+ | NileMenu
149
+ | undefined;
150
+ }
151
+
152
+ handleKeyDown(event: KeyboardEvent) {
153
+ // Close when escape is pressed inside an open dropdown. We need to listen on the panel itself and stop propagation
154
+ // in case any ancestors are also listening for this key.
155
+ if (this.open && event.key === 'Escape') {
156
+ event.stopPropagation();
157
+ this.hide();
158
+ this.focusOnTrigger();
159
+ }
160
+ }
161
+
162
+ handleDocumentKeyDown(event: KeyboardEvent) {
163
+ // Close when escape or tab is pressed
164
+ if (event.key === 'Escape' && this.open) {
165
+ event.stopPropagation();
166
+ this.focusOnTrigger();
167
+ this.hide();
168
+ return;
169
+ }
170
+
171
+ // Handle tabbing
172
+ if (event.key === 'Tab') {
173
+ // Tabbing within an open menu should close the dropdown and refocus the trigger
174
+ if (this.open && document.activeElement?.tagName.toLowerCase() === 'nile-menu-item') {
175
+ event.preventDefault();
176
+ this.hide();
177
+ this.focusOnTrigger();
178
+ return;
179
+ }
180
+
181
+ // Tabbing outside of the containing element closes the panel
182
+ //
183
+ // If the dropdown is used within a shadow DOM, we need to obtain the activeElement within that shadowRoot,
184
+ // otherwise `document.activeElement` will only return the name of the parent shadow DOM element.
185
+ setTimeout(() => {
186
+ const activeElement =
187
+ this.containingElement?.getRootNode() instanceof ShadowRoot
188
+ ? document.activeElement?.shadowRoot?.activeElement
189
+ : document.activeElement;
190
+
191
+ if (
192
+ !this.containingElement ||
193
+ activeElement?.closest(this.containingElement.tagName.toLowerCase()) !== this.containingElement
194
+ ) {
195
+ this.hide();
196
+ }
197
+ });
198
+ }
199
+ }
200
+
201
+ handleDocumentMouseDown(event: MouseEvent) {
202
+ // Close when clicking outside of the containing element
203
+ const path = event.composedPath();
204
+ if (this.containingElement && !path.includes(this.containingElement)) {
205
+ this.hide();
206
+ }
207
+ }
208
+
209
+ handlePanelSelect(event: any) {
210
+ const target = event.target as HTMLElement;
211
+
212
+ // Hide the dropdown when a menu item is selected
213
+ if (!this.stayOpenOnSelect && target.tagName.toLowerCase() === 'nile-menu') {
214
+ this.hide();
215
+ this.focusOnTrigger();
216
+ }
217
+ }
218
+
219
+ handleTriggerClick() {
220
+ if(this.noOpenOnClick){
221
+ return;
222
+ }
223
+ if (this.open) {
224
+ this.hide();
225
+ } else {
226
+ this.show();
227
+ this.focusOnTrigger();
228
+ }
229
+ }
230
+
231
+ handleTriggerKeyDown(event: KeyboardEvent) {
232
+ // When spacebar/enter is pressed, show the panel but don't focus on the menu. This let's the user press the same
233
+ // key again to hide the menu in case they don't want to make a selection.
234
+ // if (['Enter'].includes(event.key)) {
235
+ // event.preventDefault();
236
+ // this.handleTriggerClick();
237
+ // return;
238
+ // }
239
+
240
+ const menu = this.getMenu();
241
+
242
+ if (menu) {
243
+ const menuItems = menu.getAllItems();
244
+ const firstMenuItem = menuItems[0];
245
+ const lastMenuItem = menuItems[menuItems.length - 1];
246
+
247
+ // When up/down is pressed, we make the assumption that the user is familiar with the menu and plans to make a
248
+ // selection. Rather than toggle the panel, we focus on the menu (if one exists) and activate the first item for
249
+ // faster navigation.
250
+ if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {
251
+ event.preventDefault();
252
+
253
+ // Show the menu if it's not already open
254
+ if (!this.open) {
255
+ this.show();
256
+ }
257
+
258
+ if (menuItems.length > 0) {
259
+ // Focus on the first/last menu item after showing
260
+ this.updateComplete.then(() => {
261
+ if (event.key === 'ArrowDown' || event.key === 'Home') {
262
+ menu.setCurrentItem(firstMenuItem);
263
+ firstMenuItem.focus();
264
+ }
265
+
266
+ if (event.key === 'ArrowUp' || event.key === 'End') {
267
+ menu.setCurrentItem(lastMenuItem);
268
+ lastMenuItem.focus();
269
+ }
270
+ });
271
+ }
272
+ }
273
+ }
274
+ }
275
+
276
+ handleTriggerKeyUp(event: KeyboardEvent) {
277
+ // Prevent space from triggering a click event in Firefox
278
+ if (event.key === ' ') {
279
+ event.preventDefault();
280
+ }
281
+ }
282
+
283
+ handleTriggerSlotChange() {
284
+ this.updateAccessibleTrigger();
285
+ }
286
+
287
+ //
288
+ // Slotted triggers can be arbitrary content, but we need to link them to the dropdown panel with `aria-haspopup` and
289
+ // `aria-expanded`. These must be applied to the "accessible trigger" (the tabbable portion of the trigger element
290
+ // that gets slotted in) so screen readers will understand them. The accessible trigger could be the slotted element,
291
+ // a child of the slotted element, or an element in the slotted element's shadow root.
292
+ //
293
+ // For example, the accessible trigger of an <nile-button> is a <button> located inside its shadow root.
294
+ //
295
+ // To determine this, we assume the first tabbable element in the trigger slot is the "accessible trigger."
296
+ //
297
+ updateAccessibleTrigger() {
298
+ const assignedElements = this.trigger.assignedElements({ flatten: true }) as HTMLElement[];
299
+ const accessibleTrigger = assignedElements.find(el => getTabbableBoundary(el).start);
300
+ let target: HTMLElement;
301
+
302
+ if (accessibleTrigger) {
303
+ switch (accessibleTrigger.tagName.toLowerCase()) {
304
+ // nile buttons have to update the internal button so it's announced correctly by screen readers
305
+ case 'nile-button':
306
+ case 'nile-icon-button':
307
+ target = (accessibleTrigger as NileButton | NileIconButton).button;
308
+ break;
309
+
310
+ default:
311
+ target = accessibleTrigger;
312
+ }
313
+
314
+ target.setAttribute('aria-haspopup', 'true');
315
+ target.setAttribute('aria-expanded', this.open ? 'true' : 'false');
316
+ }
317
+ }
318
+
319
+ /** Shows the dropdown panel. */
320
+ async show() {
321
+ if (this.open) {
322
+ return undefined;
323
+ }
324
+
325
+ this.open = true;
326
+ return waitForEvent(this, 'nile-after-show');
327
+ }
328
+
329
+ /** Hides the dropdown panel */
330
+ async hide() {
331
+ if (!this.open) {
332
+ return undefined;
333
+ }
334
+
335
+ this.open = false;
336
+ return waitForEvent(this, 'nile-after-hide');
337
+ }
338
+
339
+ /**
340
+ * Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu
341
+ * is activated.
342
+ */
343
+ reposition() {
344
+ this.popup.reposition();
345
+ }
346
+
347
+ addOpenListeners() {
348
+ this.panel.addEventListener('nile-select', this.handlePanelSelect);
349
+ this.panel.addEventListener('keydown', this.handleKeyDown);
350
+ document.addEventListener('keydown', this.handleDocumentKeyDown);
351
+ document.addEventListener('mousedown', this.handleDocumentMouseDown);
352
+ }
353
+
354
+ removeOpenListeners() {
355
+ if (this.panel) {
356
+ this.panel.removeEventListener('nile-select', this.handlePanelSelect);
357
+ this.panel.removeEventListener('keydown', this.handleKeyDown);
358
+ }
359
+ document.removeEventListener('keydown', this.handleDocumentKeyDown);
360
+ document.removeEventListener('mousedown', this.handleDocumentMouseDown);
361
+ }
362
+
363
+ @watch('open', { waitUntilFirstUpdate: true })
364
+ async handleOpenChange() {
365
+ if (this.disabled) {
366
+ this.open = false;
367
+ return;
368
+ }
369
+
370
+ this.updateAccessibleTrigger();
371
+
372
+ if (this.open) {
373
+ // Show
374
+ this.emit('nile-show');
375
+ this.addOpenListeners();
376
+
377
+ await stopAnimations(this);
378
+ this.panel.hidden = false;
379
+ this.popup.active = true;
380
+ const { keyframes, options } = getAnimation(this, 'dropdown.show', { dir: '' });
381
+ await animateTo(this.popup.popup, keyframes, options);
382
+
383
+ this.emit('nile-after-show');
384
+ } else {
385
+ // Hide
386
+ this.emit('nile-hide');
387
+ this.removeOpenListeners();
388
+
389
+ await stopAnimations(this);
390
+ const { keyframes, options } = getAnimation(this, 'dropdown.hide', { dir: '' });
391
+ await animateTo(this.popup.popup, keyframes, options);
392
+ this.panel.hidden = true;
393
+ this.popup.active = false;
394
+
395
+ this.emit('nile-after-hide');
396
+ }
397
+ }
398
+
399
+ render() {
400
+ return html`
401
+ <nile-popup
402
+ part="base"
403
+ id="dropdown"
404
+ placement=${this.placement}
405
+ distance=${this.distance}
406
+ skidding=${this.skidding}
407
+ strategy=${this.hoist ? 'fixed' : 'absolute'}
408
+ flip
409
+ shift
410
+ auto-size="both"
411
+ auto-size-padding="10"
412
+ class=${classMap({
413
+ dropdown: true,
414
+ 'dropdown--open': this.open
415
+ })}
416
+ >
417
+ <slot
418
+ name="trigger"
419
+ slot="anchor"
420
+ part="trigger"
421
+ class="dropdown__trigger"
422
+ @click=${this.handleTriggerClick}
423
+ @keydown=${this.handleTriggerKeyDown}
424
+ @keyup=${this.handleTriggerKeyUp}
425
+ @slotchange=${this.handleTriggerSlotChange}
426
+ ></slot>
427
+
428
+ <slot
429
+ part="panel"
430
+ class="dropdown__panel"
431
+ aria-hidden=${this.open ? 'false' : 'true'}
432
+ aria-labelledby="dropdown"
433
+ ></slot>
434
+ </nile-popup>
435
+ `;
436
+ }
437
+ }
438
+
439
+ setDefaultAnimation('dropdown.show', {
440
+ keyframes: [
441
+ { opacity: 0, scale: 0.9 },
442
+ { opacity: 1, scale: 1 }
443
+ ],
444
+ options: { duration: 100, easing: 'ease' }
445
+ });
446
+
447
+ setDefaultAnimation('dropdown.hide', {
448
+ keyframes: [
449
+ { opacity: 1, scale: 1 },
450
+ { opacity: 0, scale: 0.9 }
451
+ ],
452
+ options: { duration: 100, easing: 'ease' }
453
+ });
454
+
455
+ export default NileDropdown;
456
+
457
+ declare global {
458
+ interface HTMLElementTagNameMap {
459
+ 'nile-dropdown': NileDropdown;
460
+ }
461
+ }
@@ -416,6 +416,26 @@ export const styles = css`
416
416
  .input--no-spin-buttons input[type='number'] {
417
417
  -moz-appearance: textfield;
418
418
  }
419
+
420
+ :host([no-border]) .input--standard {
421
+ border: none; /* Remove borders on all sides */
422
+ box-shadow: 0 0 0 0;
423
+ }
424
+
425
+ :host([no-border]) .input--standard:hover:not(.input--disabled) {
426
+ border: none; /* Remove borders on all sides */
427
+ box-shadow: 0 0 0 0;
428
+ }
429
+
430
+ :host([no-border]) .input--standard.input--focused:not(.input--disabled) {
431
+ border: none; /* Remove borders on all sides */
432
+ box-shadow: 0 0 0 0;
433
+ }
434
+
435
+ :host([no-border]) .input--standard.input--focused:not(.input--disabled) {
436
+ border: none; /* Remove borders on all sides */
437
+ box-shadow: 0 0 0 0;
438
+ }
419
439
  `;
420
440
 
421
441
  export default [styles];
@@ -1,116 +1 @@
1
- import { LitElement, html, css } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
- import { classMap } from 'lit/directives/class-map.js';
4
- /**
5
- * An nile-menu element.
6
- *
7
- * @fires count-changed - Indicates when the count changes
8
- * @slot - This element has a slot
9
- * @csspart button - The button
10
- */
11
- @customElement('nile-menu')
12
- export class NileMenu extends LitElement {
13
- static override styles = css`
14
- :host {
15
- display: block;
16
- width: 100%;
17
- }
18
- .nds-menu {
19
- display: flex;
20
- padding: 6px 6px;
21
- border-radius: 4px;
22
- cursor: pointer;
23
- margin-bottom: 12px;
24
- align-items: center;
25
- text-decoration: none;
26
- }
27
-
28
- .nds-menu:hover {
29
- background: rgba(0, 94, 166, 0.1);
30
- }
31
- .nds-menu__link {
32
- font-family: var(--nile-font-family-sans-serif);
33
- font-style: normal;
34
- font-weight: 400;
35
- font-size: 14px;
36
- line-height: 14px;
37
- letter-spacing: 0.2px;
38
- color: #131415;
39
- text-decoration: none;
40
- margin-left: 12px;
41
- }
42
- .nds-menu--active {
43
- background: rgba(0, 94, 166, 0.1);
44
- }
45
-
46
- .nds-menu__icon {
47
- margin-bottom: 0;
48
- height: 14px;
49
- }
50
-
51
- .nds-menu--short {
52
- width: auto;
53
- /* min-width: 30px; */
54
- }
55
- .nds-menu--short > .nds-menu__link {
56
- display:none;
57
- }
58
- `;
59
-
60
- /**
61
- * Button Lab
62
- */
63
- @property()
64
- name = 'Heading 1';
65
-
66
- /**
67
- * Button Lab
68
- */
69
- @property()
70
- icon: string = "";
71
-
72
- /**
73
- * Button Lab
74
- */
75
- @property()
76
- isActive: boolean = false;
77
-
78
- /**
79
- * Displays shorter version
80
- */
81
- @property()
82
- short: boolean = false;
83
-
84
-
85
- get buttonClassMap() {
86
- return {
87
- 'nds-menu--active': this.isActive,
88
- 'nds-menu--short': this.short
89
- };
90
- }
91
-
92
- /**
93
- * Button Lab
94
- */
95
- @property()
96
- href = "/";
97
-
98
- override render() {
99
- const { name, icon, href } = this;
100
- const hrefPath = `/${href}`;
101
- return html`
102
- <a class="nds-menu ${classMap(this.buttonClassMap)}">
103
- <span class="nds-menu__icon">
104
- <nile-icon name="${this.icon}" size="14" color="#000"></nile-icon>
105
- </span>
106
- <span class="nds-menu__link">${this.name}</span>
107
- </a>
108
- `;
109
- }
110
- }
111
-
112
- declare global {
113
- interface HTMLElementTagNameMap {
114
- 'nile-menu': NileMenu;
115
- }
116
- }
1
+ export { NileMenu } from './nile-menu';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { css } from 'lit-element';
9
+
10
+ /**
11
+ * Menu CSS
12
+ */
13
+ export const styles = css`
14
+ :host {
15
+ display: block;
16
+ position: relative;
17
+ background: hsl(0, 0%, 100%);
18
+ border: solid 1px hsl(240 5.9% 90%);
19
+ border-radius: 0.25rem;
20
+ padding: 0.5rem 0;
21
+ overflow: auto;
22
+ overscroll-behavior: none;
23
+ }
24
+
25
+ ::slotted(nile-divider) {
26
+ --spacing: 0.5rem;
27
+ }
28
+ `;
29
+
30
+ export default [styles];