@nldd/design-system 0.19.0 → 0.20.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 (275) hide show
  1. package/custom-elements.json +317 -49
  2. package/dist/components/actions/button/button.d.ts +5 -5
  3. package/dist/components/actions/button/button.d.ts.map +1 -1
  4. package/dist/components/actions/button/button.js +6 -6
  5. package/dist/components/actions/button/button.js.map +1 -1
  6. package/dist/components/actions/button/button.template.d.ts.map +1 -1
  7. package/dist/components/actions/button/button.template.js +6 -8
  8. package/dist/components/actions/button/button.template.js.map +1 -1
  9. package/dist/components/actions/button-bar/button-bar.d.ts.map +1 -1
  10. package/dist/components/actions/button-bar/button-bar.js +15 -4
  11. package/dist/components/actions/button-bar/button-bar.js.map +1 -1
  12. package/dist/components/actions/button-group/button-group.d.ts.map +1 -1
  13. package/dist/components/actions/button-group/button-group.js +7 -1
  14. package/dist/components/actions/button-group/button-group.js.map +1 -1
  15. package/dist/components/actions/button-group/button-group.styles.js +2 -2
  16. package/dist/components/actions/icon-button/icon-button.d.ts +3 -3
  17. package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
  18. package/dist/components/actions/icon-button/icon-button.js +4 -4
  19. package/dist/components/actions/icon-button/icon-button.js.map +1 -1
  20. package/dist/components/actions/icon-button/icon-button.template.d.ts.map +1 -1
  21. package/dist/components/actions/icon-button/icon-button.template.js +2 -4
  22. package/dist/components/actions/icon-button/icon-button.template.js.map +1 -1
  23. package/dist/components/actions/menu/menu-item.d.ts +6 -1
  24. package/dist/components/actions/menu/menu-item.d.ts.map +1 -1
  25. package/dist/components/actions/menu/menu-item.js +15 -5
  26. package/dist/components/actions/menu/menu-item.js.map +1 -1
  27. package/dist/components/actions/menu/menu.d.ts +31 -8
  28. package/dist/components/actions/menu/menu.d.ts.map +1 -1
  29. package/dist/components/actions/menu/menu.js +107 -31
  30. package/dist/components/actions/menu/menu.js.map +1 -1
  31. package/dist/components/actions/menu/menu.pointer.d.ts +7 -0
  32. package/dist/components/actions/menu/menu.pointer.d.ts.map +1 -1
  33. package/dist/components/actions/menu/menu.pointer.js +17 -0
  34. package/dist/components/actions/menu/menu.pointer.js.map +1 -1
  35. package/dist/components/actions/menu/menu.safe-triangle.d.ts +6 -5
  36. package/dist/components/actions/menu/menu.safe-triangle.d.ts.map +1 -1
  37. package/dist/components/actions/menu/menu.safe-triangle.js +3 -3
  38. package/dist/components/actions/menu/menu.safe-triangle.js.map +1 -1
  39. package/dist/components/actions/menu/menu.styles.d.ts.map +1 -1
  40. package/dist/components/actions/menu/menu.styles.js +6 -0
  41. package/dist/components/actions/menu/menu.styles.js.map +1 -1
  42. package/dist/components/actions/menu/menu.template.d.ts.map +1 -1
  43. package/dist/components/actions/menu/menu.template.js +15 -8
  44. package/dist/components/actions/menu/menu.template.js.map +1 -1
  45. package/dist/components/actions/toolbar/toolbar-title.js +2 -2
  46. package/dist/components/actions/toolbar/toolbar-title.js.map +1 -1
  47. package/dist/components/components.js +645 -297
  48. package/dist/components/content/avatar/avatar.js +1 -1
  49. package/dist/components/content/avatar/avatar.js.map +1 -1
  50. package/dist/components/content/avatar-group/avatar-group.d.ts.map +1 -1
  51. package/dist/components/content/avatar-group/avatar-group.js +2 -1
  52. package/dist/components/content/avatar-group/avatar-group.js.map +1 -1
  53. package/dist/components/content/image/image.js +1 -1
  54. package/dist/components/content/image/image.js.map +1 -1
  55. package/dist/components/content/tag/tag.d.ts +3 -3
  56. package/dist/components/content/tag/tag.js +3 -3
  57. package/dist/components/content/tag/tag.template.js +3 -3
  58. package/dist/components/content/tag/tag.template.js.map +1 -1
  59. package/dist/components/content/title/title.js +1 -1
  60. package/dist/components/content/title/title.js.map +1 -1
  61. package/dist/components/content/token/token.d.ts +6 -4
  62. package/dist/components/content/token/token.d.ts.map +1 -1
  63. package/dist/components/content/token/token.js +6 -4
  64. package/dist/components/content/token/token.js.map +1 -1
  65. package/dist/components/content/token/token.template.js +1 -1
  66. package/dist/components/content/token/token.template.js.map +1 -1
  67. package/dist/components/{reflect-non-default-B9wQcnne.js → decorate-DD7uUxHb.js} +16 -1
  68. package/dist/components/{defer-focus-BQ3c4mzj.js → defer-focus-dzorHsCQ.js} +2 -2
  69. package/dist/components/{dev-checks-lQ-gHUjV.js → dev-checks-CLB9G43h.js} +5 -0
  70. package/dist/components/{icon-CrBk3W-t.js → icon-_Eox7ZfO.js} +1 -2
  71. package/dist/components/{icon-button-CfpnGzYQ.js → icon-button-8gvQCwCW.js} +8 -11
  72. package/dist/components/{input-modality-CiPLYYMN.js → input-modality-D_CY185R.js} +8 -2
  73. package/dist/components/inputs/file-field/file-field.js +1 -1
  74. package/dist/components/inputs/file-field/file-field.js.map +1 -1
  75. package/dist/components/inputs/one-time-code-field/one-time-code-field.styles.d.ts.map +1 -1
  76. package/dist/components/inputs/one-time-code-field/one-time-code-field.styles.js +4 -2
  77. package/dist/components/inputs/one-time-code-field/one-time-code-field.styles.js.map +1 -1
  78. package/dist/components/inputs/one-time-code-field/one-time-code-field.template.js +2 -2
  79. package/dist/components/inputs/one-time-code-field/one-time-code-field.template.js.map +1 -1
  80. package/dist/components/inputs/segmented-control/segmented-control.d.ts +2 -2
  81. package/dist/components/inputs/segmented-control/segmented-control.js +4 -4
  82. package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
  83. package/dist/components/inputs/segmented-control/segmented-control.template.js +2 -2
  84. package/dist/components/inputs/segmented-control/segmented-control.template.js.map +1 -1
  85. package/dist/components/inputs/swatch-picker/swatch-picker.js +1 -1
  86. package/dist/components/inputs/swatch-picker/swatch-picker.js.map +1 -1
  87. package/dist/components/inputs/time-picker/time-picker.js +1 -1
  88. package/dist/components/inputs/time-picker/time-picker.js.map +1 -1
  89. package/dist/components/inputs/toggle-button/toggle-button.d.ts +2 -2
  90. package/dist/components/inputs/toggle-button/toggle-button.js +3 -3
  91. package/dist/components/inputs/toggle-button/toggle-button.js.map +1 -1
  92. package/dist/components/inputs/toggle-button/toggle-button.template.d.ts.map +1 -1
  93. package/dist/components/inputs/toggle-button/toggle-button.template.js +7 -10
  94. package/dist/components/inputs/toggle-button/toggle-button.template.js.map +1 -1
  95. package/dist/components/inputs/toggle-button-group/toggle-button-group.js +1 -1
  96. package/dist/components/inputs/toggle-button-group/toggle-button-group.js.map +1 -1
  97. package/dist/components/inputs/toggle-button-group/toggle-button-group.styles.js +3 -3
  98. package/dist/components/layout/card/card.js +1 -1
  99. package/dist/components/layout/card/card.js.map +1 -1
  100. package/dist/components/layout/card/card.styles.d.ts.map +1 -1
  101. package/dist/components/layout/card/card.styles.js +3 -1
  102. package/dist/components/layout/card/card.styles.js.map +1 -1
  103. package/dist/components/layout/kanban/kanban.d.ts.map +1 -1
  104. package/dist/components/layout/kanban/kanban.js +2 -1
  105. package/dist/components/layout/kanban/kanban.js.map +1 -1
  106. package/dist/components/layout/page/page.d.ts.map +1 -1
  107. package/dist/components/layout/page/page.js +3 -2
  108. package/dist/components/layout/page/page.js.map +1 -1
  109. package/dist/components/layout/page/page.styles.d.ts.map +1 -1
  110. package/dist/components/layout/page/page.styles.js +3 -2
  111. package/dist/components/layout/page/page.styles.js.map +1 -1
  112. package/dist/components/layout/page-footer/page-footer.d.ts +5 -2
  113. package/dist/components/layout/page-footer/page-footer.d.ts.map +1 -1
  114. package/dist/components/layout/page-footer/page-footer.js +5 -2
  115. package/dist/components/layout/page-footer/page-footer.js.map +1 -1
  116. package/dist/components/layout/page-footer/page-footer.template.d.ts.map +1 -1
  117. package/dist/components/layout/page-footer/page-footer.template.js +2 -4
  118. package/dist/components/layout/page-footer/page-footer.template.js.map +1 -1
  119. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.d.ts +1 -1
  120. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.d.ts.map +1 -1
  121. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.js +2 -2
  122. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.js.map +1 -1
  123. package/dist/components/layout/page-sections/hero/hero.d.ts.map +1 -1
  124. package/dist/components/layout/page-sections/hero/hero.js +2 -2
  125. package/dist/components/layout/page-sections/hero/hero.js.map +1 -1
  126. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.d.ts +1 -1
  127. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.d.ts.map +1 -1
  128. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.js +2 -2
  129. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.js.map +1 -1
  130. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.d.ts +1 -1
  131. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.d.ts.map +1 -1
  132. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.js +2 -2
  133. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.js.map +1 -1
  134. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.d.ts +1 -1
  135. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.d.ts.map +1 -1
  136. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.js +4 -4
  137. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.js.map +1 -1
  138. package/dist/components/layout/page-sections/simple-section/simple-section.d.ts +1 -1
  139. package/dist/components/layout/page-sections/simple-section/simple-section.d.ts.map +1 -1
  140. package/dist/components/layout/page-sections/simple-section/simple-section.js +2 -2
  141. package/dist/components/layout/page-sections/simple-section/simple-section.js.map +1 -1
  142. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.d.ts +1 -1
  143. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.d.ts.map +1 -1
  144. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.js +2 -2
  145. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.js.map +1 -1
  146. package/dist/components/layout/popover/popover.d.ts +1 -2
  147. package/dist/components/layout/popover/popover.d.ts.map +1 -1
  148. package/dist/components/layout/popover/popover.js +10 -12
  149. package/dist/components/layout/popover/popover.js.map +1 -1
  150. package/dist/components/layout/sheet/sheet.d.ts +1 -0
  151. package/dist/components/layout/sheet/sheet.d.ts.map +1 -1
  152. package/dist/components/layout/sheet/sheet.js +6 -1
  153. package/dist/components/layout/sheet/sheet.js.map +1 -1
  154. package/dist/components/layout/spacer/spacer.js +1 -1
  155. package/dist/components/layout/spacer/spacer.js.map +1 -1
  156. package/dist/components/layout/split-views/bar-split-view/bar-split-view.d.ts.map +1 -1
  157. package/dist/components/layout/split-views/bar-split-view/bar-split-view.js +2 -1
  158. package/dist/components/layout/split-views/bar-split-view/bar-split-view.js.map +1 -1
  159. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.d.ts.map +1 -1
  160. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.js +3 -2
  161. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.js.map +1 -1
  162. package/dist/components/layout/split-views/split-view-pane/split-view-pane.d.ts.map +1 -1
  163. package/dist/components/layout/split-views/split-view-pane/split-view-pane.js +2 -1
  164. package/dist/components/layout/split-views/split-view-pane/split-view-pane.js.map +1 -1
  165. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.d.ts.map +1 -1
  166. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.js +3 -2
  167. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.js.map +1 -1
  168. package/dist/components/layout/window/window.d.ts +1 -0
  169. package/dist/components/layout/window/window.d.ts.map +1 -1
  170. package/dist/components/layout/window/window.js +7 -1
  171. package/dist/components/layout/window/window.js.map +1 -1
  172. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts +5 -2
  173. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts.map +1 -1
  174. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js +7 -4
  175. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js.map +1 -1
  176. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.template.js +3 -3
  177. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.template.js.map +1 -1
  178. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.d.ts.map +1 -1
  179. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.js +2 -1
  180. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.js.map +1 -1
  181. package/dist/components/lists-and-tables/cells/text-cell/text-cell.d.ts +2 -2
  182. package/dist/components/lists-and-tables/cells/text-cell/text-cell.js +2 -2
  183. package/dist/components/lists-and-tables/cells/title-cell/title-cell.d.ts +2 -2
  184. package/dist/components/lists-and-tables/cells/title-cell/title-cell.js +2 -2
  185. package/dist/components/lists-and-tables/list/list.d.ts.map +1 -1
  186. package/dist/components/lists-and-tables/list/list.js +4 -1
  187. package/dist/components/lists-and-tables/list/list.js.map +1 -1
  188. package/dist/components/lists-and-tables/list-item/list-item.d.ts +12 -9
  189. package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
  190. package/dist/components/lists-and-tables/list-item/list-item.js +17 -11
  191. package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
  192. package/dist/components/lists-and-tables/list-item/list-item.styles.d.ts.map +1 -1
  193. package/dist/components/lists-and-tables/list-item/list-item.styles.js +20 -0
  194. package/dist/components/lists-and-tables/list-item/list-item.styles.js.map +1 -1
  195. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.styles.d.ts.map +1 -1
  196. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.styles.js +6 -0
  197. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.styles.js.map +1 -1
  198. package/dist/components/lists-and-tables/table/table.js +5 -5
  199. package/dist/components/lists-and-tables/table/table.js.map +1 -1
  200. package/dist/components/navigation/breadcrumbs/breadcrumbs.d.ts +5 -2
  201. package/dist/components/navigation/breadcrumbs/breadcrumbs.d.ts.map +1 -1
  202. package/dist/components/navigation/breadcrumbs/breadcrumbs.js +5 -2
  203. package/dist/components/navigation/breadcrumbs/breadcrumbs.js.map +1 -1
  204. package/dist/components/navigation/breadcrumbs/breadcrumbs.template.d.ts.map +1 -1
  205. package/dist/components/navigation/breadcrumbs/breadcrumbs.template.js +2 -4
  206. package/dist/components/navigation/breadcrumbs/breadcrumbs.template.js.map +1 -1
  207. package/dist/components/navigation/link/link.d.ts +7 -4
  208. package/dist/components/navigation/link/link.d.ts.map +1 -1
  209. package/dist/components/navigation/link/link.js +7 -4
  210. package/dist/components/navigation/link/link.js.map +1 -1
  211. package/dist/components/navigation/link/link.template.js +5 -5
  212. package/dist/components/navigation/link/link.template.js.map +1 -1
  213. package/dist/components/navigation/menu-bar-item/menu-bar-item.js +1 -1
  214. package/dist/components/navigation/menu-bar-item/menu-bar-item.js.map +1 -1
  215. package/dist/components/navigation/pagination/pagination.d.ts.map +1 -1
  216. package/dist/components/navigation/pagination/pagination.js +3 -2
  217. package/dist/components/navigation/pagination/pagination.js.map +1 -1
  218. package/dist/components/navigation/tab-bar/tab-bar.d.ts +18 -2
  219. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  220. package/dist/components/navigation/tab-bar/tab-bar.js +51 -3
  221. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  222. package/dist/components/navigation/tab-bar/tab-bar.template.d.ts.map +1 -1
  223. package/dist/components/navigation/tab-bar/tab-bar.template.js +5 -3
  224. package/dist/components/navigation/tab-bar/tab-bar.template.js.map +1 -1
  225. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +2 -2
  226. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
  227. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.d.ts +4 -0
  228. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.d.ts.map +1 -1
  229. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.js +26 -2
  230. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.js.map +1 -1
  231. package/dist/components/status-and-feedback/banner/banner.js +1 -1
  232. package/dist/components/status-and-feedback/banner/banner.js.map +1 -1
  233. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js +2 -2
  234. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js.map +1 -1
  235. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js +1 -1
  236. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js.map +1 -1
  237. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js +1 -1
  238. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js.map +1 -1
  239. package/dist/components/status-and-feedback/notification/notification.js +2 -2
  240. package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
  241. package/dist/components/status-and-feedback/progress-bar/progress-bar.js +4 -4
  242. package/dist/components/status-and-feedback/progress-bar/progress-bar.js.map +1 -1
  243. package/dist/components/status-and-feedback/progress-circle/progress-circle.js +4 -4
  244. package/dist/components/status-and-feedback/progress-circle/progress-circle.js.map +1 -1
  245. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts +5 -2
  246. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts.map +1 -1
  247. package/dist/components/status-and-feedback/step-bar/step-bar.js +6 -3
  248. package/dist/components/status-and-feedback/step-bar/step-bar.js.map +1 -1
  249. package/dist/components/status-and-feedback/step-bar/step-bar.template.js +1 -1
  250. package/dist/components/status-and-feedback/step-bar/step-bar.template.js.map +1 -1
  251. package/dist/components/{visibility-mixin-BMtETgjk.js → visibility-mixin-Dzn48SL8.js} +1 -1
  252. package/dist/css/variables.css +6 -0
  253. package/dist/nldd.min.js +823 -767
  254. package/dist/types/vue.d.ts +15 -11
  255. package/dist/utilities/dev-rules.generated.d.ts.map +1 -1
  256. package/dist/utilities/dev-rules.generated.js +5 -0
  257. package/dist/utilities/dev-rules.generated.js.map +1 -1
  258. package/dist/utilities/input-modality.d.ts.map +1 -1
  259. package/dist/utilities/input-modality.js +4 -2
  260. package/dist/utilities/input-modality.js.map +1 -1
  261. package/dist/utilities/page-section-mixin.d.ts +10 -4
  262. package/dist/utilities/page-section-mixin.d.ts.map +1 -1
  263. package/dist/utilities/page-section-mixin.js +29 -23
  264. package/dist/utilities/page-section-mixin.js.map +1 -1
  265. package/dist/utilities/return-focus.d.ts +44 -0
  266. package/dist/utilities/return-focus.d.ts.map +1 -0
  267. package/dist/utilities/return-focus.js +99 -0
  268. package/dist/utilities/return-focus.js.map +1 -0
  269. package/dist/utilities/slot-content.d.ts +30 -0
  270. package/dist/utilities/slot-content.d.ts.map +1 -0
  271. package/dist/utilities/slot-content.js +38 -0
  272. package/dist/utilities/slot-content.js.map +1 -0
  273. package/lint/data.generated.json +1 -1
  274. package/package.json +1 -1
  275. package/dist/components/decorate-C7khEuc7.js +0 -16
@@ -0,0 +1,99 @@
1
+ import { isPointerMode } from './input-modality.js';
2
+ /** The element that really holds focus, inside any shadow roots. */
3
+ export function deepActiveElement() {
4
+ let el = document.activeElement;
5
+ while (el?.shadowRoot?.activeElement)
6
+ el = el.shadowRoot.activeElement;
7
+ return el;
8
+ }
9
+ /**
10
+ * Hands focus back to `target` once `overlay` (a popover, menu, sheet or window)
11
+ * has closed. Call it after the close, with the element that had focus when the
12
+ * overlay opened.
13
+ *
14
+ * - Focus the user moved elsewhere, by a click into a field or Tab out of the
15
+ * overlay, stays there. Only focus still in the overlay, on nothing, or on
16
+ * `target` itself is handed back.
17
+ * - After the keyboard, `target` gets a plain `focus()` and its ring.
18
+ * - After a mouse or a finger, it gets no ring. The browser's own close step
19
+ * has often moved focus back already, and WebKit draws a ring for that
20
+ * script focus. A second `focus()` would be a no-op, so it blurs first and
21
+ * focuses with `focusVisible: false`. Chromium leaves the ring off itself.
22
+ * A text field keeps its ring, as it does on any click.
23
+ */
24
+ export function returnFocus(target, overlay) {
25
+ if (!target || target === document.body || !target.isConnected)
26
+ return;
27
+ // Compared deep: in a shadow root, document.activeElement is the same host
28
+ // for the opener, the overlay and any other field beside them.
29
+ const active = deepActiveElement();
30
+ // On the target or inside it: the anchor fallback is a host, such as an
31
+ // nldd-button, whose inner button the browser may have focused.
32
+ const onTarget = !!active && isWithin(active, target);
33
+ const free = !active || active === document.body || onTarget || isWithin(active, overlay);
34
+ if (!free)
35
+ return;
36
+ if (!isPointerMode()) {
37
+ target.focus();
38
+ return;
39
+ }
40
+ if (active && onTarget) {
41
+ if (!active.matches(':focus-visible') || isTextEntry(active))
42
+ return;
43
+ active.blur();
44
+ }
45
+ // @ts-expect-error lib.dom lacks focusVisible; this fails once it has it.
46
+ const noRing = { focusVisible: false };
47
+ target.focus(noRing);
48
+ }
49
+ /** Whether `node` is `container` or inside it, across shadow roots. */
50
+ function isWithin(node, container) {
51
+ for (let n = node; n; n = n.parentNode ?? (n instanceof ShadowRoot ? n.host : null)) {
52
+ if (n === container)
53
+ return true;
54
+ }
55
+ return false;
56
+ }
57
+ function isTextEntry(el) {
58
+ if (el.isContentEditable || el instanceof HTMLTextAreaElement)
59
+ return true;
60
+ return el instanceof HTMLInputElement
61
+ && !['button', 'checkbox', 'color', 'file', 'image', 'radio', 'range', 'reset', 'submit'].includes(el.type);
62
+ }
63
+ /**
64
+ * Remembers where focus was when an overlay opened, and hands it back when it
65
+ * closes, through `returnFocus`. One per overlay:
66
+ *
67
+ * ```ts
68
+ * private _focusReturn = new FocusReturn();
69
+ * // on open, before the overlay takes focus
70
+ * this._focusReturn.remember(anchor);
71
+ * // once it has closed
72
+ * this._focusReturn.restore(this);
73
+ * ```
74
+ */
75
+ export class FocusReturn {
76
+ constructor() {
77
+ this._target = null;
78
+ this._fallback = null;
79
+ }
80
+ /** Remembers what has focus now, inside any shadow roots, so focus goes
81
+ * back to that element and not to the host it sits in. With nothing
82
+ * focused, as after a click on a button in Safari, it remembers
83
+ * `fallback`: an overlay's anchor, so Tab goes on from there. The
84
+ * fallback also stands in for a remembered element that has left the page
85
+ * by the time the overlay closes, as when a framework renders it anew. */
86
+ remember(fallback) {
87
+ const active = deepActiveElement();
88
+ this._fallback = fallback ?? null;
89
+ this._target = active && active !== document.body ? active : this._fallback;
90
+ }
91
+ /** Hands focus back once `overlay` has closed. */
92
+ restore(overlay) {
93
+ const target = this._target?.isConnected ? this._target : this._fallback;
94
+ this._target = null;
95
+ this._fallback = null;
96
+ returnFocus(target, overlay);
97
+ }
98
+ }
99
+ //# sourceMappingURL=return-focus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"return-focus.js","sourceRoot":"","sources":["../../src/utilities/return-focus.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Whether a slot holds something to show: an element, or text that is more
3
+ * than whitespace.
4
+ *
5
+ * A default slot also gets the whitespace and line breaks between the tags of
6
+ * the markup around it, and that whitespace switches off the slot's fallback
7
+ * content. A component that lets its slot win over an attribute therefore
8
+ * renders the attribute beside the slot, and hides it when this says so.
9
+ */
10
+ export declare function hasSlotContent(slot: HTMLSlotElement): boolean;
11
+ /**
12
+ * Tracks whether a slot holds something, for a component whose slot wins over
13
+ * an attribute. Pass `onChange` to the slot's `@slotchange` and render the
14
+ * attribute only while `has` is false:
15
+ *
16
+ * ```ts
17
+ * private _textSlot = new SlotContent(this);
18
+ * // in the template
19
+ * html`${this._textSlot.has ? nothing : this.text}<slot @slotchange=${this._textSlot.onChange}></slot>`
20
+ * ```
21
+ */
22
+ export declare class SlotContent {
23
+ private readonly _host;
24
+ has: boolean;
25
+ constructor(_host: {
26
+ requestUpdate(): void;
27
+ });
28
+ onChange: (e: Event) => void;
29
+ }
30
+ //# sourceMappingURL=slot-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-content.d.ts","sourceRoot":"","sources":["../../src/utilities/slot-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAG7D;AAED;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;IAGX,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,GAAG,UAAS;gBAEiB,KAAK,EAAE;QAAE,aAAa,IAAI,IAAI,CAAA;KAAE;IAE7D,QAAQ,GAAI,GAAG,KAAK,KAAG,IAAI,CAKzB;CACF"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Whether a slot holds something to show: an element, or text that is more
3
+ * than whitespace.
4
+ *
5
+ * A default slot also gets the whitespace and line breaks between the tags of
6
+ * the markup around it, and that whitespace switches off the slot's fallback
7
+ * content. A component that lets its slot win over an attribute therefore
8
+ * renders the attribute beside the slot, and hides it when this says so.
9
+ */
10
+ export function hasSlotContent(slot) {
11
+ return slot.assignedNodes().some((node) => node.nodeType === Node.ELEMENT_NODE
12
+ || (node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').trim().length > 0));
13
+ }
14
+ /**
15
+ * Tracks whether a slot holds something, for a component whose slot wins over
16
+ * an attribute. Pass `onChange` to the slot's `@slotchange` and render the
17
+ * attribute only while `has` is false:
18
+ *
19
+ * ```ts
20
+ * private _textSlot = new SlotContent(this);
21
+ * // in the template
22
+ * html`${this._textSlot.has ? nothing : this.text}<slot @slotchange=${this._textSlot.onChange}></slot>`
23
+ * ```
24
+ */
25
+ export class SlotContent {
26
+ constructor(_host) {
27
+ this._host = _host;
28
+ this.has = false;
29
+ this.onChange = (e) => {
30
+ const has = hasSlotContent(e.target);
31
+ if (has === this.has)
32
+ return;
33
+ this.has = has;
34
+ this._host.requestUpdate();
35
+ };
36
+ }
37
+ }
38
+ //# sourceMappingURL=slot-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-content.js","sourceRoot":"","sources":["../../src/utilities/slot-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,IAAqB;IACnD,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;WAC1E,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,OAAO,WAAW;IAGvB,YAA6B,KAAgC;QAAhC,UAAK,GAAL,KAAK,CAA2B;QAF7D,QAAG,GAAG,KAAK,CAAC;QAIZ,aAAQ,GAAG,CAAC,CAAQ,EAAQ,EAAE;YAC7B,MAAM,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC,MAAyB,CAAC,CAAC;YACxD,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG;gBAAE,OAAO;YAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC,CAAC;IAP8D,CAAC;CAQjE"}