pixel-react 1.22.5 → 1.22.6
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.
- package/lib/components/AutoTruncateText/AutoTruncateText.js +38 -30
- package/lib/components/AutoTruncateText/AutoTruncateText.js.map +1 -1
- package/lib/components/AutoTruncateText/resizeObserverService.d.ts +10 -2
- package/lib/components/AutoTruncateText/resizeObserverService.js +19 -12
- package/lib/components/AutoTruncateText/resizeObserverService.js.map +1 -1
- package/lib/components/HighlightText/HighlightText.d.ts +2 -2
- package/lib/components/HighlightText/HighlightText.js +144 -13
- package/lib/components/HighlightText/HighlightText.js.map +1 -1
- package/lib/components/HighlightText/index.d.ts +1 -0
- package/lib/components/HighlightText/types.d.ts +46 -0
- package/lib/components/Icon/iconList.js +2 -4
- package/lib/components/Icon/iconList.js.map +1 -1
- package/lib/components/MenuOption/MenuOption.js +22 -31
- package/lib/components/MenuOption/MenuOption.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.js +20 -26
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/components/TooltipService/TooltipService.js +219 -109
- package/lib/components/TooltipService/TooltipService.js.map +1 -1
- package/lib/hooks/useFocusTrap.d.ts +29 -0
- package/lib/hooks/useFocusTrap.js +97 -0
- package/lib/hooks/useFocusTrap.js.map +1 -0
- package/lib/hooks/useInteractiveAncestor.d.ts +7 -0
- package/lib/hooks/useInteractiveAncestor.js +18 -0
- package/lib/hooks/useInteractiveAncestor.js.map +1 -0
- package/lib/index.d.ts +50 -175
- package/lib/index.js +9 -27
- package/lib/index.js.map +1 -1
- package/lib/styles.css +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/a11y/a11y.d.ts +28 -0
- package/lib/utils/a11y/a11y.js +62 -0
- package/lib/utils/a11y/a11y.js.map +1 -0
- package/lib/utils/truncateText/truncateText.js +29 -15
- package/lib/utils/truncateText/truncateText.js.map +1 -1
- package/package.json +119 -129
- package/lib/components/RichTextEditor/DynamicValue.d.ts +0 -8
- package/lib/components/RichTextEditor/DynamicValue.js +0 -73
- package/lib/components/RichTextEditor/DynamicValue.js.map +0 -1
- package/lib/components/RichTextEditor/DynamicValueList.d.ts +0 -11
- package/lib/components/RichTextEditor/DynamicValueList.js +0 -49
- package/lib/components/RichTextEditor/DynamicValueList.js.map +0 -1
- package/lib/components/RichTextEditor/ImagePopover.d.ts +0 -10
- package/lib/components/RichTextEditor/ImagePopover.js +0 -99
- package/lib/components/RichTextEditor/ImagePopover.js.map +0 -1
- package/lib/components/RichTextEditor/LinkPopover.d.ts +0 -8
- package/lib/components/RichTextEditor/LinkPopover.js +0 -98
- package/lib/components/RichTextEditor/LinkPopover.js.map +0 -1
- package/lib/components/RichTextEditor/RichTextEditor.d.ts +0 -5
- package/lib/components/RichTextEditor/RichTextEditor.js +0 -216
- package/lib/components/RichTextEditor/RichTextEditor.js.map +0 -1
- package/lib/components/RichTextEditor/Toolbar.d.ts +0 -12
- package/lib/components/RichTextEditor/Toolbar.js +0 -186
- package/lib/components/RichTextEditor/Toolbar.js.map +0 -1
- package/lib/components/RichTextEditor/constants.d.ts +0 -4
- package/lib/components/RichTextEditor/constants.js +0 -33
- package/lib/components/RichTextEditor/constants.js.map +0 -1
- package/lib/components/RichTextEditor/fileAttachment.d.ts +0 -23
- package/lib/components/RichTextEditor/fileAttachment.js +0 -143
- package/lib/components/RichTextEditor/fileAttachment.js.map +0 -1
- package/lib/components/RichTextEditor/imageUpload.d.ts +0 -6
- package/lib/components/RichTextEditor/imageUpload.js +0 -29
- package/lib/components/RichTextEditor/imageUpload.js.map +0 -1
- package/lib/components/RichTextEditor/index.d.ts +0 -1
- package/lib/components/RichTextEditor/index.js +0 -2
- package/lib/components/RichTextEditor/index.js.map +0 -1
- package/lib/components/RichTextEditor/pasteFormatting.d.ts +0 -18
- package/lib/components/RichTextEditor/pasteFormatting.js +0 -167
- package/lib/components/RichTextEditor/pasteFormatting.js.map +0 -1
- package/lib/components/RichTextEditor/types.d.ts +0 -167
- package/lib/components/RichTextEditor/types.js +0 -2
- package/lib/components/RichTextEditor/types.js.map +0 -1
|
@@ -1,48 +1,56 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useLayoutEffect, useRef } from 'react';
|
|
3
3
|
import './AutoTruncateText.scss';
|
|
4
|
-
import {
|
|
4
|
+
import { subscribe } from './resizeObserverService';
|
|
5
5
|
const AutoTruncateText = memo(({ children, className, lines = 1, interactive = false, placement = 'bottom', allowedHtml = false, tooltipText = "" }) => {
|
|
6
6
|
const textRef = useRef(null);
|
|
7
|
-
const
|
|
7
|
+
const isSingleLine = lines <= 1;
|
|
8
|
+
const normalizedPlacement = placement?.toLowerCase();
|
|
9
|
+
// Several lines: whether the clamp cuts text off is measured in the resize
|
|
10
|
+
// observer's callback, after layout, and written after every read
|
|
8
11
|
useLayoutEffect(() => {
|
|
9
12
|
const el = textRef.current;
|
|
10
|
-
if (!el)
|
|
11
|
-
return;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (normalizedPlacement) {
|
|
20
|
-
el.setAttribute('data-tooltip-placement', normalizedPlacement);
|
|
21
|
-
}
|
|
22
|
-
if (truncated) {
|
|
23
|
-
if (allowedHtml) {
|
|
24
|
-
el.setAttribute('data-tooltip', tooltipText);
|
|
25
|
-
el.setAttribute('data-tooltip-allowhtml', 'true');
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
const text = tooltipText || el.textContent?.trim() || '';
|
|
29
|
-
if (text) {
|
|
13
|
+
if (!el || isSingleLine)
|
|
14
|
+
return undefined;
|
|
15
|
+
return subscribe(el, () => {
|
|
16
|
+
const truncated = el.scrollHeight > el.clientHeight + 0.5;
|
|
17
|
+
const text = allowedHtml
|
|
18
|
+
? tooltipText
|
|
19
|
+
: tooltipText || el.textContent?.trim() || '';
|
|
20
|
+
return () => {
|
|
21
|
+
if (truncated && text) {
|
|
30
22
|
el.setAttribute('data-tooltip', text);
|
|
23
|
+
if (allowedHtml)
|
|
24
|
+
el.setAttribute('data-tooltip-allowhtml', 'true');
|
|
31
25
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
}, [
|
|
26
|
+
else {
|
|
27
|
+
el.removeAttribute('data-tooltip');
|
|
28
|
+
el.removeAttribute('data-tooltip-allowhtml');
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}, [children, isSingleLine, allowedHtml, tooltipText]);
|
|
33
|
+
// One line: TooltipService checks the cut-off itself when the text is
|
|
34
|
+
// hovered, so nothing is measured while it mounts (e.g. one per table row)
|
|
35
|
+
const showsWhenCutOff = isSingleLine && (!allowedHtml || !!tooltipText);
|
|
36
|
+
const tooltipProps = {
|
|
37
|
+
...(showsWhenCutOff ? { 'data-tooltip-overflow': '' } : {}),
|
|
38
|
+
...(showsWhenCutOff && tooltipText ? { 'data-tooltip': tooltipText } : {}),
|
|
39
|
+
...(showsWhenCutOff && allowedHtml
|
|
40
|
+
? { 'data-tooltip-allowhtml': 'true' }
|
|
41
|
+
: {}),
|
|
42
|
+
...(interactive ? { 'data-tooltip-interactive': 'true' } : {}),
|
|
43
|
+
...(normalizedPlacement
|
|
44
|
+
? { 'data-tooltip-placement': normalizedPlacement }
|
|
45
|
+
: {}),
|
|
46
|
+
};
|
|
39
47
|
const textContent = typeof children === 'string' ? children : '';
|
|
40
48
|
return (_jsx("div", { ref: textRef, className: className ? `ff-ellipsis ${className}` : 'ff-ellipsis', style: {
|
|
41
49
|
display: lines > 1 ? '-webkit-box' : 'block',
|
|
42
50
|
WebkitLineClamp: lines > 1 ? lines : undefined,
|
|
43
51
|
WebkitBoxOrient: lines > 1 ? 'vertical' : undefined,
|
|
44
52
|
whiteSpace: lines === 1 ? 'nowrap' : 'normal',
|
|
45
|
-
}, role: "text", "aria-label": textContent || 'Truncated text', children: children }));
|
|
53
|
+
}, role: "text", "aria-label": textContent || 'Truncated text', ...tooltipProps, children: children }));
|
|
46
54
|
});
|
|
47
55
|
AutoTruncateText.displayName = 'AutoTruncateText';
|
|
48
56
|
export default AutoTruncateText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoTruncateText.js","sourceRoot":"","sources":["../../../src/components/AutoTruncateText/AutoTruncateText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"AutoTruncateText.js","sourceRoot":"","sources":["../../../src/components/AutoTruncateText/AutoTruncateText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,MAAM,gBAAgB,GAAG,IAAI,CAC3B,CAAC,EACC,QAAQ,EACR,SAAS,EACT,KAAK,GAAG,CAAC,EACT,WAAW,GAAG,KAAK,EACnB,SAAS,GAAG,QAAQ,EACpB,WAAW,GAAG,KAAK,EACnB,WAAW,GAAG,EAAE,EACe,EAAE,EAAE;IACnC,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,KAAK,IAAI,CAAC,CAAC;IAChC,MAAM,mBAAmB,GAAG,SAAS,EAAE,WAAW,EAAE,CAAC;IAErD,2EAA2E;IAC3E,kEAAkE;IAClE,eAAe,CAAC,GAAG,EAAE;QACnB,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,EAAE,IAAI,YAAY;YAAE,OAAO,SAAS,CAAC;QAC1C,OAAO,SAAS,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WAAW,CAAC,CAAC,CAAC,EAAE,0BAA0B,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,GAAG,CAAC,mBAAmB;YACrB,CAAC,CAAC,EAAE,wBAAwB,EAAE,mBAAmB,EAAE;YACnD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IAEF,MAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjE,OAAO,CACL,cACE,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,EAAE,CAAC,CAAC,CAAC,aAAa,EACjE,KAAK,EAAE;YACL,OAAO,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO;YAC5C,eAAe,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YAC9C,eAAe,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;YACnD,UAAU,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;SAC9C,EACD,IAAI,EAAC,MAAM,gBACC,WAAW,IAAI,gBAAgB,KACvC,YAAY,YAEf,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAClD,eAAe,gBAAgB,CAAC"}
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
* resizeObserverService.ts
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Reads sizes and may return a function that writes to the DOM. Every read
|
|
6
|
+
* runs before any write, so a write never makes the next read lay out again.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
type ResizeCallback = () => void | (() => void);
|
|
9
|
+
/**
|
|
10
|
+
* Register an element to the SINGLE global observer. The observer reports a
|
|
11
|
+
* newly observed element once, after its first layout, so subscribing is also
|
|
12
|
+
* how a subscriber gets its first measurement.
|
|
13
|
+
*/
|
|
14
|
+
export declare const subscribe: (el: Element, callback: ResizeCallback) => () => void;
|
|
15
|
+
export {};
|
|
@@ -2,23 +2,30 @@
|
|
|
2
2
|
* resizeObserverService.ts
|
|
3
3
|
*/
|
|
4
4
|
const subscribers = new Map();
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
// Created on first use, so importing this needs no ResizeObserver (e.g. SSR)
|
|
6
|
+
let observer = null;
|
|
7
|
+
// Callbacks run inside the observer's callback, where layout is already done,
|
|
8
|
+
// so they can read sizes for free. A frame later the next commit may have
|
|
9
|
+
// changed the DOM, and the same read would force a layout per element.
|
|
10
|
+
const getObserver = () => (observer ??= new ResizeObserver(entries => {
|
|
11
|
+
const writes = [];
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
const write = subscribers.get(entry.target)?.();
|
|
14
|
+
if (typeof write === 'function')
|
|
15
|
+
writes.push(write);
|
|
16
|
+
}
|
|
17
|
+
writes.forEach(write => write());
|
|
18
|
+
}));
|
|
14
19
|
/**
|
|
15
|
-
* Register an element to the SINGLE global observer.
|
|
20
|
+
* Register an element to the SINGLE global observer. The observer reports a
|
|
21
|
+
* newly observed element once, after its first layout, so subscribing is also
|
|
22
|
+
* how a subscriber gets its first measurement.
|
|
16
23
|
*/
|
|
17
24
|
export const subscribe = (el, callback) => {
|
|
18
25
|
subscribers.set(el, callback);
|
|
19
|
-
|
|
26
|
+
getObserver().observe(el);
|
|
20
27
|
return () => {
|
|
21
|
-
|
|
28
|
+
getObserver().unobserve(el);
|
|
22
29
|
subscribers.delete(el);
|
|
23
30
|
};
|
|
24
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizeObserverService.js","sourceRoot":"","sources":["../../../src/components/AutoTruncateText/resizeObserverService.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"resizeObserverService.js","sourceRoot":"","sources":["../../../src/components/AutoTruncateText/resizeObserverService.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEvD,6EAA6E;AAC7E,IAAI,QAAQ,GAA0B,IAAI,CAAC;AAE3C,8EAA8E;AAC9E,0EAA0E;AAC1E,uEAAuE;AACvE,MAAM,WAAW,GAAG,GAAG,EAAE,CACvB,CAAC,QAAQ,KAAK,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;IACzC,MAAM,MAAM,GAAmB,EAAE,CAAC;IAClC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QAChD,IAAI,OAAO,KAAK,KAAK,UAAU;YAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC,CAAC;AAEN;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAW,EAAE,QAAwB,EAAE,EAAE;IACjE,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC9B,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAE1B,OAAO,GAAG,EAAE;QACV,WAAW,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC5B,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { HighlightTextProps } from './types';
|
|
2
2
|
import './HighlightText.scss';
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const MemoizedHighlightText: import("react").MemoExoticComponent<({ text, segments, highlight, onlyExactMatch, color, fontWeight, tooltip, truncate, }: HighlightTextProps) => import("react").JSX.Element>;
|
|
4
|
+
export default MemoizedHighlightText;
|
|
@@ -1,22 +1,153 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import './HighlightText.scss';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { Fragment, isValidElement, memo, useId, useLayoutEffect, useRef, useState, } from 'react';
|
|
4
|
+
import { subscribe } from '../AutoTruncateText/resizeObserverService';
|
|
5
|
+
import useInteractiveAncestor from '../../hooks/useInteractiveAncestor';
|
|
5
6
|
// Function to escape special characters in the search term
|
|
6
7
|
const escapeRegExp = (text) => {
|
|
7
8
|
return text?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
8
9
|
};
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const getSegmentText = (segment) => typeof segment === 'string' ? segment : (segment.text ?? '');
|
|
11
|
+
const getTextStyle = (color, fontWeight) => color || fontWeight ? { color, fontWeight } : undefined;
|
|
12
|
+
// Text goes in `data-tooltip`. JSX cannot, so it is rendered into a hidden
|
|
13
|
+
// element that `data-tooltip-id` points to, and TooltipService copies its HTML.
|
|
14
|
+
// The pointer can move onto the tooltip (WCAG 1.4.13), and the element takes
|
|
15
|
+
// focus so keyboard users get the tooltip too (WCAG 2.1.1).
|
|
16
|
+
const getTooltipProps = (tooltip, templateId, focusable) => {
|
|
17
|
+
if (!tooltip)
|
|
18
|
+
return {};
|
|
19
|
+
return {
|
|
20
|
+
...(isValidElement(tooltip)
|
|
21
|
+
? { 'data-tooltip-id': templateId }
|
|
22
|
+
: {
|
|
23
|
+
'data-tooltip': tooltip,
|
|
24
|
+
// Keeps line breaks, e.g. one `name: value` per line
|
|
25
|
+
'data-tooltip-multiline': typeof tooltip === 'string' && tooltip.includes('\n')
|
|
26
|
+
? ''
|
|
27
|
+
: undefined,
|
|
28
|
+
}),
|
|
29
|
+
'data-tooltip-hoverable': '',
|
|
30
|
+
tabIndex: focusable ? 0 : undefined,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
// One-line ellipsis cut-off, measured again when the text or its size changes.
|
|
34
|
+
// Measured only in the resize observer's callback, after layout: reading the
|
|
35
|
+
// width here, during the commit, forced a layout for every row that mounted.
|
|
36
|
+
// Subscribing again when the text changes gets a fresh report.
|
|
37
|
+
const useIsClipped = (ref, enabled, text) => {
|
|
38
|
+
const [isClipped, setIsClipped] = useState(false);
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
const element = ref.current;
|
|
41
|
+
if (!enabled || !element)
|
|
42
|
+
return undefined;
|
|
43
|
+
return subscribe(element, () => setIsClipped(element.scrollWidth > element.clientWidth + 0.5));
|
|
44
|
+
}, [ref, enabled, text]);
|
|
45
|
+
return enabled && isClipped;
|
|
46
|
+
};
|
|
47
|
+
// Where the search term occurs in the whole text, ignoring case
|
|
48
|
+
const findMatches = (text, highlight) => {
|
|
49
|
+
const ranges = [];
|
|
50
|
+
const regex = new RegExp(escapeRegExp(highlight), 'gi');
|
|
51
|
+
for (let match = regex.exec(text); match; match = regex.exec(text)) {
|
|
52
|
+
ranges.push([match.index, match.index + match[0].length]);
|
|
53
|
+
}
|
|
54
|
+
return ranges;
|
|
55
|
+
};
|
|
56
|
+
// One segment's text, with the matches that overlap it marked. `start` is where
|
|
57
|
+
// the segment begins in the whole text, so a match can run across segments.
|
|
58
|
+
const markMatches = (text, start, ranges) => {
|
|
59
|
+
const end = start + text.length;
|
|
60
|
+
const nodes = [];
|
|
61
|
+
let cursor = start;
|
|
62
|
+
for (const [matchStart, matchEnd] of ranges) {
|
|
63
|
+
if (matchStart >= end)
|
|
64
|
+
break;
|
|
65
|
+
if (matchEnd <= start)
|
|
66
|
+
continue;
|
|
67
|
+
const from = Math.max(matchStart, start);
|
|
68
|
+
const to = Math.min(matchEnd, end);
|
|
69
|
+
if (from > cursor)
|
|
70
|
+
nodes.push(text.slice(cursor - start, from - start));
|
|
71
|
+
nodes.push(_jsx("mark", { className: "ff-highlight-bg", children: text.slice(from - start, to - start) }, `highlight-${from}`));
|
|
72
|
+
cursor = to;
|
|
12
73
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
74
|
+
if (!nodes.length)
|
|
75
|
+
return text;
|
|
76
|
+
if (cursor < end)
|
|
77
|
+
nodes.push(text.slice(cursor - start));
|
|
78
|
+
return nodes;
|
|
79
|
+
};
|
|
80
|
+
const HighlightText = ({ text = '', segments, highlight = '', onlyExactMatch = false, color, fontWeight, tooltip, truncate = false, }) => {
|
|
81
|
+
const rowRef = useRef(null);
|
|
82
|
+
const tooltipId = `ff-highlight-tooltip-${useId().replace(/:/g, '')}`;
|
|
83
|
+
const query = String(highlight ?? '');
|
|
84
|
+
const fullText = segments ? segments.map(getSegmentText).join('') : text;
|
|
85
|
+
const isExactMatch = !!query && onlyExactMatch && fullText.toLowerCase() === query.toLowerCase();
|
|
86
|
+
const ranges = query && !onlyExactMatch ? findMatches(fullText, query) : [];
|
|
87
|
+
// Without a tooltip, TooltipService shows the full text while it is cut off
|
|
88
|
+
const showsOverflow = truncate && !tooltip;
|
|
89
|
+
const hasTooltip = !!tooltip ||
|
|
90
|
+
showsOverflow ||
|
|
91
|
+
!!segments?.some((segment) => typeof segment !== 'string' && !!segment.tooltip);
|
|
92
|
+
const isClipped = useIsClipped(rowRef, showsOverflow, fullText);
|
|
93
|
+
// Inside a control (e.g. a button), that control takes focus instead
|
|
94
|
+
const focusable = !useInteractiveAncestor(rowRef, hasTooltip);
|
|
95
|
+
let offset = 0;
|
|
96
|
+
const content = (segments ?? [text]).map((segment, index) => {
|
|
97
|
+
const value = getSegmentText(segment);
|
|
98
|
+
const marked = markMatches(value, offset, ranges);
|
|
99
|
+
offset += value.length;
|
|
100
|
+
if (typeof segment === 'string') {
|
|
101
|
+
return _jsx(Fragment, { children: marked }, `segment-${index}`);
|
|
102
|
+
}
|
|
103
|
+
return (_jsx("span", { style: getTextStyle(segment.color, segment.fontWeight), ...getTooltipProps(segment.tooltip, `${tooltipId}-${index}`, focusable), children: marked }, `segment-${index}`));
|
|
104
|
+
});
|
|
105
|
+
const templates = [
|
|
106
|
+
{ id: tooltipId, tooltip },
|
|
107
|
+
...(segments ?? []).map((segment, index) => ({
|
|
108
|
+
id: `${tooltipId}-${index}`,
|
|
109
|
+
tooltip: typeof segment === 'string' ? undefined : segment.tooltip,
|
|
110
|
+
})),
|
|
111
|
+
].filter((template) => isValidElement(template.tooltip));
|
|
112
|
+
// The row takes focus only while its full text is hidden
|
|
113
|
+
const rowTooltipProps = showsOverflow
|
|
114
|
+
? {
|
|
115
|
+
'data-tooltip-overflow': '',
|
|
116
|
+
'data-tooltip-hoverable': '',
|
|
117
|
+
tabIndex: focusable && isClipped ? 0 : undefined,
|
|
118
|
+
}
|
|
119
|
+
: getTooltipProps(tooltip, tooltipId, focusable);
|
|
120
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: rowRef, className: truncate ? 'ff-highlight-text--truncate' : undefined, style: getTextStyle(color, fontWeight), ...rowTooltipProps, children: isExactMatch ? (_jsx("mark", { className: "ff-highlight-bg", children: content })) : (content) }), templates.map((template) => (_jsx("span", { id: template.id, hidden: true, children: template.tooltip }, template.id)))] }));
|
|
121
|
+
};
|
|
122
|
+
const isSameSegment = (a, b) => typeof a === 'string' || typeof b === 'string'
|
|
123
|
+
? a === b
|
|
124
|
+
: a.text === b.text &&
|
|
125
|
+
a.color === b.color &&
|
|
126
|
+
a.fontWeight === b.fontWeight &&
|
|
127
|
+
a.tooltip === b.tooltip;
|
|
128
|
+
// Segments are compared by value (a JSX tooltip by reference), so rows that
|
|
129
|
+
// rebuild the same segments on every render (e.g. in a virtualized table) do
|
|
130
|
+
// not re-render
|
|
131
|
+
const arePropsEqual = (prev, next) => {
|
|
132
|
+
const keys = Object.keys({
|
|
133
|
+
...prev,
|
|
134
|
+
...next,
|
|
135
|
+
});
|
|
136
|
+
if (keys.some((key) => key !== 'segments' && !Object.is(prev[key], next[key]))) {
|
|
137
|
+
return false;
|
|
18
138
|
}
|
|
19
|
-
|
|
139
|
+
const { segments: before } = prev;
|
|
140
|
+
const { segments: after } = next;
|
|
141
|
+
return (before === after ||
|
|
142
|
+
(!!before &&
|
|
143
|
+
!!after &&
|
|
144
|
+
before.length === after.length &&
|
|
145
|
+
before.every((segment, index) => {
|
|
146
|
+
const other = after[index];
|
|
147
|
+
return other !== undefined && isSameSegment(segment, other);
|
|
148
|
+
})));
|
|
20
149
|
};
|
|
21
|
-
|
|
150
|
+
const MemoizedHighlightText = memo(HighlightText, arePropsEqual);
|
|
151
|
+
MemoizedHighlightText.displayName = 'HighlightText';
|
|
152
|
+
export default MemoizedHighlightText;
|
|
22
153
|
//# sourceMappingURL=HighlightText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightText.js","sourceRoot":"","sources":["../../../src/components/HighlightText/HighlightText.tsx"],"names":[],"mappings":";AACA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"HighlightText.js","sourceRoot":"","sources":["../../../src/components/HighlightText/HighlightText.tsx"],"names":[],"mappings":";AACA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAEL,QAAQ,EAIR,cAAc,EACd,IAAI,EACJ,KAAK,EACL,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AACtE,OAAO,sBAAsB,MAAM,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CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAC1E,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAClC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACjC,OAAO,CACL,MAAM,KAAK,KAAK;QAChB,CAAC,CAAC,CAAC,MAAM;YACP,CAAC,CAAC,KAAK;YACP,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;YAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;gBAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC3B,OAAO,KAAK,KAAK,SAAS,IAAI,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AACjE,qBAAqB,CAAC,WAAW,GAAG,eAAe,CAAC;AAEpD,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,5 +1,51 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
2
|
+
/** A styled part of the text, e.g. a variable inside a step name */
|
|
3
|
+
export interface HighlightTextPart {
|
|
4
|
+
text: string;
|
|
5
|
+
/**
|
|
6
|
+
* Needs the same contrast as `color` on the row. Colour alone must not tell
|
|
7
|
+
* kinds of parts apart (WCAG 1.4.1): a tooltip can say what the part is.
|
|
8
|
+
*/
|
|
9
|
+
color?: string;
|
|
10
|
+
fontWeight?: CSSProperties['fontWeight'];
|
|
11
|
+
/**
|
|
12
|
+
* Shown on hover over this part only. Text or JSX, as for `tooltip` below.
|
|
13
|
+
* A line break (`\n`) in text starts a new line, e.g. for an element's name
|
|
14
|
+
* and type; prefer that over JSX in long lists, since JSX tooltips render a
|
|
15
|
+
* hidden copy in every row.
|
|
16
|
+
*/
|
|
17
|
+
tooltip?: string | ReactElement;
|
|
18
|
+
}
|
|
19
|
+
/** Plain text, or a styled part */
|
|
20
|
+
export type HighlightTextSegment = string | HighlightTextPart;
|
|
1
21
|
export interface HighlightTextProps {
|
|
2
22
|
text?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Use instead of `text` when parts need their own colour or tooltip.
|
|
25
|
+
* Search highlighting runs on the joined text, so a match can span parts.
|
|
26
|
+
*/
|
|
27
|
+
segments?: HighlightTextSegment[];
|
|
3
28
|
highlight?: String;
|
|
4
29
|
onlyExactMatch?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Text colour: any CSS colour value or variable, e.g. `var(--brand-color)`.
|
|
32
|
+
* WCAG 1.4.6 (AAA) needs 7:1 contrast with the background (4.5:1 for large
|
|
33
|
+
* text), also against the search highlight.
|
|
34
|
+
*/
|
|
35
|
+
color?: string;
|
|
36
|
+
fontWeight?: CSSProperties['fontWeight'];
|
|
37
|
+
/**
|
|
38
|
+
* Shown on hover or keyboard focus, through the global TooltipService. The
|
|
39
|
+
* text takes focus for it, except inside another control (e.g. a button),
|
|
40
|
+
* which should then carry the tooltip itself. Escape hides it. JSX is copied
|
|
41
|
+
* into the tooltip as HTML, so it is static: event handlers inside it do not
|
|
42
|
+
* run.
|
|
43
|
+
*/
|
|
44
|
+
tooltip?: string | ReactElement;
|
|
45
|
+
/**
|
|
46
|
+
* Keep to one line and end with an ellipsis when it does not fit. The full
|
|
47
|
+
* text shows on hover or focus, only while it is cut off (unless `tooltip`
|
|
48
|
+
* is set); the row takes focus only then.
|
|
49
|
+
*/
|
|
50
|
+
truncate?: boolean;
|
|
5
51
|
}
|
|
@@ -680,10 +680,9 @@ import RecorderResumePlaybackIcon from '../../assets/icons/recorder_resume_playb
|
|
|
680
680
|
import RecorderStopPlaybackIcon from '../../assets/icons/recorder_stop_playback_icon.svg?react';
|
|
681
681
|
import RecorderResumeRecordingIcon from '../../assets/icons/recorder_resume_recording_icon.svg?react';
|
|
682
682
|
import RecorderStopRecordingIcon from '../../assets/icons/recorder_stop_recording_icon.svg?react';
|
|
683
|
-
import ImageIcon from '../../assets/icons/image.svg?react';
|
|
684
683
|
import Reports from '../../assets/icons/reports.svg?react';
|
|
685
684
|
import Code_404 from '../../assets/icons/code_404.svg?react';
|
|
686
|
-
import
|
|
685
|
+
import Mantis_Bt_Icon from '../../assets/icons/mantis_bt_icon.svg?react';
|
|
687
686
|
Components['success'] = ToastSuccessIcon;
|
|
688
687
|
Components['setting_icon'] = SettingIcon;
|
|
689
688
|
Components['create_manual_auto_mark'] = CreateManualTag;
|
|
@@ -1369,9 +1368,8 @@ Components['recorder_resume_playback_icon'] = RecorderResumePlaybackIcon;
|
|
|
1369
1368
|
Components['recorder_stop_playback_icon'] = RecorderStopPlaybackIcon;
|
|
1370
1369
|
Components['recorder_resume_recording_icon'] = RecorderResumeRecordingIcon;
|
|
1371
1370
|
Components['recorder_stop_recording_icon'] = RecorderStopRecordingIcon;
|
|
1372
|
-
Components['image'] = ImageIcon;
|
|
1373
1371
|
Components['reports'] = Reports;
|
|
1374
1372
|
Components['code_404'] = Code_404;
|
|
1375
|
-
Components['mantis_bt_icon'] =
|
|
1373
|
+
Components['mantis_bt_icon'] = Mantis_Bt_Icon;
|
|
1376
1374
|
export default Components;
|
|
1377
1375
|
//# sourceMappingURL=iconList.js.map
|