@uipath/apollo-react 7.22.0 → 7.23.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.
@@ -21,12 +21,56 @@ const measuredHeights = (current, entries)=>{
21
21
  }
22
22
  return next ?? current;
23
23
  };
24
- const useRuleWindow = (rules, selectedRowId, retainedRowId)=>{
24
+ const isPageScroller = (scroller)=>scroller === scroller.ownerDocument.scrollingElement;
25
+ const scrollAncestorOf = (element, named)=>{
26
+ const scroller = named ?? element.ownerDocument.scrollingElement;
27
+ return scroller instanceof HTMLElement ? {
28
+ scroller
29
+ } : null;
30
+ };
31
+ const scrollportOf = (scroller)=>isPageScroller(scroller) ? scroller.ownerDocument : scroller;
32
+ const pageForwarders = new WeakMap();
33
+ const forwardPageScrolls = (document)=>{
34
+ const forwarder = pageForwarders.get(document) ?? {
35
+ views: 0,
36
+ forward: ()=>document.scrollingElement?.dispatchEvent(new Event('scroll'))
37
+ };
38
+ if (0 === forwarder.views) {
39
+ pageForwarders.set(document, forwarder);
40
+ document.addEventListener('scroll', forwarder.forward, {
41
+ passive: true
42
+ });
43
+ }
44
+ forwarder.views += 1;
45
+ return ()=>{
46
+ forwarder.views -= 1;
47
+ if (forwarder.views > 0) return;
48
+ document.removeEventListener('scroll', forwarder.forward);
49
+ pageForwarders.delete(document);
50
+ };
51
+ };
52
+ const scrollportTopOf = (scroller)=>isPageScroller(scroller) ? 0 : scroller.getBoundingClientRect().top;
53
+ const contentTopIn = (element, scroller)=>element.getBoundingClientRect().top - scrollportTopOf(scroller) - (isPageScroller(scroller) ? 0 : scroller.clientTop) + scroller.scrollTop;
54
+ const NEAREST = {
55
+ block: 'nearest',
56
+ inline: 'nearest'
57
+ };
58
+ const useRuleWindow = (rules, selectedRowId, retainedRowId, scroll = 'self')=>{
59
+ const named = 'self' === scroll ? void 0 : scroll.container ?? null;
25
60
  const listRef = useRef(null);
26
61
  const headerRef = useRef(null);
27
62
  const sectionRef = useRef(null);
28
- const listStart = useCallback(()=>listRef.current?.offsetTop ?? 0, []);
29
- const headerHeight = useCallback(()=>headerRef.current?.offsetHeight ?? 0, []);
63
+ const ancestorRef = useRef(null);
64
+ const scrollerOf = useCallback(()=>ancestorRef.current?.scroller ?? sectionRef.current, []);
65
+ const listStart = useCallback(()=>{
66
+ const list = listRef.current;
67
+ const ancestor = ancestorRef.current;
68
+ if (!list) return 0;
69
+ return ancestor ? contentTopIn(list, ancestor.scroller) : list.offsetTop;
70
+ }, []);
71
+ const headerHeight = useCallback(()=>ancestorRef.current ? 0 : headerRef.current?.offsetHeight ?? 0, []);
72
+ const pendingRevealRef = useRef(null);
73
+ const [listMoves, setListMoves] = useState(0);
30
74
  const [measured, setMeasured] = useState(NO_HEIGHTS);
31
75
  const offsetsPx = useMemo(()=>sentenceRuleOffsets(rules, measured), [
32
76
  rules,
@@ -60,23 +104,92 @@ const useRuleWindow = (rules, selectedRowId, retainedRowId)=>{
60
104
  ]);
61
105
  const attachSection = useCallback((element)=>{
62
106
  sectionRef.current = element;
63
- measureRef(element);
107
+ ancestorRef.current = element && void 0 !== named ? scrollAncestorOf(element, named) : null;
108
+ measureRef(ancestorRef.current?.scroller ?? element);
64
109
  }, [
65
- measureRef
110
+ measureRef,
111
+ named
112
+ ]);
113
+ useLayoutEffect(()=>{
114
+ const ancestor = ancestorRef.current;
115
+ const list = listRef.current;
116
+ if (!ancestor || !list || "u" < typeof IntersectionObserver) return;
117
+ const observer = new IntersectionObserver((entries)=>{
118
+ if (entries.some(({ isIntersecting })=>isIntersecting)) setListMoves((count)=>count + 1);
119
+ }, {
120
+ root: scrollportOf(ancestor.scroller)
121
+ });
122
+ for (const spacer of list.querySelectorAll(':scope > li:not([data-row-id])'))observer.observe(spacer);
123
+ return ()=>observer.disconnect();
124
+ }, [
125
+ mountedRowIds,
126
+ named
127
+ ]);
128
+ useLayoutEffect(()=>{
129
+ const ancestor = ancestorRef.current;
130
+ if (!ancestor) return;
131
+ const events = scrollportOf(ancestor.scroller);
132
+ let last = listStart();
133
+ const check = ()=>{
134
+ const next = listStart();
135
+ if (next === last) return;
136
+ last = next;
137
+ setListMoves((count)=>count + 1);
138
+ };
139
+ const stopForwarding = isPageScroller(ancestor.scroller) ? forwardPageScrolls(ancestor.scroller.ownerDocument) : null;
140
+ events.addEventListener('scroll', check, {
141
+ passive: true
142
+ });
143
+ return ()=>{
144
+ events.removeEventListener('scroll', check);
145
+ stopForwarding?.();
146
+ };
147
+ }, [
148
+ listStart,
149
+ named
150
+ ]);
151
+ useLayoutEffect(()=>{
152
+ if (listMoves > 0) ancestorRef.current?.scroller.dispatchEvent(new Event('scroll'));
153
+ }, [
154
+ listMoves
66
155
  ]);
67
156
  const container = useCallback(()=>sectionRef.current, []);
68
- const scrollRowIntoView = useCallback((rowIndex)=>scrollItemIntoView(sectionRef.current, rowIndex), [
69
- scrollItemIntoView
157
+ const cardOf = useCallback((rowId)=>listRef.current?.querySelector(`:scope > li[data-row-id="${CSS.escape(rowId)}"]`) ?? null, []);
158
+ const scrollRowIntoView = useCallback((rowIndex)=>{
159
+ scrollItemIntoView(scrollerOf(), rowIndex);
160
+ const rowId = ancestorRef.current ? rules[rowIndex]?.rowId : void 0;
161
+ if (void 0 === rowId) return;
162
+ const card = cardOf(rowId);
163
+ pendingRevealRef.current = card ? null : rowId;
164
+ card?.scrollIntoView?.(NEAREST);
165
+ }, [
166
+ scrollItemIntoView,
167
+ scrollerOf,
168
+ rules,
169
+ cardOf
70
170
  ]);
171
+ useLayoutEffect(()=>{
172
+ const pending = pendingRevealRef.current;
173
+ const card = null === pending ? null : cardOf(pending);
174
+ if (!card) return;
175
+ pendingRevealRef.current = null;
176
+ card.scrollIntoView?.(NEAREST);
177
+ });
71
178
  const firstVisibleRow = ()=>{
72
- const top = (sectionRef.current?.scrollTop ?? 0) + headerHeight() - listStart();
179
+ const top = (scrollerOf()?.scrollTop ?? 0) + headerHeight() - listStart();
73
180
  const end = offsetsPx.findIndex((offset)=>offset > top);
74
181
  return end < 0 ? rules.length - 1 : Math.max(0, end - 1);
75
182
  };
76
183
  const scrollStopIntoView = (rowIndex, stop)=>{
184
+ const ancestor = ancestorRef.current;
185
+ const rowHeight = (offsetsPx[rowIndex + 1] ?? 0) - (offsetsPx[rowIndex] ?? 0);
186
+ if (ancestor) {
187
+ if (rowHeight <= (ancestor.scroller.clientHeight || FALLBACK_ROW_VIEWPORT_PX)) scrollRowIntoView(rowIndex);
188
+ stop.scrollIntoView?.(NEAREST);
189
+ return;
190
+ }
77
191
  const section = sectionRef.current;
78
192
  if (!section) return;
79
- const rowHeight = (offsetsPx[rowIndex + 1] ?? 0) - (offsetsPx[rowIndex] ?? 0);
80
193
  if (rowHeight <= (section.clientHeight || FALLBACK_ROW_VIEWPORT_PX) - headerHeight()) scrollRowIntoView(rowIndex);
81
194
  const top = section.getBoundingClientRect().top + headerHeight();
82
195
  const bottom = section.getBoundingClientRect().top + section.clientHeight;
@@ -165,14 +165,18 @@ const useVirtualizedAxis = (itemCount, itemSizePx, retained, options)=>{
165
165
  height: fallbackViewportPx
166
166
  });
167
167
  if ("u" < typeof ResizeObserver) return;
168
- const observer = new ResizeObserver(()=>{
169
- callback({
168
+ const measure = ()=>callback({
170
169
  width: element.clientWidth || fallbackViewportPx,
171
170
  height: element.clientHeight || fallbackViewportPx
172
171
  });
173
- });
172
+ const observer = new ResizeObserver(measure);
174
173
  observer.observe(element);
175
- return ()=>observer.disconnect();
174
+ const page = element === element.ownerDocument.scrollingElement ? element.ownerDocument.defaultView : null;
175
+ page?.addEventListener('resize', measure);
176
+ return ()=>{
177
+ observer.disconnect();
178
+ page?.removeEventListener('resize', measure);
179
+ };
176
180
  },
177
181
  onChange: (instance)=>{
178
182
  const range = instance.range;
@@ -1 +1 @@
1
- {"version":3,"file":"useVirtualizedAxis.d.ts","sourceRoot":"","sources":["../../src/decision-table/useVirtualizedAxis.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,OAAO,CAA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C7B,WAAW,MAAM,EACjB,YAAY,MAAM,EAClB,UAAU,MAAM,GAAG,IAAI,EACvB,SAAS,sBAAsB,KAC9B,eA6SF,CAAC"}
@@ -136,14 +136,18 @@ const useVirtualizedAxis = (itemCount, itemSizePx, retained, options)=>{
136
136
  height: fallbackViewportPx
137
137
  });
138
138
  if ("u" < typeof ResizeObserver) return;
139
- const observer = new ResizeObserver(()=>{
140
- callback({
139
+ const measure = ()=>callback({
141
140
  width: element.clientWidth || fallbackViewportPx,
142
141
  height: element.clientHeight || fallbackViewportPx
143
142
  });
144
- });
143
+ const observer = new ResizeObserver(measure);
145
144
  observer.observe(element);
146
- return ()=>observer.disconnect();
145
+ const page = element === element.ownerDocument.scrollingElement ? element.ownerDocument.defaultView : null;
146
+ page?.addEventListener('resize', measure);
147
+ return ()=>{
148
+ observer.disconnect();
149
+ page?.removeEventListener('resize', measure);
150
+ };
147
151
  },
148
152
  onChange: (instance)=>{
149
153
  const range = instance.range;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/apollo-react",
3
- "version": "7.22.0",
3
+ "version": "7.23.0",
4
4
  "description": "Apollo Design System - React component library with Material UI theming",
5
5
  "repository": {
6
6
  "type": "git",
@@ -251,10 +251,10 @@
251
251
  "use-sync-external-store": "^1.2.0",
252
252
  "zod": "^4.6.6",
253
253
  "zustand": "^5.0.9",
254
- "@uipath/apollo-core": "5.15.2",
255
254
  "@uipath/apollo-ui-icons": "1.2.1",
256
255
  "@uipath/apollo-ui-icons-react": "1.0.0",
257
- "@uipath/apollo-wind": "2.93.0"
256
+ "@uipath/apollo-wind": "2.93.0",
257
+ "@uipath/apollo-core": "5.15.2"
258
258
  },
259
259
  "devDependencies": {
260
260
  "@lingui/cli": "^5.6.1",