@ulu/frontend-vue 0.1.3-beta.1 → 0.1.3-beta.11

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 (58) hide show
  1. package/dist/frontend-vue.css +1 -1
  2. package/dist/frontend-vue.js +3147 -2580
  3. package/dist/types/components/collapsible/UluModal.vue.d.ts.map +1 -1
  4. package/dist/types/components/elements/UluList.vue.d.ts.map +1 -1
  5. package/dist/types/components/elements/UluRule.vue.d.ts +19 -0
  6. package/dist/types/components/elements/UluRule.vue.d.ts.map +1 -0
  7. package/dist/types/components/forms/UluFormRadio.vue.d.ts +4 -4
  8. package/dist/types/components/index.d.ts +12 -0
  9. package/dist/types/components/layout/UluDataGrid.vue.d.ts +16 -1
  10. package/dist/types/components/layout/UluDataGrid.vue.d.ts.map +1 -1
  11. package/dist/types/components/systems/facets/UluFacetsFilterSelects.vue.d.ts +21 -2
  12. package/dist/types/components/systems/facets/UluFacetsFilterSelects.vue.d.ts.map +1 -1
  13. package/dist/types/components/systems/facets/UluFacetsSearch.vue.d.ts.map +1 -1
  14. package/dist/types/components/systems/index.d.ts +4 -0
  15. package/dist/types/components/systems/scroll-anchors/UluScrollAnchors.vue.d.ts +20 -58
  16. package/dist/types/components/systems/scroll-anchors/UluScrollAnchors.vue.d.ts.map +1 -1
  17. package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue.d.ts +24 -0
  18. package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue.d.ts.map +1 -0
  19. package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsNav.vue.d.ts +17 -13
  20. package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsNav.vue.d.ts.map +1 -1
  21. package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsNavAnimated.vue.d.ts +27 -30
  22. package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsNavAnimated.vue.d.ts.map +1 -1
  23. package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsSection.vue.d.ts +27 -45
  24. package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsSection.vue.d.ts.map +1 -1
  25. package/dist/types/components/systems/scroll-anchors/useScrollAnchorSection.d.ts +9 -0
  26. package/dist/types/components/systems/scroll-anchors/useScrollAnchorSection.d.ts.map +1 -0
  27. package/dist/types/components/systems/scroll-anchors/useScrollAnchorSections.d.ts +8 -0
  28. package/dist/types/components/systems/scroll-anchors/useScrollAnchorSections.d.ts.map +1 -0
  29. package/dist/types/components/systems/scroll-anchors/useScrollAnchors.d.ts +14 -0
  30. package/dist/types/components/systems/scroll-anchors/useScrollAnchors.d.ts.map +1 -0
  31. package/dist/types/plugins/popovers/defaults.d.ts.map +1 -1
  32. package/dist/types/plugins/popovers/index.d.ts.map +1 -1
  33. package/lib/components/_index.scss +1 -0
  34. package/lib/components/collapsible/UluModal.vue +9 -10
  35. package/lib/components/elements/UluList.vue +3 -4
  36. package/lib/components/elements/UluRule.vue +49 -0
  37. package/lib/components/forms/UluFormRadio.vue +2 -2
  38. package/lib/components/index.js +12 -0
  39. package/lib/components/layout/UluDataGrid.vue +45 -16
  40. package/lib/components/systems/facets/UluFacetsFilterSelects.vue +34 -7
  41. package/lib/components/systems/facets/UluFacetsSearch.vue +3 -3
  42. package/lib/components/systems/facets/UluFacetsSort.vue +3 -3
  43. package/lib/components/systems/index.js +4 -0
  44. package/lib/components/systems/scroll-anchors/UluScrollAnchors.vue +46 -145
  45. package/lib/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue +36 -0
  46. package/lib/components/systems/scroll-anchors/UluScrollAnchorsNav.vue +18 -16
  47. package/lib/components/systems/scroll-anchors/UluScrollAnchorsNavAnimated.vue +100 -89
  48. package/lib/components/systems/scroll-anchors/UluScrollAnchorsSection.vue +55 -52
  49. package/lib/components/systems/scroll-anchors/_scroll-anchors-nav-animated.scss +66 -0
  50. package/lib/components/systems/scroll-anchors/useScrollAnchorSection.js +56 -0
  51. package/lib/components/systems/scroll-anchors/useScrollAnchorSections.js +15 -0
  52. package/lib/components/systems/scroll-anchors/useScrollAnchors.js +152 -0
  53. package/lib/plugins/popovers/defaults.js +10 -10
  54. package/lib/plugins/popovers/index.js +9 -0
  55. package/package.json +2 -2
  56. package/dist/types/components/systems/scroll-anchors/symbols.d.ts +0 -7
  57. package/dist/types/components/systems/scroll-anchors/symbols.d.ts.map +0 -1
  58. package/lib/components/systems/scroll-anchors/symbols.js +0 -6
@@ -1,16 +1,11 @@
1
- <!--
2
- Version: 0.0.2
3
- Changes:
4
- - 0.0.2 | Added transition initial state/class so the indicator
5
- doesn't transition at first
6
- -->
7
1
  <template>
8
2
  <component
9
- v-if="sections.length"
3
+ v-if="sections && sections.length"
10
4
  :is="element"
11
- class="scroll-anchors__nav scroll-anchors__nav--animated"
5
+ class="scroll-anchors__nav scroll-anchors__nav--animated scroll-anchors-nav-animated"
6
+ :style="{ '--rail-width': `${railWidth}px` }"
12
7
  >
13
- <ul class="scroll-anchors__rail">
8
+ <ul class="scroll-anchors-nav-animated__rail">
14
9
  <li
15
10
  v-for="(item, index) in sections" :key="index"
16
11
  :class="{ 'is-active' : item.active }"
@@ -20,105 +15,121 @@ Changes:
20
15
  :ref="(el) => addLinkRef(index, el)"
21
16
  :href="`#${ item.titleId }`"
22
17
  >
23
- {{ item.title }}
18
+ <slot :item="item" :index="index">
19
+ {{ item.title }}
20
+ </slot>
24
21
  </a>
25
22
  </li>
26
23
  </ul>
27
24
  <div
28
- class="scroll-anchors__indicator"
25
+ class="scroll-anchors-nav-animated__indicator"
29
26
  :class="{
30
- 'scroll-anchors__indicator--can-transition' : indicatorAnimReady
27
+ 'scroll-anchors-nav-animated__indicator--can-transition' : indicatorAnimReady
31
28
  }"
32
29
  ref="indicator"
33
- :style="{
30
+ :style="{
34
31
  opacity: indicatorStyles ? '1' : '0',
35
- transform: `translateY(${ indicatorStyles.y }px)`,
36
- height: `${ indicatorStyles.height }px`,
32
+ transform: `translateY(${ indicatorStyles ? indicatorStyles.y : 0 }px)`,
33
+ height: `${ indicatorStyles ? indicatorStyles.height : 0 }px`,
34
+ width: `${ indicatorStyles ? indicatorStyles.width : 0 }px`
37
35
  }"
38
36
  ></div>
39
37
  </component>
40
38
  </template>
41
39
 
42
- <script>
40
+ <script setup>
41
+ import { ref, computed, watch } from 'vue';
43
42
  import { runAfterFramePaint } from "@ulu/utils/browser/performance.js";
44
- import { SECTIONS } from "./symbols.js";
45
- export default {
46
- name: "ScrollAnchorsNavAnimated",
47
- inject: {
48
- sections: { from: SECTIONS }
43
+ import { useScrollAnchorSections } from './useScrollAnchorSections.js';
44
+
45
+ const props = defineProps({
46
+ /**
47
+ * The HTML element to use for the navigation root
48
+ */
49
+ element: {
50
+ type: String,
51
+ default: "nav"
49
52
  },
50
- props: {
51
- /**
52
- * Element to use for container
53
- */
54
- element: {
55
- type: String,
56
- default: "nav"
57
- },
53
+ /**
54
+ * The width of the navigation rail
55
+ */
56
+ railWidth: {
57
+ type: Number,
58
+ default: 3
58
59
  },
59
- data() {
60
- return {
61
- linkRefs: {},
62
- indicatorAnimReady: false
63
- };
60
+ /**
61
+ * The width of the indicator, defaults to railWidth
62
+ */
63
+ indicatorWidth: {
64
+ type: Number,
65
+ default: null
64
66
  },
65
- computed: {
66
- indicatorStyles() {
67
- const { sections, linkRefs } = this;
68
- const linkCount = Object.keys(linkRefs).length;
69
- // Checking for sections and link refs incase
70
- // we were waiting for the components to mount, etc
71
- if (!sections || !linkCount) {
72
- return false;
73
- }
74
- const activeIndex = sections.findIndex(s => s.active);
75
- if (activeIndex === -1) {
76
- return false;
77
- }
78
- const link = this.linkRefs[activeIndex];
79
- const { offsetTop, offsetHeight } = link;
80
- return {
81
- y: offsetTop,
82
- height: offsetHeight,
83
- initial: this.inidica
84
- };
85
- }
67
+ /**
68
+ * If set, creates a static height, centered indicator
69
+ */
70
+ indicatorHeight: {
71
+ type: Number,
72
+ default: null
86
73
  },
87
- watch: {
88
- indicatorStyles(val) {
89
- if (val && !this.indicatorAnimReady) {
90
- runAfterFramePaint(() => {
91
- this.indicatorAnimReady = true;
92
- });
93
- }
94
- }
74
+ /**
75
+ * Vertical alignment of the indicator relative to the link
76
+ */
77
+ indicatorAlignment: {
78
+ type: String,
79
+ default: 'center' // options: center, top
95
80
  },
96
- methods: {
97
- addLinkRef(index, el) {
98
- this.linkRefs[index] = el;
99
- }
81
+ /**
82
+ * Pixel offset for the indicator's vertical alignment
83
+ */
84
+ indicatorAlignmentOffset: {
85
+ type: Number,
86
+ default: 0
100
87
  }
101
- };
102
- </script>
88
+ });
103
89
 
104
- <style lang="scss">
105
- // User can override these styles
106
- // - Think this is better than props/etc
107
- // - Refactored from props to just plain css to be overridden
108
- .scroll-anchors__rail {
109
- border-left: 3px solid rgb(220, 220, 220);
110
- padding-left: 1rem;
111
- }
112
- .scroll-anchors__indicator {
113
- position: absolute;
114
- top: 0;
115
- left: 0;
116
- width: 3px;
117
- background-color: black;
118
- }
119
- .scroll-anchors__indicator--can-transition {
120
- transition-property: height, transform;
121
- transition-timing-function: ease-in-out;
122
- transition-duration: 250ms;
90
+ const sections = useScrollAnchorSections();
91
+
92
+ const linkRefs = ref({});
93
+ const indicatorAnimReady = ref(false);
94
+ const indicator = ref(null);
95
+
96
+ const indicatorStyles = computed(() => {
97
+ if (!sections || !sections.value || !sections.value.length) {
98
+ return false;
99
+ }
100
+ const activeIndex = sections.value.findIndex(s => s.active);
101
+ if (activeIndex === -1) {
102
+ return false;
103
+ }
104
+ const link = linkRefs.value[activeIndex];
105
+ if (!link) return false; // Link might not be rendered yet
106
+
107
+ const { offsetTop, offsetHeight } = link;
108
+ const isStatic = props.indicatorHeight != null;
109
+ const width = props.indicatorWidth ?? props.railWidth;
110
+ const height = isStatic ? props.indicatorHeight : offsetHeight;
111
+
112
+ let y = offsetTop; // Default to 'top' alignment
113
+ if (props.indicatorAlignment === 'center') {
114
+ y = offsetTop + (offsetHeight / 2) - (height / 2);
115
+ }
116
+
117
+ y += props.indicatorAlignmentOffset;
118
+
119
+ return { y, height, width };
120
+ });
121
+
122
+ watch(indicatorStyles, (val) => {
123
+ if (val && !indicatorAnimReady.value) {
124
+ runAfterFramePaint(() => {
125
+ indicatorAnimReady.value = true;
126
+ });
127
+ }
128
+ });
129
+
130
+ function addLinkRef(index, el) {
131
+ if (el) {
132
+ linkRefs.value[index] = el;
133
+ }
123
134
  }
124
- </style>
135
+ </script>
@@ -1,63 +1,66 @@
1
1
  <template>
2
- <div :class="[wrapperClass, { [activeClass] : activeClass && section?.active }]" ref="element">
2
+ <component
3
+ :is="element"
4
+ :class="[wrapperClass, { [activeClass] : activeClass && isActive }]"
5
+ ref="sectionRef"
6
+ >
3
7
  <component :is="titleElement" :class="titleClass" :id="titleId">
4
- {{ title }}
8
+ <slot name="title">
9
+ {{ title }}
10
+ </slot>
5
11
  </component>
6
12
  <slot :section="section"></slot>
7
- </div>
13
+ </component>
8
14
  </template>
9
15
 
10
- <script>
11
- import { computed } from "vue";
12
- import { urlize } from "@ulu/utils/string.js";
13
- import { REGISTER, UNREGISTER, SECTIONS } from "./symbols.js";
14
- export default {
15
- name: "ScrollAnchorsSection",
16
- props: {
17
- title: String,
18
- titleElement: {
19
- type: String,
20
- default: "h2"
21
- },
22
- titleClass: {
23
- type: String,
24
- default: "h2"
25
- },
26
- anchorId: String,
27
- wrapperClass: {
28
- type: String,
29
- default: "scroll-anchors__section"
30
- },
31
- activeClass: {
32
- type: String,
33
- default: 'is-active'
34
- }
35
- },
36
- inject: {
37
- register: { from: REGISTER },
38
- unregister: { from: UNREGISTER },
39
- sections: { from: SECTIONS, default: () => computed(() => []) }
16
+ <script setup>
17
+ import { useScrollAnchorSection } from "./useScrollAnchorSection";
18
+
19
+ const props = defineProps({
20
+ /**
21
+ * The title of the section, used for navigation and generating a default ID
22
+ */
23
+ title: String,
24
+ /**
25
+ * The HTML element to use for the title
26
+ */
27
+ titleElement: {
28
+ type: String,
29
+ default: "h2"
40
30
  },
41
- data() {
42
- const { anchorId, title } = this;
43
- return {
44
- titleId: anchorId || `sas-title-${ urlize(title) }`
45
- };
31
+ /**
32
+ * The class to apply to the title element
33
+ */
34
+ titleClass: {
35
+ type: String,
36
+ default: "h2"
46
37
  },
47
- computed: {
48
- section() {
49
- return this.sections.find(s => s.instance === this);
50
- }
38
+ /**
39
+ * A custom ID to use for the section anchor, overriding the auto-generated one
40
+ */
41
+ customTitleId: String,
42
+ /**
43
+ * The class to apply to the section's wrapper div
44
+ */
45
+ wrapperClass: {
46
+ type: String,
47
+ default: "scroll-anchors__section"
51
48
  },
52
- mounted() {
53
- if (this.register) {
54
- this.register(this);
55
- }
49
+ /**
50
+ * The class to apply to the wrapper div when the section is active
51
+ */
52
+ activeClass: {
53
+ type: String,
54
+ default: 'is-active'
56
55
  },
57
- unmounted() {
58
- if (this.unregister) {
59
- this.unregister(this);
60
- }
56
+ /**
57
+ * The HTML element to use for the section root
58
+ */
59
+ element: {
60
+ type: String,
61
+ default: 'section'
61
62
  }
62
- };
63
- </script>
63
+ });
64
+
65
+ const { sectionRef, titleId, isActive, section } = useScrollAnchorSection(props);
66
+ </script>
@@ -0,0 +1,66 @@
1
+ ////
2
+ /// @group scroll-anchors-nav-animated
3
+ /// For use with UluScrollAnchorsNavAnimated vue component.
4
+ ////
5
+
6
+ @use "sass:map";
7
+ @use "sass:meta";
8
+
9
+ @use "@ulu/frontend/scss/selector";
10
+ @use "@ulu/frontend/scss/utils";
11
+
12
+ // Used for function fallback
13
+ $-fallbacks: () !default;
14
+
15
+ /// Module Settings
16
+ /// @type Map
17
+ $config: (
18
+ "rail-border-color": #dcdcdc,
19
+ "rail-padding": 1rem,
20
+ "indicator-color": #000,
21
+ "indicator-clip-path": null,
22
+ "transition-duration": 250ms,
23
+ "transition-timing-function": ease-in-out
24
+ ) !default;
25
+
26
+ /// Change modules $config
27
+ /// @param {Map} $changes Map of changes
28
+ @mixin set($changes) {
29
+ $config: map.merge($config, $changes) !global;
30
+ }
31
+
32
+ /// Get a config option
33
+ /// @param {Map} $name Name of property
34
+ @function get($name) {
35
+ $value: utils.require-map-get($config, $name, "scroll-anchors-nav-animated [config]");
36
+ @return utils.function-fallback($name, $value, $-fallbacks);
37
+ }
38
+
39
+ /// Prints component styles
40
+ /// @demo scroll-anchors-nav-animated
41
+ /// @example scss
42
+ /// @include ulu.component-scroll-anchors-nav-animated-styles();
43
+
44
+ @mixin styles {
45
+ $prefix: selector.class("scroll-anchors-nav-animated");
46
+
47
+ #{ $prefix } {
48
+ position: relative;
49
+ }
50
+ #{ $prefix }__rail {
51
+ border-left: var(--rail-width, 3px) solid get("rail-border-color");
52
+ padding-left: get("rail-padding");
53
+ }
54
+ #{ $prefix }__indicator {
55
+ position: absolute;
56
+ top: 0;
57
+ left: 0;
58
+ background-color: get("indicator-color");
59
+ clip-path: get("indicator-clip-path");
60
+ }
61
+ #{ $prefix }__indicator--can-transition {
62
+ transition-property: height, transform, width;
63
+ transition-timing-function: get("transition-timing-function");
64
+ transition-duration: get("transition-duration");
65
+ }
66
+ }
@@ -0,0 +1,56 @@
1
+ import { ref, onMounted, onUnmounted, inject, computed, reactive, watch } from 'vue';
2
+ import { urlize } from '@ulu/utils/string.js';
3
+
4
+ /**
5
+ * Composable for a component that acts as a section within the Scroll Anchors system.
6
+ * It handles registering the section with the parent `UluScrollAnchors` component,
7
+ * manages its active state, and provides reactive properties for use in the template.
8
+ * @param {object} props The component props, requires `title` and optional `customTitleId`.
9
+ * @returns {object} An object with reactive properties for the section: `sectionRef` (the ref to bind), `titleId`, `isActive`, and the raw `section` object.
10
+ */
11
+ export function useScrollAnchorSection(props) {
12
+ const sectionRef = ref(null); // for the user to bind to their root element
13
+
14
+ const register = inject('uluScrollAnchorsRegister');
15
+ const unregister = inject('uluScrollAnchorsUnregister');
16
+ const newId = title => `ulu-sa-${ urlize(title) }`;
17
+
18
+ const titleId = computed(() => props.customTitleId || newId(props.title));
19
+
20
+ const section = reactive({
21
+ id: Symbol('section-id'),
22
+ title: props.title,
23
+ titleId: titleId.value,
24
+ element: null, // will be set on mount
25
+ active: false
26
+ });
27
+
28
+ // Keep title and titleId in sync with props
29
+ watch(() => props.title, (newTitle) => {
30
+ section.title = newTitle;
31
+ section.titleId = props.customTitleId || newId(newTitle);
32
+ });
33
+ watch(() => props.customTitleId, (newTitleId) => {
34
+ section.titleId = newTitleId || newId(props.title);
35
+ });
36
+
37
+ onMounted(() => {
38
+ if (register && sectionRef.value) {
39
+ section.element = sectionRef.value;
40
+ register(section);
41
+ }
42
+ });
43
+
44
+ onUnmounted(() => {
45
+ if (unregister) {
46
+ unregister(section.id);
47
+ }
48
+ });
49
+
50
+ return {
51
+ sectionRef, // the ref for the user to attach
52
+ titleId,
53
+ isActive: computed(() => section.active),
54
+ section
55
+ };
56
+ }
@@ -0,0 +1,15 @@
1
+ import { inject } from 'vue';
2
+
3
+ /**
4
+ * Composable that provides a reactive list of all registered scroll anchor sections.
5
+ * This is the recommended way to access section data for building custom navigation.
6
+ * Must be used within a component that is a descendant of `UluScrollAnchors`.
7
+ * @returns {object} A reactive ref containing an array of section objects.
8
+ */
9
+ export function useScrollAnchorSections() {
10
+ const sections = inject('uluScrollAnchorsSections');
11
+ if (!sections) {
12
+ console.warn('useScrollAnchorSections() must be used within an UluScrollAnchors component provider.');
13
+ }
14
+ return sections;
15
+ }
@@ -0,0 +1,152 @@
1
+ import { onMounted, onUnmounted, nextTick, watch } from "vue";
2
+ import { getScrollParent } from "@ulu/utils/browser/dom.js";
3
+
4
+ /**
5
+ * The main composable that contains the core "engine" for the Scroll Anchors system.
6
+ * It encapsulates the IntersectionObserver logic to track sections and manage their active state.
7
+ * This is intended for advanced use cases where a developer needs to build a custom provider
8
+ * component instead of using the default `UluScrollAnchors`.
9
+ * @param {{sections: object, props: object, emit: Function, componentElRef: object}} options
10
+ */
11
+ export function useScrollAnchors({ sections, props, emit, componentElRef }) {
12
+ let observer = null;
13
+
14
+ function getSectionIndex(el) {
15
+ return sections.value.findIndex(({ element }) => el === element);
16
+ }
17
+
18
+ function removeActive(except = null) {
19
+ sections.value.forEach(s => {
20
+ if (s !== except) {
21
+ s.active = false;
22
+ }
23
+ });
24
+ }
25
+
26
+ function createObserver() {
27
+ let lastScrollY = 0;
28
+ let isInitialObservation = true;
29
+
30
+ const onObserve = (entries) => {
31
+ const { root } = observer;
32
+ const currentScrollY = root ? root.scrollTop : document.documentElement.scrollTop || window.scrollY;
33
+
34
+ if (props.debug) {
35
+ console.group("useScrollAnchors: onObserve");
36
+ console.log("Observer:", observer);
37
+ console.log("Last/Current Y:", `${ lastScrollY }/${ currentScrollY }`);
38
+ console.log("Entries:", entries.map(e => ({ el: e.target, is: e.isIntersecting })));
39
+ }
40
+
41
+ if (isInitialObservation && props.firstItemActive) {
42
+ if (props.debug) console.log("Initial observation, respecting `firstItemActive`.");
43
+ isInitialObservation = false;
44
+ lastScrollY = currentScrollY;
45
+ if (props.debug) console.groupEnd();
46
+ return;
47
+ }
48
+ isInitialObservation = false;
49
+
50
+ const scrollDirection = currentScrollY > lastScrollY ? 'down' : 'up';
51
+ lastScrollY = currentScrollY;
52
+ if (props.debug) console.log(`Scroll direction: ${scrollDirection}`);
53
+
54
+ const intersectingEntries = entries.filter(entry => entry.isIntersecting);
55
+ if (props.debug) console.log("Intersecting entries:", intersectingEntries.map(e => e.target));
56
+
57
+ if (intersectingEntries.length > 0) {
58
+ intersectingEntries.sort((a, b) => getSectionIndex(a.target) - getSectionIndex(b.target));
59
+
60
+ const targetEntry = scrollDirection === 'down'
61
+ ? intersectingEntries[intersectingEntries.length - 1]
62
+ : intersectingEntries[0];
63
+ if (props.debug) console.log("Chosen target entry:", targetEntry.target);
64
+
65
+ const sectionToActivate = sections.value[getSectionIndex(targetEntry.target)];
66
+
67
+ if (sectionToActivate && !sectionToActivate.active) {
68
+ if (props.debug) console.log("Activating section:", sectionToActivate.title);
69
+ nextTick(() => {
70
+ removeActive(sectionToActivate);
71
+ sectionToActivate.active = true;
72
+ emit("section-change", { section: sectionToActivate, sections: sections.value, active: true });
73
+ });
74
+ }
75
+ } else {
76
+ if (props.debug) console.log("No intersecting entries. Checking edge cases.");
77
+ const activeSection = sections.value.find(s => s.active);
78
+ if (activeSection) {
79
+ const entryForActive = entries.find(e => e.target === activeSection.element);
80
+ if (entryForActive && !entryForActive.isIntersecting) {
81
+ const index = getSectionIndex(entryForActive.target);
82
+ const isFirst = index === 0;
83
+ const isLast = index === sections.value.length - 1;
84
+ if ((isFirst && scrollDirection === 'up' && !props.firstItemActive) || (isLast && scrollDirection === 'down')) {
85
+ if (props.debug) console.log("Deactivating section at edge:", activeSection.title);
86
+ nextTick(() => {
87
+ removeActive();
88
+ emit("section-change", { section: activeSection, sections: sections.value, active: false });
89
+ });
90
+ }
91
+ }
92
+ }
93
+ }
94
+ if (props.debug) console.groupEnd();
95
+ };
96
+
97
+ let root = null;
98
+ if (props.observerOptions && props.observerOptions.root) {
99
+ root = props.observerOptions.root;
100
+ } else if (componentElRef.value) {
101
+ root = getScrollParent(componentElRef.value);
102
+ if (root === document.scrollingElement) {
103
+ root = null;
104
+ }
105
+ }
106
+
107
+ const finalObserverOptions = {
108
+ ...props.observerOptions,
109
+ root
110
+ };
111
+
112
+ observer = new IntersectionObserver(onObserve, finalObserverOptions);
113
+ }
114
+
115
+ function observeItems() {
116
+ if (!observer) return;
117
+ observer.disconnect();
118
+ sections.value.forEach(({ element }) => {
119
+ if (element) {
120
+ observer.observe(element);
121
+ }
122
+ });
123
+ }
124
+
125
+ function destroyObserver() {
126
+ if (observer) {
127
+ observer.disconnect();
128
+ observer = null;
129
+ }
130
+ }
131
+
132
+ onMounted(() => {
133
+ if (props.firstItemActive && sections.value.length > 0) {
134
+ const first = sections.value[0];
135
+ if (first) {
136
+ first.active = true;
137
+ }
138
+ }
139
+ createObserver();
140
+ observeItems();
141
+ });
142
+
143
+ onUnmounted(() => {
144
+ destroyObserver();
145
+ });
146
+
147
+ watch(() => sections.value.length, () => {
148
+ nextTick(() => {
149
+ observeItems();
150
+ });
151
+ });
152
+ }
@@ -9,16 +9,7 @@ export default {
9
9
  * @type {String}
10
10
  */
11
11
  directiveName: "ulu-tooltip",
12
- /**
13
- * The element that the tooltip should be rendered within
14
- * - Default bottom of the body (on top of everything)
15
- * - Doesn't need to be inline for accessibility since tooltips are just an enhancement
16
- * content displayed within them should be hidden for assistive devices,
17
- * they are not visible to assistive devices
18
- * @type {String}
19
- */
20
- tooltipTeleportTo: "body",
21
- },
12
+ },
22
13
  /**
23
14
  * Default Popover Options
24
15
  */
@@ -59,6 +50,15 @@ export default {
59
50
  * @type {Object}
60
51
  */
61
52
  tooltip: {
53
+ /**
54
+ * The element that the tooltip should be rendered within
55
+ * - Default bottom of the body if this is unset
56
+ * - Doesn't need to be inline for accessibility since tooltips are just an enhancement
57
+ * content displayed within them should be hidden for assistive devices,
58
+ * they are not visible to assistive devices
59
+ * @type {String}
60
+ */
61
+ teleportTo: null,
62
62
  /**
63
63
  * Optional class binding for tooltip element
64
64
  * @type {String|Object|Array}
@@ -70,6 +70,15 @@ export default function install(app, userOptions = {}) {
70
70
  config: {},
71
71
  });
72
72
  const showTooltip = (triggerEl, configObj) => {
73
+ // If a teleport target isn't already specified in the config,
74
+ // try to find a parent dialog to teleport to automatically.
75
+ if (triggerEl && !configObj.teleportTo) {
76
+ const dialog = triggerEl.closest("dialog");
77
+ if (dialog) {
78
+ configObj.teleportTo = dialog;
79
+ }
80
+ }
81
+
73
82
  // If a tooltip is already active for a different element, remove its attribute.
74
83
  if (tooltipState.trigger && tooltipState.trigger !== triggerEl) {
75
84
  if (tooltipState.trigger?.removeAttribute) {