@aurelia-ui-toolkits/headless 1.0.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 (284) hide show
  1. package/dist/alert/ui-alert.html +19 -0
  2. package/dist/alert/ui-alert.js +67 -0
  3. package/dist/alert/ui-alert.js.map +1 -0
  4. package/dist/alert-service/alert-configuration.js +11 -0
  5. package/dist/alert-service/alert-configuration.js.map +1 -0
  6. package/dist/alert-service/alert-modal/alert-modal.html +12 -0
  7. package/dist/alert-service/alert-modal/alert-modal.js +31 -0
  8. package/dist/alert-service/alert-modal/alert-modal.js.map +1 -0
  9. package/dist/alert-service/alert-modal/i-alert-modal-payload.js +2 -0
  10. package/dist/alert-service/alert-modal/i-alert-modal-payload.js.map +1 -0
  11. package/dist/alert-service/alert-service.js +108 -0
  12. package/dist/alert-service/alert-service.js.map +1 -0
  13. package/dist/alert-service/decorators/confirm-action.js +14 -0
  14. package/dist/alert-service/decorators/confirm-action.js.map +1 -0
  15. package/dist/alert-service/decorators/using-progress.js +23 -0
  16. package/dist/alert-service/decorators/using-progress.js.map +1 -0
  17. package/dist/alert-service/exceptions-tracker.js +4 -0
  18. package/dist/alert-service/exceptions-tracker.js.map +1 -0
  19. package/dist/alert-service/prompt-dialog/prompt-dialog.html +13 -0
  20. package/dist/alert-service/prompt-dialog/prompt-dialog.js +39 -0
  21. package/dist/alert-service/prompt-dialog/prompt-dialog.js.map +1 -0
  22. package/dist/badge/ui-badge.html +6 -0
  23. package/dist/badge/ui-badge.js +44 -0
  24. package/dist/badge/ui-badge.js.map +1 -0
  25. package/dist/base/boolean-attr.js +4 -0
  26. package/dist/base/boolean-attr.js.map +1 -0
  27. package/dist/base/i-validated-element.js +2 -0
  28. package/dist/base/i-validated-element.js.map +1 -0
  29. package/dist/base/keys.js +14 -0
  30. package/dist/base/keys.js.map +1 -0
  31. package/dist/breadcrumbs/ui-breadcrumbs.html +10 -0
  32. package/dist/breadcrumbs/ui-breadcrumbs.js +31 -0
  33. package/dist/breadcrumbs/ui-breadcrumbs.js.map +1 -0
  34. package/dist/button/enhance-ui-button.js +25 -0
  35. package/dist/button/enhance-ui-button.js.map +1 -0
  36. package/dist/button/ui-button.html +20 -0
  37. package/dist/button/ui-button.js +77 -0
  38. package/dist/button/ui-button.js.map +1 -0
  39. package/dist/button/ui-icon-button.html +20 -0
  40. package/dist/button/ui-icon-button.js +77 -0
  41. package/dist/button/ui-icon-button.js.map +1 -0
  42. package/dist/checkbox/ui-checkbox.html +32 -0
  43. package/dist/checkbox/ui-checkbox.js +186 -0
  44. package/dist/checkbox/ui-checkbox.js.map +1 -0
  45. package/dist/chip/ui-chip.html +32 -0
  46. package/dist/chip/ui-chip.js +129 -0
  47. package/dist/chip/ui-chip.js.map +1 -0
  48. package/dist/combobox/enhance-ui-combobox.js +26 -0
  49. package/dist/combobox/enhance-ui-combobox.js.map +1 -0
  50. package/dist/combobox/ui-combobox.html +76 -0
  51. package/dist/combobox/ui-combobox.js +478 -0
  52. package/dist/combobox/ui-combobox.js.map +1 -0
  53. package/dist/disclosure/ui-disclosure.html +28 -0
  54. package/dist/disclosure/ui-disclosure.js +75 -0
  55. package/dist/disclosure/ui-disclosure.js.map +1 -0
  56. package/dist/drawer/ui-drawer.html +35 -0
  57. package/dist/drawer/ui-drawer.js +246 -0
  58. package/dist/drawer/ui-drawer.js.map +1 -0
  59. package/dist/index.js +135 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/input/enhance-ui-input.js +26 -0
  62. package/dist/input/enhance-ui-input.js.map +1 -0
  63. package/dist/input/ui-input.html +56 -0
  64. package/dist/input/ui-input.js +259 -0
  65. package/dist/input/ui-input.js.map +1 -0
  66. package/dist/list/ui-list-item.html +22 -0
  67. package/dist/list/ui-list-item.js +59 -0
  68. package/dist/list/ui-list-item.js.map +1 -0
  69. package/dist/list/ui-list.html +10 -0
  70. package/dist/list/ui-list.js +316 -0
  71. package/dist/list/ui-list.js.map +1 -0
  72. package/dist/menu/ui-menu.html +20 -0
  73. package/dist/menu/ui-menu.js +154 -0
  74. package/dist/menu/ui-menu.js.map +1 -0
  75. package/dist/popup/ui-popup.html +16 -0
  76. package/dist/popup/ui-popup.js +397 -0
  77. package/dist/popup/ui-popup.js.map +1 -0
  78. package/dist/progress/ui-progress.html +17 -0
  79. package/dist/progress/ui-progress.js +76 -0
  80. package/dist/progress/ui-progress.js.map +1 -0
  81. package/dist/radio/ui-radio-group.html +27 -0
  82. package/dist/radio/ui-radio-group.js +259 -0
  83. package/dist/radio/ui-radio-group.js.map +1 -0
  84. package/dist/radio/ui-radio.html +11 -0
  85. package/dist/radio/ui-radio.js +55 -0
  86. package/dist/radio/ui-radio.js.map +1 -0
  87. package/dist/segmented-control/ui-segment.html +10 -0
  88. package/dist/segmented-control/ui-segment.js +44 -0
  89. package/dist/segmented-control/ui-segment.js.map +1 -0
  90. package/dist/segmented-control/ui-segmented-control.html +9 -0
  91. package/dist/segmented-control/ui-segmented-control.js +134 -0
  92. package/dist/segmented-control/ui-segmented-control.js.map +1 -0
  93. package/dist/select/enhance-ui-select.js +26 -0
  94. package/dist/select/enhance-ui-select.js.map +1 -0
  95. package/dist/select/ui-select.html +70 -0
  96. package/dist/select/ui-select.js +323 -0
  97. package/dist/select/ui-select.js.map +1 -0
  98. package/dist/slider/ui-slider.html +69 -0
  99. package/dist/slider/ui-slider.js +362 -0
  100. package/dist/slider/ui-slider.js.map +1 -0
  101. package/dist/splitter/ui-splitter.html +14 -0
  102. package/dist/splitter/ui-splitter.js +257 -0
  103. package/dist/splitter/ui-splitter.js.map +1 -0
  104. package/dist/switch/ui-switch.html +23 -0
  105. package/dist/switch/ui-switch.js +121 -0
  106. package/dist/switch/ui-switch.js.map +1 -0
  107. package/dist/table/enhance-ui-table.js +25 -0
  108. package/dist/table/enhance-ui-table.js.map +1 -0
  109. package/dist/table/ui-table-column.html +17 -0
  110. package/dist/table/ui-table-column.js +127 -0
  111. package/dist/table/ui-table-column.js.map +1 -0
  112. package/dist/table/ui-table.html +56 -0
  113. package/dist/table/ui-table.js +225 -0
  114. package/dist/table/ui-table.js.map +1 -0
  115. package/dist/tabs/ui-tab.html +10 -0
  116. package/dist/tabs/ui-tab.js +52 -0
  117. package/dist/tabs/ui-tab.js.map +1 -0
  118. package/dist/tabs/ui-tabs.html +3 -0
  119. package/dist/tabs/ui-tabs.js +112 -0
  120. package/dist/tabs/ui-tabs.js.map +1 -0
  121. package/dist/toast/ui-toast-region.html +11 -0
  122. package/dist/toast/ui-toast-region.js +38 -0
  123. package/dist/toast/ui-toast-region.js.map +1 -0
  124. package/dist/toast/ui-toast-service.js +70 -0
  125. package/dist/toast/ui-toast-service.js.map +1 -0
  126. package/dist/tooltip/ui-tooltip-service.js +63 -0
  127. package/dist/tooltip/ui-tooltip-service.js.map +1 -0
  128. package/dist/tooltip/ui-tooltip.js +221 -0
  129. package/dist/tooltip/ui-tooltip.js.map +1 -0
  130. package/dist/top-app-bar/ui-top-app-bar.html +24 -0
  131. package/dist/top-app-bar/ui-top-app-bar.js +68 -0
  132. package/dist/top-app-bar/ui-top-app-bar.js.map +1 -0
  133. package/dist/tree/ui-tree.html +38 -0
  134. package/dist/tree/ui-tree.js +340 -0
  135. package/dist/tree/ui-tree.js.map +1 -0
  136. package/dist/types/alert/ui-alert.d.ts +11 -0
  137. package/dist/types/alert-service/alert-configuration.d.ts +8 -0
  138. package/dist/types/alert-service/alert-modal/alert-modal.d.ts +7 -0
  139. package/dist/types/alert-service/alert-modal/i-alert-modal-payload.d.ts +14 -0
  140. package/dist/types/alert-service/alert-service.d.ts +17 -0
  141. package/dist/types/alert-service/decorators/confirm-action.d.ts +3 -0
  142. package/dist/types/alert-service/decorators/using-progress.d.ts +6 -0
  143. package/dist/types/alert-service/exceptions-tracker.d.ts +3 -0
  144. package/dist/types/alert-service/prompt-dialog/prompt-dialog.d.ts +17 -0
  145. package/dist/types/badge/ui-badge.d.ts +7 -0
  146. package/dist/types/base/boolean-attr.d.ts +1 -0
  147. package/dist/types/base/i-validated-element.d.ts +10 -0
  148. package/dist/types/base/keys.d.ts +12 -0
  149. package/dist/types/breadcrumbs/ui-breadcrumbs.d.ts +8 -0
  150. package/dist/types/button/enhance-ui-button.d.ts +3 -0
  151. package/dist/types/button/ui-button.d.ts +16 -0
  152. package/dist/types/button/ui-icon-button.d.ts +18 -0
  153. package/dist/types/checkbox/ui-checkbox.d.ts +32 -0
  154. package/dist/types/chip/ui-chip.d.ts +26 -0
  155. package/dist/types/combobox/enhance-ui-combobox.d.ts +3 -0
  156. package/dist/types/combobox/ui-combobox.d.ts +79 -0
  157. package/dist/types/disclosure/ui-disclosure.d.ts +18 -0
  158. package/dist/types/drawer/ui-drawer.d.ts +38 -0
  159. package/dist/types/index.d.ts +91 -0
  160. package/dist/types/input/enhance-ui-input.d.ts +3 -0
  161. package/dist/types/input/ui-input.d.ts +44 -0
  162. package/dist/types/list/ui-list-item.d.ts +10 -0
  163. package/dist/types/list/ui-list.d.ts +45 -0
  164. package/dist/types/menu/ui-menu.d.ts +29 -0
  165. package/dist/types/popup/ui-popup.d.ts +61 -0
  166. package/dist/types/progress/ui-progress.d.ts +15 -0
  167. package/dist/types/radio/ui-radio-group.d.ts +37 -0
  168. package/dist/types/radio/ui-radio.d.ts +11 -0
  169. package/dist/types/segmented-control/ui-segment.d.ts +8 -0
  170. package/dist/types/segmented-control/ui-segmented-control.d.ts +17 -0
  171. package/dist/types/select/enhance-ui-select.d.ts +3 -0
  172. package/dist/types/select/ui-select.d.ts +50 -0
  173. package/dist/types/slider/ui-slider.d.ts +58 -0
  174. package/dist/types/splitter/ui-splitter.d.ts +39 -0
  175. package/dist/types/switch/ui-switch.d.ts +23 -0
  176. package/dist/types/table/enhance-ui-table.d.ts +3 -0
  177. package/dist/types/table/ui-table-column.d.ts +22 -0
  178. package/dist/types/table/ui-table.d.ts +51 -0
  179. package/dist/types/tabs/ui-tab.d.ts +10 -0
  180. package/dist/types/tabs/ui-tabs.d.ts +16 -0
  181. package/dist/types/toast/ui-toast-region.d.ts +6 -0
  182. package/dist/types/toast/ui-toast-service.d.ts +28 -0
  183. package/dist/types/tooltip/ui-tooltip-service.d.ts +23 -0
  184. package/dist/types/tooltip/ui-tooltip.d.ts +35 -0
  185. package/dist/types/top-app-bar/ui-top-app-bar.d.ts +9 -0
  186. package/dist/types/tree/ui-tree.d.ts +70 -0
  187. package/dist/types/validation/ui-validation-controller-factory.d.ts +7 -0
  188. package/dist/types/validation/ui-validation-result-presenter.d.ts +4 -0
  189. package/dist/types/validation/validate.d.ts +13 -0
  190. package/dist/validation/ui-validation-controller-factory.js +17 -0
  191. package/dist/validation/ui-validation-controller-factory.js.map +1 -0
  192. package/dist/validation/ui-validation-result-presenter.js +23 -0
  193. package/dist/validation/ui-validation-result-presenter.js.map +1 -0
  194. package/dist/validation/validate.js +24 -0
  195. package/dist/validation/validate.js.map +1 -0
  196. package/package.json +50 -0
  197. package/src/alert/ui-alert.html +19 -0
  198. package/src/alert/ui-alert.ts +33 -0
  199. package/src/alert-service/alert-configuration.ts +11 -0
  200. package/src/alert-service/alert-modal/alert-modal.html +12 -0
  201. package/src/alert-service/alert-modal/alert-modal.ts +19 -0
  202. package/src/alert-service/alert-modal/i-alert-modal-payload.ts +14 -0
  203. package/src/alert-service/alert-service.ts +116 -0
  204. package/src/alert-service/decorators/confirm-action.ts +18 -0
  205. package/src/alert-service/decorators/using-progress.ts +32 -0
  206. package/src/alert-service/exceptions-tracker.ts +3 -0
  207. package/src/alert-service/prompt-dialog/prompt-dialog.html +13 -0
  208. package/src/alert-service/prompt-dialog/prompt-dialog.ts +37 -0
  209. package/src/badge/ui-badge.html +6 -0
  210. package/src/badge/ui-badge.ts +17 -0
  211. package/src/base/boolean-attr.ts +3 -0
  212. package/src/base/i-validated-element.ts +11 -0
  213. package/src/base/keys.ts +12 -0
  214. package/src/breadcrumbs/ui-breadcrumbs.html +10 -0
  215. package/src/breadcrumbs/ui-breadcrumbs.ts +14 -0
  216. package/src/button/enhance-ui-button.ts +9 -0
  217. package/src/button/ui-button.html +20 -0
  218. package/src/button/ui-button.ts +60 -0
  219. package/src/button/ui-icon-button.html +20 -0
  220. package/src/button/ui-icon-button.ts +62 -0
  221. package/src/checkbox/ui-checkbox.html +32 -0
  222. package/src/checkbox/ui-checkbox.ts +188 -0
  223. package/src/chip/ui-chip.html +32 -0
  224. package/src/chip/ui-chip.ts +118 -0
  225. package/src/combobox/enhance-ui-combobox.ts +10 -0
  226. package/src/combobox/ui-combobox.html +76 -0
  227. package/src/combobox/ui-combobox.ts +450 -0
  228. package/src/disclosure/ui-disclosure.html +28 -0
  229. package/src/disclosure/ui-disclosure.ts +68 -0
  230. package/src/drawer/ui-drawer.html +35 -0
  231. package/src/drawer/ui-drawer.ts +219 -0
  232. package/src/index.ts +152 -0
  233. package/src/input/enhance-ui-input.ts +10 -0
  234. package/src/input/ui-input.html +56 -0
  235. package/src/input/ui-input.ts +225 -0
  236. package/src/list/ui-list-item.html +22 -0
  237. package/src/list/ui-list-item.ts +25 -0
  238. package/src/list/ui-list.html +10 -0
  239. package/src/list/ui-list.ts +330 -0
  240. package/src/menu/ui-menu.html +20 -0
  241. package/src/menu/ui-menu.ts +103 -0
  242. package/src/popup/ui-popup.html +16 -0
  243. package/src/popup/ui-popup.ts +391 -0
  244. package/src/progress/ui-progress.html +17 -0
  245. package/src/progress/ui-progress.ts +51 -0
  246. package/src/radio/ui-radio-group.html +27 -0
  247. package/src/radio/ui-radio-group.ts +250 -0
  248. package/src/radio/ui-radio.html +11 -0
  249. package/src/radio/ui-radio.ts +35 -0
  250. package/src/resource.d.ts +4 -0
  251. package/src/segmented-control/ui-segment.html +10 -0
  252. package/src/segmented-control/ui-segment.ts +20 -0
  253. package/src/segmented-control/ui-segmented-control.html +9 -0
  254. package/src/segmented-control/ui-segmented-control.ts +119 -0
  255. package/src/select/enhance-ui-select.ts +10 -0
  256. package/src/select/ui-select.html +70 -0
  257. package/src/select/ui-select.ts +294 -0
  258. package/src/slider/ui-slider.html +69 -0
  259. package/src/slider/ui-slider.ts +329 -0
  260. package/src/splitter/ui-splitter.html +14 -0
  261. package/src/splitter/ui-splitter.ts +249 -0
  262. package/src/switch/ui-switch.html +23 -0
  263. package/src/switch/ui-switch.ts +121 -0
  264. package/src/table/enhance-ui-table.ts +9 -0
  265. package/src/table/ui-table-column.html +17 -0
  266. package/src/table/ui-table-column.ts +108 -0
  267. package/src/table/ui-table.html +56 -0
  268. package/src/table/ui-table.ts +209 -0
  269. package/src/tabs/ui-tab.html +10 -0
  270. package/src/tabs/ui-tab.ts +30 -0
  271. package/src/tabs/ui-tabs.html +3 -0
  272. package/src/tabs/ui-tabs.ts +105 -0
  273. package/src/toast/ui-toast-region.html +11 -0
  274. package/src/toast/ui-toast-region.ts +18 -0
  275. package/src/toast/ui-toast-service.ts +100 -0
  276. package/src/tooltip/ui-tooltip-service.ts +84 -0
  277. package/src/tooltip/ui-tooltip.ts +200 -0
  278. package/src/top-app-bar/ui-top-app-bar.html +24 -0
  279. package/src/top-app-bar/ui-top-app-bar.ts +27 -0
  280. package/src/tree/ui-tree.html +38 -0
  281. package/src/tree/ui-tree.ts +363 -0
  282. package/src/validation/ui-validation-controller-factory.ts +20 -0
  283. package/src/validation/ui-validation-result-presenter.ts +26 -0
  284. package/src/validation/validate.ts +35 -0
@@ -0,0 +1,391 @@
1
+ import { bindable, BindingMode, customElement, INode, resolve } from 'aurelia';
2
+ import { booleanAttr } from '../base/boolean-attr';
3
+ import { Keys } from '../base/keys';
4
+ import template from './ui-popup.html?raw';
5
+
6
+ type PopupPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';
7
+
8
+ @customElement({ name: 'ui-popup', template })
9
+ export class UiPopup {
10
+ readonly element = resolve(INode) as HTMLElement;
11
+ readonly slotHost = this;
12
+ private readonly hiddenPanelStyle = 'position: fixed; top: -10000px; left: -10000px; visibility: hidden;';
13
+
14
+ @bindable({ mode: BindingMode.twoWay, set: booleanAttr })
15
+ open: boolean = false;
16
+ openChanged(newValue: boolean): void {
17
+ if (newValue) {
18
+ this.panelStyle = this.hiddenPanelStyle;
19
+ this.startOpenState();
20
+ return;
21
+ }
22
+
23
+ this.stopOpenState();
24
+ }
25
+
26
+ @bindable({ set: booleanAttr })
27
+ closeOnOutside: boolean = true;
28
+
29
+ @bindable({ set: booleanAttr })
30
+ closeOnEscape: boolean = true;
31
+
32
+ @bindable({ set: booleanAttr })
33
+ matchAnchorWidth: boolean = false;
34
+ matchAnchorWidthChanged(): void {
35
+ this.queuePositionUpdate();
36
+ }
37
+
38
+ @bindable({ set: booleanAttr })
39
+ focusOnOpen: boolean = true;
40
+
41
+ @bindable({ set: booleanAttr })
42
+ restoreFocus: boolean = true;
43
+
44
+ @bindable
45
+ anchor: Element | undefined;
46
+ anchorChanged(newValue: Element | undefined, oldValue: Element | undefined): void {
47
+ oldValue?.removeEventListener('pointerdown', this.onAnchorPointerDownCapture, true);
48
+ newValue?.addEventListener('pointerdown', this.onAnchorPointerDownCapture, true);
49
+ this.queuePositionUpdate();
50
+ }
51
+
52
+ @bindable
53
+ tabReference: HTMLElement | undefined;
54
+
55
+ @bindable
56
+ placement: PopupPlacement = 'bottom-start';
57
+ placementChanged(): void {
58
+ this.queuePositionUpdate();
59
+ }
60
+
61
+ @bindable
62
+ offset: number = 8;
63
+ offsetChanged(): void {
64
+ this.queuePositionUpdate();
65
+ }
66
+
67
+ @bindable
68
+ portalTarget: string | Element | null | undefined;
69
+
70
+ @bindable
71
+ portalPosition: InsertPosition = 'beforeend';
72
+
73
+ @bindable
74
+ exposedHost: unknown;
75
+
76
+ @bindable
77
+ panelRole: string = 'dialog';
78
+
79
+ @bindable
80
+ panelId: string | undefined;
81
+
82
+ panelStyle = this.hiddenPanelStyle;
83
+ panelElement: HTMLElement | undefined;
84
+
85
+ get effectiveSlotHost(): unknown {
86
+ return this.exposedHost ?? this.slotHost;
87
+ }
88
+
89
+ attaching(): void {
90
+ this.anchor?.addEventListener('pointerdown', this.onAnchorPointerDownCapture, true);
91
+ if (this.open) {
92
+ this.startOpenState();
93
+ }
94
+ }
95
+
96
+ detaching(): void {
97
+ this.anchor?.removeEventListener('pointerdown', this.onAnchorPointerDownCapture, true);
98
+ this.stopOpenState();
99
+ }
100
+
101
+ private listening = false;
102
+ private anchorRectSnapshot: DOMRect | undefined;
103
+ private previousFocus: HTMLElement | undefined;
104
+ private resizeObserver: ResizeObserver | undefined;
105
+ private observedPanelHeight: number | undefined;
106
+ private observedPanelScrollHeight: number | undefined;
107
+ private mutationObserver: MutationObserver | undefined;
108
+ private currentPlaceTop: boolean | undefined;
109
+ private preservePlacementUpdate = false;
110
+
111
+ private readonly onAnchorPointerDownCapture = (): void => {
112
+ if (!this.anchor) {
113
+ return;
114
+ }
115
+
116
+ this.anchorRectSnapshot = this.anchor.getBoundingClientRect();
117
+ };
118
+
119
+ private readonly onWindowPointerDown = (event: PointerEvent): void => {
120
+ if (!this.open || !this.closeOnOutside) {
121
+ return;
122
+ }
123
+
124
+ const target = event.target as Node | null;
125
+ if (!target) {
126
+ return;
127
+ }
128
+
129
+ if (this.panelElement?.contains(target) || this.anchor?.contains(target)) {
130
+ return;
131
+ }
132
+
133
+ this.requestClose();
134
+ };
135
+
136
+ private readonly onWindowKeyDown = (event: KeyboardEvent): void => {
137
+ if (!this.open) {
138
+ return;
139
+ }
140
+
141
+ if (event.key === Keys.Tab && this.panelElement?.contains(event.target as Node | null)) {
142
+ this.focusNextFromTabReference(event.shiftKey);
143
+ event.preventDefault();
144
+ return;
145
+ }
146
+
147
+ if (!this.closeOnEscape || event.key !== Keys.Escape) {
148
+ return;
149
+ }
150
+
151
+ event.preventDefault();
152
+ this.requestClose();
153
+ };
154
+
155
+ private readonly onWindowLayoutChange = (): void => {
156
+ this.queuePositionUpdate();
157
+ };
158
+
159
+ private startOpenState(): void {
160
+ this.previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : undefined;
161
+ this.setListeners(true);
162
+ this.observePanelSize();
163
+ if (this.focusOnOpen) {
164
+ this.focusPanel();
165
+ }
166
+ }
167
+
168
+ private stopOpenState(): void {
169
+ this.setListeners(false);
170
+ this.resizeObserver?.disconnect();
171
+ this.resizeObserver = undefined;
172
+ this.mutationObserver?.disconnect();
173
+ this.mutationObserver = undefined;
174
+ this.observedPanelHeight = undefined;
175
+ this.observedPanelScrollHeight = undefined;
176
+ this.currentPlaceTop = undefined;
177
+ this.preservePlacementUpdate = false;
178
+ this.anchorRectSnapshot = undefined;
179
+ this.panelStyle = this.hiddenPanelStyle;
180
+ if (this.restoreFocus) {
181
+ this.restorePreviousFocus();
182
+ }
183
+ }
184
+
185
+ private requestClose(): void {
186
+ this.open = false;
187
+ }
188
+
189
+ onListSelect(event: Event): void {
190
+ event.stopPropagation();
191
+ this.element.dispatchEvent(new CustomEvent('list-select', {
192
+ bubbles: true,
193
+ detail: (event as CustomEvent).detail
194
+ }));
195
+ }
196
+
197
+ focus(): void {
198
+ this.focusPanel();
199
+ }
200
+
201
+ contains(target: Node): boolean {
202
+ return !!this.panelElement?.contains(target);
203
+ }
204
+
205
+ private focusPanel(): void {
206
+ const focusTarget = this.panelElement?.querySelector('[tabindex]') as HTMLElement | null;
207
+ (focusTarget ?? this.panelElement)?.focus();
208
+ }
209
+
210
+ private restorePreviousFocus(): void {
211
+ if (!this.previousFocus || !document.contains(this.previousFocus)) {
212
+ this.previousFocus = undefined;
213
+ return;
214
+ }
215
+
216
+ this.previousFocus.focus();
217
+ this.previousFocus = undefined;
218
+ }
219
+
220
+ private focusNextFromTabReference(reverse: boolean): void {
221
+ const reference = this.tabReference ?? this.anchor;
222
+ if (!(reference instanceof HTMLElement)) {
223
+ this.requestClose();
224
+ return;
225
+ }
226
+
227
+ const focusable = this.getFocusableElements();
228
+ const index = focusable.indexOf(reference);
229
+ if (index < 0) {
230
+ this.requestClose();
231
+ return;
232
+ }
233
+
234
+ const target = focusable[index + (reverse ? -1 : 1)];
235
+
236
+ this.element.dispatchEvent(new CustomEvent('popup-tab-away', {
237
+ bubbles: true,
238
+ detail: { reverse }
239
+ }));
240
+ this.requestClose();
241
+ target?.focus();
242
+ }
243
+
244
+ private getFocusableElements(): HTMLElement[] {
245
+ const selector = [
246
+ 'a[href]',
247
+ 'button',
248
+ 'input:not([type="hidden"])',
249
+ 'select',
250
+ 'textarea',
251
+ 'iframe',
252
+ '[tabindex]',
253
+ '[contenteditable="true"]'
254
+ ].join(',');
255
+
256
+ return Array.from(document.querySelectorAll<HTMLElement>(selector))
257
+ .filter((element) => this.isFocusable(element));
258
+ }
259
+
260
+ private isFocusable(element: HTMLElement): boolean {
261
+ if (this.panelElement?.contains(element)) {
262
+ return false;
263
+ }
264
+
265
+ if (element.tabIndex < 0 || element.hasAttribute('disabled') || element.getAttribute('aria-hidden') === 'true') {
266
+ return false;
267
+ }
268
+
269
+ const style = window.getComputedStyle(element);
270
+ return style.display !== 'none' && style.visibility !== 'hidden';
271
+ }
272
+
273
+ private setListeners(listen: boolean): void {
274
+ if (listen === this.listening) {
275
+ return;
276
+ }
277
+
278
+ this.listening = listen;
279
+ if (listen) {
280
+ window.addEventListener('pointerdown', this.onWindowPointerDown, true);
281
+ window.addEventListener('keydown', this.onWindowKeyDown, true);
282
+ window.addEventListener('resize', this.onWindowLayoutChange);
283
+ window.addEventListener('scroll', this.onWindowLayoutChange, true);
284
+ return;
285
+ }
286
+
287
+ window.removeEventListener('pointerdown', this.onWindowPointerDown, true);
288
+ window.removeEventListener('keydown', this.onWindowKeyDown, true);
289
+ window.removeEventListener('resize', this.onWindowLayoutChange);
290
+ window.removeEventListener('scroll', this.onWindowLayoutChange, true);
291
+ }
292
+
293
+ private observePanelSize(): void {
294
+ this.resizeObserver?.disconnect();
295
+ this.resizeObserver = undefined;
296
+ this.mutationObserver?.disconnect();
297
+ this.mutationObserver = undefined;
298
+ this.observedPanelHeight = undefined;
299
+ this.observedPanelScrollHeight = undefined;
300
+
301
+ if (!this.open || !this.panelElement) {
302
+ return;
303
+ }
304
+
305
+ this.resizeObserver = new ResizeObserver(([entry]) => {
306
+ const height = entry.contentRect.height;
307
+ if (this.observedPanelHeight === undefined) {
308
+ this.observedPanelHeight = height;
309
+ if (height > 0) {
310
+ this.queuePositionUpdate();
311
+ }
312
+ return;
313
+ }
314
+
315
+ const preservePlacement = height <= this.observedPanelHeight;
316
+ this.observedPanelHeight = height;
317
+ this.queuePositionUpdate(preservePlacement);
318
+ });
319
+ this.resizeObserver.observe(this.panelElement);
320
+ this.mutationObserver = new MutationObserver(() => this.handlePanelContentChange());
321
+ this.mutationObserver.observe(this.panelElement, { childList: true, subtree: true, characterData: true });
322
+ }
323
+
324
+ private handlePanelContentChange(): void {
325
+ if (!this.open || !this.panelElement) {
326
+ return;
327
+ }
328
+
329
+ const scrollHeight = this.panelElement.scrollHeight;
330
+ if (this.observedPanelScrollHeight === undefined) {
331
+ this.observedPanelScrollHeight = scrollHeight;
332
+ return;
333
+ }
334
+
335
+ const preservePlacement = scrollHeight <= this.observedPanelScrollHeight;
336
+ this.observedPanelScrollHeight = scrollHeight;
337
+ this.queuePositionUpdate(preservePlacement);
338
+ }
339
+
340
+ private queuePositionUpdate(preservePlacement = false): void {
341
+ if (!this.open) {
342
+ return;
343
+ }
344
+
345
+ this.preservePlacementUpdate = this.preservePlacementUpdate || preservePlacement;
346
+ const shouldPreservePlacement = this.preservePlacementUpdate;
347
+ this.preservePlacementUpdate = false;
348
+ this.updatePosition(shouldPreservePlacement);
349
+ }
350
+
351
+ private updatePosition(preservePlacement = false): void {
352
+ if (!this.open || !this.panelElement) {
353
+ return;
354
+ }
355
+
356
+ if (!this.anchor) {
357
+ this.panelStyle = this.hiddenPanelStyle;
358
+ return;
359
+ }
360
+
361
+ const anchorRect = this.anchorRectSnapshot || this.anchor.getBoundingClientRect();
362
+ this.anchorRectSnapshot = undefined;
363
+ const panelRect = this.panelElement.getBoundingClientRect();
364
+ this.observedPanelHeight = panelRect.height;
365
+ this.observedPanelScrollHeight = this.panelElement.scrollHeight;
366
+ const viewportPadding = 8;
367
+ const alignEnd = this.placement.endsWith('end');
368
+ const preferTop = this.placement.startsWith('top');
369
+ const fallbackBottom = anchorRect.bottom + this.offset;
370
+ const availableTop = Math.max(0, anchorRect.top - this.offset - viewportPadding);
371
+ const availableBottom = Math.max(0, window.innerHeight - fallbackBottom - viewportPadding);
372
+ const nextPlaceTop = preferTop
373
+ ? panelRect.height <= availableTop || availableTop >= availableBottom
374
+ : panelRect.height > availableBottom && availableTop > availableBottom;
375
+ const placeTop = preservePlacement && this.currentPlaceTop !== undefined ? this.currentPlaceTop : nextPlaceTop;
376
+ this.currentPlaceTop = placeTop;
377
+ const availableHeight = placeTop ? availableTop : availableBottom;
378
+ const panelHeight = Math.min(panelRect.height, availableHeight);
379
+
380
+ let top = placeTop ? anchorRect.top - this.offset - panelHeight : fallbackBottom;
381
+ top = Math.max(viewportPadding, Math.min(top, window.innerHeight - panelHeight - viewportPadding));
382
+
383
+ let left = alignEnd ? anchorRect.right - panelRect.width : anchorRect.left;
384
+ left = Math.max(viewportPadding, Math.min(left, window.innerWidth - panelRect.width - viewportPadding));
385
+
386
+ const maxWidth = `max-width: calc(100vw - ${viewportPadding * 2}px);`;
387
+ const maxHeight = `max-height: ${availableHeight}px; --ui-popup-available-height: ${availableHeight}px;`;
388
+ const minWidth = this.matchAnchorWidth ? `min-width: min(${anchorRect.width}px, calc(100vw - ${viewportPadding * 2}px));` : '';
389
+ this.panelStyle = `position: fixed; top: ${top}px; left: ${left}px; ${maxWidth} ${maxHeight} ${minWidth}`;
390
+ }
391
+ }
@@ -0,0 +1,17 @@
1
+ <template class="ui-progress"
2
+ role="progressbar"
3
+ aria-label.attr="label || null"
4
+ aria-valuemin="0"
5
+ aria-valuemax.attr="indeterminate ? null : normalizedMax"
6
+ aria-valuenow.attr="indeterminate ? null : normalizedValue"
7
+ aria-valuetext.attr="indeterminate ? 'Loading' : null"
8
+ data-circular.attr="circular ? '' : null"
9
+ data-indeterminate.attr="indeterminate ? '' : null">
10
+ <span class="ui-progress__track" aria-hidden="true" if.bind="!circular">
11
+ <span class="ui-progress__bar" style.bind="barStyle"></span>
12
+ </span>
13
+ <svg class="ui-progress__circle" viewBox="0 0 36 36" aria-hidden="true" if.bind="circular">
14
+ <circle class="ui-progress__circle-track" cx="18" cy="18" r="16" pathLength="100" fill="none"></circle>
15
+ <circle class="ui-progress__circle-bar" cx="18" cy="18" r="16" pathLength="100" fill="none" style.bind="circleStyle"></circle>
16
+ </svg>
17
+ </template>
@@ -0,0 +1,51 @@
1
+ import { bindable, customElement } from 'aurelia';
2
+ import { booleanAttr } from '../base/boolean-attr';
3
+ import template from './ui-progress.html?raw';
4
+
5
+ @customElement({ name: 'ui-progress', template })
6
+ export class UiProgress {
7
+ @bindable
8
+ value: number | undefined;
9
+ valueChanged(): void {
10
+ this.updateState();
11
+ }
12
+
13
+ @bindable
14
+ max: number = 100;
15
+ maxChanged(): void {
16
+ this.updateState();
17
+ }
18
+
19
+ @bindable
20
+ label: string | undefined;
21
+
22
+ @bindable({ set: booleanAttr })
23
+ circular: boolean = false;
24
+
25
+ indeterminate = true;
26
+ normalizedMax = 100;
27
+ normalizedValue = 0;
28
+ barStyle: string | undefined;
29
+ circleStyle: string | undefined;
30
+
31
+ binding(): void {
32
+ this.updateState();
33
+ }
34
+
35
+ private updateState(): void {
36
+ const max = Number(this.max);
37
+ this.normalizedMax = max > 0 ? max : 100;
38
+ this.indeterminate = this.value === undefined || this.value === null || Number.isNaN(Number(this.value));
39
+ if (this.indeterminate) {
40
+ this.normalizedValue = 0;
41
+ this.barStyle = undefined;
42
+ this.circleStyle = undefined;
43
+ return;
44
+ }
45
+
46
+ this.normalizedValue = Math.max(0, Math.min(Number(this.value), this.normalizedMax));
47
+ const percent = this.normalizedValue / this.normalizedMax * 100;
48
+ this.barStyle = `width: ${percent}%`;
49
+ this.circleStyle = `stroke-dasharray: ${percent} 100`;
50
+ }
51
+ }
@@ -0,0 +1,27 @@
1
+ <template class="ui-radio-group"
2
+ data-disabled.attr="disabled ? '' : null"
3
+ data-invalid.attr="invalid || errors.size ? '' : null"
4
+ data-focus.attr="focus ? '' : null">
5
+ <div class="ui-radio-group__label" id.bind="label ? labelId : null" show.bind="label">${label}</div>
6
+
7
+ <div class="ui-radio-group__control"
8
+ role="radiogroup"
9
+ aria-labelledby.bind="label ? labelId : null"
10
+ aria-invalid.bind="invalid || errors.size ? 'true' : 'false'"
11
+ aria-describedby.bind="errors.size ? errorsId : (helperNodes.length ? helperId : null)"
12
+ aria-required.attr="required ? 'true' : null"
13
+ focusin.trigger="onFocusIn()"
14
+ focusout.trigger="onFocusOut()">
15
+ <au-slot></au-slot>
16
+ </div>
17
+
18
+ <div class="ui-radio-group__subscript" show.bind="errors.size || helperText || helperNodes.length">
19
+ <div class="ui-radio-group__helper" id.bind="helperId" show.bind="!errors.size && (helperText || helperNodes.length)">
20
+ <au-slot name="helper">${helperText}</au-slot>
21
+ </div>
22
+
23
+ <div class="ui-radio-group__errors" id.bind="errorsId" show.bind="errors.size">
24
+ <div class="ui-radio-group__error" repeat.for="[error, _] of errors" if.bind="error.message">${error.message}</div>
25
+ </div>
26
+ </div>
27
+ </template>