@uipath/apollo-react 7.35.0 → 7.36.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 (36) hide show
  1. package/dist/canvas/components/BaseNode/BaseNodeContainer.cjs +4 -4
  2. package/dist/canvas/components/BaseNode/BaseNodeContainer.js +4 -4
  3. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  4. package/dist/chat/styles/tailwind.chat.css +1 -1
  5. package/dist/decision-table/DecisionGraphText.cjs +398 -6
  6. package/dist/decision-table/DecisionGraphText.d.ts +15 -5
  7. package/dist/decision-table/DecisionGraphText.d.ts.map +1 -1
  8. package/dist/decision-table/DecisionGraphText.js +399 -7
  9. package/dist/decision-table/DecisionText.cjs +5 -1
  10. package/dist/decision-table/DecisionText.d.ts +3 -3
  11. package/dist/decision-table/DecisionText.d.ts.map +1 -1
  12. package/dist/decision-table/DecisionText.js +5 -1
  13. package/dist/decision-table/__fixtures__/textMode.d.ts +3 -3
  14. package/dist/decision-table/__fixtures__/textMode.d.ts.map +1 -1
  15. package/dist/decision-table/__fixtures__/useStoryHistory.d.ts +7 -0
  16. package/dist/decision-table/__fixtures__/useStoryHistory.d.ts.map +1 -0
  17. package/dist/decision-table/decisionGraphActionTypes.d.ts +8 -0
  18. package/dist/decision-table/decisionGraphActionTypes.d.ts.map +1 -1
  19. package/dist/decision-table/index.cjs +54 -62
  20. package/dist/decision-table/index.d.ts +0 -1
  21. package/dist/decision-table/index.d.ts.map +1 -1
  22. package/dist/decision-table/index.js +1 -2
  23. package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
  24. package/dist/decision-table/useContainerHandlers.cjs +13 -2
  25. package/dist/decision-table/useContainerHandlers.d.ts +6 -1
  26. package/dist/decision-table/useContainerHandlers.d.ts.map +1 -1
  27. package/dist/decision-table/useContainerHandlers.js +14 -3
  28. package/package.json +2 -2
  29. package/dist/decision-table/DecisionGraphView.cjs +0 -435
  30. package/dist/decision-table/DecisionGraphView.d.ts +0 -19
  31. package/dist/decision-table/DecisionGraphView.d.ts.map +0 -1
  32. package/dist/decision-table/DecisionGraphView.js +0 -401
  33. package/dist/decision-table/EditableDecisionGraphText.cjs +0 -40
  34. package/dist/decision-table/EditableDecisionGraphText.d.ts +0 -5
  35. package/dist/decision-table/EditableDecisionGraphText.d.ts.map +0 -1
  36. package/dist/decision-table/EditableDecisionGraphText.js +0 -6
@@ -1,401 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { cn } from "@uipath/apollo-wind";
3
- import { Plus } from "lucide-react";
4
- import { useCallback, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
5
- import { DecisionGraphCard, DecisionGraphReference } from "./DecisionGraphCard.js";
6
- import { DecisionGraphMinimapSlot } from "./DecisionGraphMinimapSlot.js";
7
- import { childPositionsOf, decisionsOf, topPositionsOf, usersOf } from "./decisionGraphPositions.js";
8
- import { GRAPH_ADD_DECISION_CLASS, GRAPH_BRANCH_CLASS, GRAPH_COLUMN_CLASS, GRAPH_EMPTY_CLASS, GRAPH_FRAME_CLASS, GRAPH_MINIMAP_GAP_PX, GRAPH_NEST_CLASS, GRAPH_OUTPUT_HUE_CLASS, GRAPH_SCROLLER_CLASS, graphColumnInsetOf } from "./decisionGraphStyles.js";
9
- import { revealIn } from "./revealIn.js";
10
- import { SENTENCE_MIN_RULE_HEIGHT_PX } from "./sentenceRuleHeights.js";
11
- import { useDecisionGraphActions } from "./useDecisionGraphActions.js";
12
- import { useDecisionGraphLabels } from "./useDecisionGraphStrings.js";
13
- import { useDecisionTextLabels } from "./useDecisionTextStrings.js";
14
- import { useTextAnnouncements } from "./useTextAnnouncements.js";
15
- const NO_EXPANDED = new Set();
16
- const markTargetOf = ({ id, mark })=>mark?.kind === 'rule' ? {
17
- kind: 'rule',
18
- decisionId: id,
19
- rowId: mark.rowId
20
- } : {
21
- kind: 'decision',
22
- decisionId: id
23
- };
24
- const focuses = (mode)=>'navigate' === mode.kind && mode.focus;
25
- const flashes = (mode)=>'inPlace' === mode.kind || mode.flash;
26
- const prefersReducedMotion = ()=>'function' == typeof matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches;
27
- const flash = (element)=>{
28
- if (prefersReducedMotion()) return;
29
- element.animate?.([
30
- {
31
- boxShadow: '0 0 0 4px color-mix(in srgb, var(--color-primary) 40%, transparent)'
32
- },
33
- {
34
- boxShadow: '0 0 0 0 transparent'
35
- }
36
- ], {
37
- duration: 1400,
38
- easing: 'ease-out'
39
- });
40
- };
41
- const NEAR_MARGIN = '100% 0px';
42
- const nearAfter = (current, entries)=>{
43
- let next;
44
- for (const { target, isIntersecting } of entries){
45
- const decisionId = target instanceof HTMLElement ? target.dataset.decisionId : void 0;
46
- if (void 0 !== decisionId && (next ?? current).has(decisionId) !== isIntersecting) {
47
- next ??= new Set(current);
48
- if (isIntersecting) next.add(decisionId);
49
- else next.delete(decisionId);
50
- }
51
- }
52
- return next ?? current;
53
- };
54
- const bodyHeightOf = (card)=>{
55
- const body = card.querySelector(':scope > [data-graph-body]');
56
- if (!body || body.querySelector(':scope > [data-graph-placeholder]')) return null;
57
- return body.offsetHeight || null;
58
- };
59
- const ruleCountsOf = (nodes)=>{
60
- const counts = new Map();
61
- const visit = (node)=>{
62
- if ('decision' !== node.kind) return;
63
- if ('table' === node.logic.kind) counts.set(node.id, node.logic.ruleCount);
64
- for (const child of node.children)visit(child);
65
- };
66
- for (const node of nodes)visit(node);
67
- return counts;
68
- };
69
- const perRuleHeightOf = (heights, ruleCounts)=>{
70
- let height = 0;
71
- let rules = 0;
72
- for (const [decisionId, measured] of heights){
73
- const count = ruleCounts.get(decisionId) ?? 0;
74
- if (0 !== count) {
75
- height += measured;
76
- rules += count;
77
- }
78
- }
79
- return 0 === rules ? SENTENCE_MIN_RULE_HEIGHT_PX : height / rules;
80
- };
81
- const DecisionGraphView = ({ nodes, mode, renderBody, expansion, onFold, selected = null, onReveal, onOpenDecision, rules, dataTestId })=>{
82
- const labels = useDecisionGraphLabels();
83
- const { announce, region } = useTextAnnouncements(useDecisionTextLabels(), dataTestId);
84
- const idPrefix = useId();
85
- const [ownExpanded, setOwnExpanded] = useState(NO_EXPANDED);
86
- const expanded = expansion?.expanded ?? ownExpanded;
87
- const users = useMemo(()=>usersOf(nodes), [
88
- nodes
89
- ]);
90
- const drawn = useMemo(()=>new Set(decisionsOf(nodes).map(({ id })=>id)), [
91
- nodes
92
- ]);
93
- const [scroller, setScroller] = useState(null);
94
- const [launcherEnd, setLauncherEnd] = useState(0);
95
- const cardsRef = useRef(new Map());
96
- const [pending, setPending] = useState(null);
97
- const [near, setNear] = useState(()=>"u" < typeof IntersectionObserver ? null : NO_EXPANDED);
98
- const [revealed, setRevealed] = useState(null);
99
- const [focused, setFocused] = useState(null);
100
- const heightsRef = useRef(new Map());
101
- const observersRef = useRef(null);
102
- const ruleCounts = useMemo(()=>ruleCountsOf(nodes), [
103
- nodes
104
- ]);
105
- const setExpanded = (next)=>{
106
- if (expansion) expansion.onChange(next);
107
- else setOwnExpanded(next);
108
- };
109
- const toggle = (decisionId)=>{
110
- const next = new Set(expanded);
111
- const folds = next.delete(decisionId);
112
- if (!folds) next.add(decisionId);
113
- setExpanded(next);
114
- if (folds) onFold?.(decisionId);
115
- };
116
- const reveal = (target)=>{
117
- if (!expanded.has(target.decisionId)) setExpanded(new Set([
118
- ...expanded,
119
- target.decisionId
120
- ]));
121
- setPending(target);
122
- setRevealed(target.decisionId);
123
- if ('navigate' === target.mode.kind) onReveal?.('rule' === target.kind ? {
124
- kind: 'rule',
125
- decisionId: target.decisionId,
126
- rowId: target.rowId
127
- } : {
128
- kind: 'decision',
129
- decisionId: target.decisionId
130
- });
131
- };
132
- const bodyContext = {
133
- revealDecision: (decisionId, byKey)=>{
134
- if (!drawn.has(decisionId)) return void onOpenDecision?.(decisionId);
135
- reveal({
136
- kind: 'decision',
137
- decisionId,
138
- mode: {
139
- kind: 'navigate',
140
- focus: byKey,
141
- flash: true
142
- }
143
- });
144
- }
145
- };
146
- const openOf = (decisionId)=>onOpenDecision && (()=>onOpenDecision(decisionId));
147
- const actions = useDecisionGraphActions({
148
- mode,
149
- nodes,
150
- labels,
151
- openOf,
152
- cardOf: (decisionId)=>cardsRef.current.get(decisionId),
153
- scroller,
154
- announce,
155
- dataTestId
156
- });
157
- const cardRefsRef = useRef(new Map());
158
- const cardRef = useCallback((decisionId)=>{
159
- const cached = cardRefsRef.current.get(decisionId);
160
- if (cached) return cached;
161
- const attach = (element)=>{
162
- const observers = observersRef.current;
163
- const previous = cardsRef.current.get(decisionId);
164
- if (previous && previous !== element) {
165
- observers?.near.unobserve(previous);
166
- observers?.size?.unobserve(previous);
167
- }
168
- if (!element) return void cardsRef.current.delete(decisionId);
169
- cardsRef.current.set(decisionId, element);
170
- observers?.near.observe(element);
171
- observers?.size?.observe(element);
172
- };
173
- cardRefsRef.current.set(decisionId, attach);
174
- return attach;
175
- }, []);
176
- useLayoutEffect(()=>{
177
- if (!scroller || "u" < typeof IntersectionObserver) return;
178
- const remember = (card)=>{
179
- if (!(card instanceof HTMLElement)) return;
180
- const decisionId = card.dataset.decisionId;
181
- const height = bodyHeightOf(card);
182
- if (void 0 !== decisionId && null !== height) heightsRef.current.set(decisionId, height);
183
- };
184
- const nearObserver = new IntersectionObserver((entries)=>{
185
- for (const { target } of entries)remember(target);
186
- setNear((current)=>nearAfter(current ?? NO_EXPANDED, entries));
187
- }, {
188
- root: scroller,
189
- rootMargin: NEAR_MARGIN
190
- });
191
- const sizeObserver = "u" < typeof ResizeObserver ? null : new ResizeObserver((entries)=>{
192
- for (const { target } of entries)remember(target);
193
- });
194
- observersRef.current = {
195
- near: nearObserver,
196
- size: sizeObserver
197
- };
198
- for (const card of cardsRef.current.values()){
199
- nearObserver.observe(card);
200
- sizeObserver?.observe(card);
201
- }
202
- return ()=>{
203
- nearObserver.disconnect();
204
- sizeObserver?.disconnect();
205
- observersRef.current = null;
206
- };
207
- }, [
208
- scroller
209
- ]);
210
- const perRuleHeight = perRuleHeightOf(heightsRef.current, ruleCounts);
211
- const bodyOf = (decisionId, scrollContainer)=>{
212
- const mounted = null === near || near.has(decisionId) || decisionId === selected || decisionId === revealed || decisionId === focused;
213
- if (mounted) return renderBody(decisionId, {
214
- container: scrollContainer
215
- }, bodyContext);
216
- const height = heightsRef.current.get(decisionId) ?? Math.max(1, ruleCounts.get(decisionId) ?? 1) * perRuleHeight;
217
- return /*#__PURE__*/ jsx("div", {
218
- "aria-hidden": true,
219
- "data-graph-placeholder": true,
220
- style: {
221
- height
222
- }
223
- });
224
- };
225
- const onFocus = (event)=>{
226
- const card = event.target instanceof Element ? event.target.closest('[data-graph-card]') : null;
227
- const decisionId = card instanceof HTMLElement ? card.dataset.decisionId : void 0;
228
- if (void 0 !== decisionId) setFocused(decisionId);
229
- };
230
- useLayoutEffect(()=>{
231
- if (!pending) return;
232
- const apply = ()=>{
233
- const card = cardsRef.current.get(pending.decisionId);
234
- if (!scroller || !card) return false;
235
- if ('decision' === pending.kind) {
236
- const heading = card.querySelector('[data-graph-toggle]');
237
- if ('navigate' === pending.mode.kind) revealIn(scroller, {
238
- vertical: card,
239
- horizontal: heading ?? card,
240
- block: 'start'
241
- });
242
- if (focuses(pending.mode)) heading?.focus({
243
- preventScroll: true
244
- });
245
- if (flashes(pending.mode)) flash(card);
246
- return true;
247
- }
248
- const rule = card.querySelector(`li[data-row-id="${CSS.escape(pending.rowId)}"]`);
249
- if (!rule) return false;
250
- if ('navigate' === pending.mode.kind) revealIn(scroller, {
251
- vertical: rule,
252
- horizontal: rule,
253
- block: 'center'
254
- });
255
- if (focuses(pending.mode)) {
256
- if (!rule.hasAttribute('tabindex')) rule.tabIndex = -1;
257
- rule.focus({
258
- preventScroll: true
259
- });
260
- }
261
- if (flashes(pending.mode)) flash(rule);
262
- return true;
263
- };
264
- if (apply()) return void setPending(null);
265
- const frame = requestAnimationFrame(()=>{
266
- const card = cardsRef.current.get(pending.decisionId);
267
- if (!apply() && flashes(pending.mode) && card) flash(card);
268
- setPending(null);
269
- });
270
- return ()=>cancelAnimationFrame(frame);
271
- });
272
- const branch = (node, depth, position)=>{
273
- if ('reference' === node.kind) return /*#__PURE__*/ jsx(DecisionGraphReference, {
274
- node: node,
275
- labels: labels,
276
- actions: actions.referenceOf(node, position),
277
- onReveal: ()=>reveal({
278
- kind: 'decision',
279
- decisionId: node.targetId,
280
- mode: {
281
- kind: 'navigate',
282
- focus: false,
283
- flash: false
284
- }
285
- }),
286
- onOpen: openOf(node.targetId),
287
- dataTestId: dataTestId
288
- });
289
- const open = expanded.has(node.id);
290
- return /*#__PURE__*/ jsxs(Fragment, {
291
- children: [
292
- /*#__PURE__*/ jsx(DecisionGraphCard, {
293
- node: node,
294
- depth: depth,
295
- open: open,
296
- active: selected === node.id,
297
- usedBy: (users.get(node.id) ?? []).map((user)=>user.label),
298
- bodyId: `${idPrefix}-${encodeURIComponent(node.id)}`,
299
- body: open && scroller ? bodyOf(node.id, scroller) : null,
300
- labels: labels,
301
- onToggle: ()=>toggle(node.id),
302
- onShowProblem: (byKey)=>reveal({
303
- ...markTargetOf(node),
304
- mode: byKey ? {
305
- kind: 'navigate',
306
- focus: true,
307
- flash: true
308
- } : {
309
- kind: 'inPlace'
310
- }
311
- }),
312
- onOpen: openOf(node.id),
313
- actions: actions.cardOf(node, position),
314
- cardRef: cardRef(node.id),
315
- dataTestId: dataTestId
316
- }),
317
- node.children.length > 0 && /*#__PURE__*/ jsx("div", {
318
- className: GRAPH_NEST_CLASS,
319
- "data-graph-nest-of": node.id,
320
- children: childPositionsOf(node, position).map((childPosition)=>{
321
- const child = node.children[childPosition.index];
322
- return child && /*#__PURE__*/ jsx("div", {
323
- className: GRAPH_BRANCH_CLASS,
324
- children: branch(child, depth + 1, childPosition)
325
- }, child.id);
326
- })
327
- })
328
- ]
329
- });
330
- };
331
- return /*#__PURE__*/ jsxs("div", {
332
- className: cn(GRAPH_FRAME_CLASS, GRAPH_OUTPUT_HUE_CLASS),
333
- "data-testid": dataTestId,
334
- ...actions.focusWithin,
335
- children: [
336
- nodes.length > 0 && /*#__PURE__*/ jsx(DecisionGraphMinimapSlot, {
337
- nodes: nodes,
338
- rules: rules,
339
- selected: selected,
340
- onPick: (target)=>reveal({
341
- ...target,
342
- mode: {
343
- kind: 'navigate',
344
- focus: true,
345
- flash: true
346
- }
347
- }),
348
- onLauncherEnd: setLauncherEnd,
349
- labels: labels,
350
- dataTestId: `${dataTestId}-minimap`
351
- }),
352
- /*#__PURE__*/ jsxs("section", {
353
- ref: setScroller,
354
- "aria-label": labels.graph,
355
- className: GRAPH_SCROLLER_CLASS,
356
- style: {
357
- scrollPaddingInlineStart: launcherEnd + GRAPH_MINIMAP_GAP_PX
358
- },
359
- "data-testid": `${dataTestId}-scroller`,
360
- children: [
361
- 0 === nodes.length && /*#__PURE__*/ jsx("p", {
362
- className: GRAPH_EMPTY_CLASS,
363
- "data-testid": `${dataTestId}-empty`,
364
- children: labels.empty
365
- }),
366
- (nodes.length > 0 || actions.addTop) && /*#__PURE__*/ jsxs("div", {
367
- className: GRAPH_COLUMN_CLASS,
368
- style: {
369
- paddingLeft: graphColumnInsetOf(launcherEnd)
370
- },
371
- onFocus: onFocus,
372
- children: [
373
- topPositionsOf(nodes).map((position)=>{
374
- const node = nodes[position.index];
375
- return node && /*#__PURE__*/ jsx("div", {
376
- children: branch(node, 0, position)
377
- }, node.id);
378
- }),
379
- actions.addTop && /*#__PURE__*/ jsxs("button", {
380
- type: "button",
381
- className: GRAPH_ADD_DECISION_CLASS,
382
- onClick: actions.addTop,
383
- "data-graph-add": true,
384
- "data-testid": `${dataTestId}-add-decision`,
385
- children: [
386
- /*#__PURE__*/ jsx(Plus, {
387
- "aria-hidden": true
388
- }),
389
- labels.addDecision
390
- ]
391
- })
392
- ]
393
- })
394
- ]
395
- }),
396
- actions.dialogs,
397
- region
398
- ]
399
- });
400
- };
401
- export { DecisionGraphView };
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- EditableDecisionGraphText: ()=>EditableDecisionGraphText
28
- });
29
- const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
- const external_DecisionGraphView_cjs_namespaceObject = require("./DecisionGraphView.cjs");
31
- const EditableDecisionGraphText = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecisionGraphView_cjs_namespaceObject.DecisionGraphView, {
32
- ...props
33
- });
34
- exports.EditableDecisionGraphText = __webpack_exports__.EditableDecisionGraphText;
35
- for(var __rspack_i in __webpack_exports__)if (-1 === [
36
- "EditableDecisionGraphText"
37
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
38
- Object.defineProperty(exports, '__esModule', {
39
- value: true
40
- });
@@ -1,5 +0,0 @@
1
- import type React from 'react';
2
- import { type DecisionGraphViewProps } from './DecisionGraphView';
3
- export type EditableDecisionGraphTextProps<Refusal, Logic> = DecisionGraphViewProps<Refusal, Logic>;
4
- export declare const EditableDecisionGraphText: <Refusal, Logic>(props: EditableDecisionGraphTextProps<Refusal, Logic>) => React.ReactElement;
5
- //# sourceMappingURL=EditableDecisionGraphText.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditableDecisionGraphText.d.ts","sourceRoot":"","sources":["../../src/decision-table/EditableDecisionGraphText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAErF,MAAM,MAAM,8BAA8B,CAAC,OAAO,EAAE,KAAK,IAAI,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAGpG,eAAO,MAAM,yBAAyB,GAAI,OAAO,EAAE,KAAK,EACtD,OAAO,8BAA8B,CAAC,OAAO,EAAE,KAAK,CAAC,KACpD,KAAK,CAAC,YAAgD,CAAC"}
@@ -1,6 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { DecisionGraphView } from "./DecisionGraphView.js";
3
- const EditableDecisionGraphText = (props)=>/*#__PURE__*/ jsx(DecisionGraphView, {
4
- ...props
5
- });
6
- export { EditableDecisionGraphText };