@teambit/react.ui.component-highlighter 0.0.490 → 0.0.494
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/{multi-highlighter/multi-highlighter.composition.tsx → children-highlighter/children-highlighter.composition.tsx} +27 -25
- package/{multi-highlighter/multi-highlighter.spec.tsx → children-highlighter/children-highlighter.spec.tsx} +3 -3
- package/children-highlighter/children-highlighter.tsx +9 -0
- package/children-highlighter/index.ts +5 -0
- package/{multi-highlighter/use-multi-highlighter.tsx → children-highlighter/use-children-highlighter.tsx} +15 -15
- package/component-highlighter.docs.md +3 -3
- package/dist/children-highlighter/children-highlighter.composition.d.ts +5 -0
- package/dist/{multi-highlighter/multi-highlighter.composition.js → children-highlighter/children-highlighter.composition.js} +29 -27
- package/dist/children-highlighter/children-highlighter.composition.js.map +1 -0
- package/dist/children-highlighter/children-highlighter.d.ts +3 -0
- package/dist/{multi-highlighter/multi-highlighter.js → children-highlighter/children-highlighter.js} +6 -6
- package/dist/children-highlighter/children-highlighter.js.map +1 -0
- package/dist/{multi-highlighter/multi-highlighter.spec.d.ts → children-highlighter/children-highlighter.spec.d.ts} +0 -0
- package/dist/{multi-highlighter/multi-highlighter.spec.js → children-highlighter/children-highlighter.spec.js} +4 -4
- package/dist/children-highlighter/children-highlighter.spec.js.map +1 -0
- package/dist/children-highlighter/index.d.ts +4 -0
- package/dist/children-highlighter/index.js +8 -0
- package/dist/children-highlighter/index.js.map +1 -0
- package/dist/{multi-highlighter/use-multi-highlighter.d.ts → children-highlighter/use-children-highlighter.d.ts} +2 -4
- package/dist/{multi-highlighter/use-multi-highlighter.js → children-highlighter/use-children-highlighter.js} +9 -12
- package/dist/children-highlighter/use-children-highlighter.js.map +1 -0
- package/dist/component-highlighter.docs.md +3 -3
- package/dist/element-highlighter/element-highlighter.compositions.d.ts +3 -1
- package/dist/element-highlighter/element-highlighter.compositions.js +15 -7
- package/dist/element-highlighter/element-highlighter.compositions.js.map +1 -1
- package/dist/element-highlighter/element-highlighter.d.ts +8 -9
- package/dist/element-highlighter/element-highlighter.js +3 -3
- package/dist/element-highlighter/element-highlighter.js.map +1 -1
- package/dist/element-highlighter/index.d.ts +1 -1
- package/dist/hover-highlighter/hover-highlighter.compositions.d.ts +0 -1
- package/dist/hover-highlighter/hover-highlighter.d.ts +1 -2
- package/dist/hover-highlighter/hover-highlighter.js +2 -2
- package/dist/hover-highlighter/hover-highlighter.js.map +1 -1
- package/dist/hover-highlighter/use-hover-highlighter.d.ts +3 -3
- package/dist/hover-highlighter/use-hover-highlighter.js +9 -14
- package/dist/hover-highlighter/use-hover-highlighter.js.map +1 -1
- package/dist/{hybrid-highligher → hybrid-highlighter}/hybrid-highlighter.d.ts +4 -2
- package/dist/{hybrid-highligher → hybrid-highlighter}/hybrid-highlighter.js +6 -6
- package/dist/hybrid-highlighter/hybrid-highlighter.js.map +1 -0
- package/dist/{hybrid-highligher → hybrid-highlighter}/index.d.ts +0 -0
- package/dist/{hybrid-highligher → hybrid-highlighter}/index.js +0 -0
- package/dist/hybrid-highlighter/index.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/label/component-strip.d.ts +9 -0
- package/dist/label/component-strip.js +49 -0
- package/dist/label/component-strip.js.map +1 -0
- package/dist/label/component-strip.module.scss +64 -0
- package/dist/label/index.d.ts +4 -2
- package/dist/label/index.js +3 -2
- package/dist/label/index.js.map +1 -1
- package/dist/label/label-container.d.ts +13 -0
- package/dist/label/label-container.js +53 -0
- package/dist/label/label-container.js.map +1 -0
- package/dist/label/label.d.ts +7 -19
- package/dist/label/label.js +20 -27
- package/dist/label/label.js.map +1 -1
- package/dist/label/label.module.scss +24 -0
- package/dist/label/links.d.ts +2 -0
- package/dist/label/links.js +17 -0
- package/dist/label/links.js.map +1 -0
- package/dist/label/other-components.d.ts +10 -0
- package/dist/label/other-components.js +35 -0
- package/dist/label/other-components.js.map +1 -0
- package/dist/rule-matcher.d.ts +3 -3
- package/dist/rule-matcher.js +1 -0
- package/dist/rule-matcher.js.map +1 -1
- package/dist/use-animation-frame.d.ts +1 -1
- package/dist/use-animation-frame.js.map +1 -1
- package/element-highlighter/element-highlighter.compositions.tsx +22 -8
- package/element-highlighter/element-highlighter.tsx +11 -16
- package/element-highlighter/index.ts +7 -1
- package/hover-highlighter/hover-highlighter.tsx +1 -1
- package/hover-highlighter/use-hover-highlighter.tsx +18 -18
- package/{hybrid-highligher → hybrid-highlighter}/hybrid-highlighter.tsx +15 -5
- package/{hybrid-highligher → hybrid-highlighter}/index.ts +0 -0
- package/index.ts +4 -4
- package/label/component-strip.module.scss +64 -0
- package/label/component-strip.tsx +49 -0
- package/label/index.ts +5 -2
- package/label/label-container.tsx +46 -0
- package/label/label.module.scss +24 -0
- package/label/label.tsx +35 -66
- package/label/links.tsx +9 -0
- package/label/other-components.tsx +53 -0
- package/package-tar/teambit-react.ui.component-highlighter-0.0.494.tgz +0 -0
- package/package.json +15 -15
- package/rule-matcher.tsx +3 -2
- package/use-animation-frame.tsx +1 -1
- package/bubble/bubble.module.scss +0 -24
- package/bubble/index.ts +0 -3
- package/dist/bubble/bubble.module.scss +0 -24
- package/dist/bubble/index.d.ts +0 -1
- package/dist/bubble/index.js +0 -9
- package/dist/bubble/index.js.map +0 -1
- package/dist/hybrid-highligher/hybrid-highlighter.js.map +0 -1
- package/dist/hybrid-highligher/index.js.map +0 -1
- package/dist/label/component-label/component-bubble.d.ts +0 -8
- package/dist/label/component-label/component-bubble.js +0 -35
- package/dist/label/component-label/component-bubble.js.map +0 -1
- package/dist/label/component-label/component-label.d.ts +0 -10
- package/dist/label/component-label/component-label.js +0 -32
- package/dist/label/component-label/component-label.js.map +0 -1
- package/dist/label/component-label/duo-component-bubble.module.scss +0 -24
- package/dist/label/component-label/index.d.ts +0 -2
- package/dist/label/component-label/index.js +0 -6
- package/dist/label/component-label/index.js.map +0 -1
- package/dist/label/component-label/scope-bubble.d.ts +0 -7
- package/dist/label/component-label/scope-bubble.js +0 -28
- package/dist/label/component-label/scope-bubble.js.map +0 -1
- package/dist/label/default-label/default-label.d.ts +0 -6
- package/dist/label/default-label/default-label.js +0 -30
- package/dist/label/default-label/default-label.js.map +0 -1
- package/dist/label/default-label/default-label.module.scss +0 -12
- package/dist/label/default-label/index.d.ts +0 -1
- package/dist/label/default-label/index.js +0 -6
- package/dist/label/default-label/index.js.map +0 -1
- package/dist/multi-highlighter/index.d.ts +0 -2
- package/dist/multi-highlighter/index.js +0 -6
- package/dist/multi-highlighter/index.js.map +0 -1
- package/dist/multi-highlighter/multi-highlighter.composition.d.ts +0 -6
- package/dist/multi-highlighter/multi-highlighter.composition.js.map +0 -1
- package/dist/multi-highlighter/multi-highlighter.d.ts +0 -4
- package/dist/multi-highlighter/multi-highlighter.js.map +0 -1
- package/dist/multi-highlighter/multi-highlighter.spec.js.map +0 -1
- package/dist/multi-highlighter/use-multi-highlighter.js.map +0 -1
- package/label/component-label/component-bubble.tsx +0 -30
- package/label/component-label/component-label.tsx +0 -31
- package/label/component-label/duo-component-bubble.module.scss +0 -24
- package/label/component-label/index.ts +0 -2
- package/label/component-label/scope-bubble.tsx +0 -20
- package/label/default-label/default-label.module.scss +0 -12
- package/label/default-label/default-label.tsx +0 -22
- package/label/default-label/index.ts +0 -1
- package/multi-highlighter/index.ts +0 -2
- package/multi-highlighter/multi-highlighter.tsx +0 -9
- package/package-tar/teambit-react.ui.component-highlighter-0.0.490.tgz +0 -0
|
@@ -3,23 +3,23 @@ import React from 'react';
|
|
|
3
3
|
import { MockedComponentWithMeta } from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
4
4
|
import { IconButton } from '@teambit/design.ui.icon-button';
|
|
5
5
|
import { ExcludeHighlighter } from '../ignore-highlighter';
|
|
6
|
-
import {
|
|
6
|
+
import { ChildrenHighlighter } from './children-highlighter';
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const ChildrenHighlighterPreview = () => {
|
|
9
9
|
return (
|
|
10
|
-
<
|
|
10
|
+
<ChildrenHighlighter style={{ padding: 40, minWidth: 200 }}>
|
|
11
11
|
<MockedComponentWithMeta>hover here</MockedComponentWithMeta>
|
|
12
12
|
<br />
|
|
13
13
|
<br />
|
|
14
14
|
<br />
|
|
15
|
-
<
|
|
16
|
-
</
|
|
15
|
+
<IconButton>this will be highlighted with dropdown</IconButton>
|
|
16
|
+
</ChildrenHighlighter>
|
|
17
17
|
);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const
|
|
20
|
+
export const ChildrenHighlighterWithCustomColors = () => {
|
|
21
21
|
return (
|
|
22
|
-
<
|
|
22
|
+
<ChildrenHighlighter
|
|
23
23
|
style={{ padding: 40, minWidth: 200, color: 'yellow' }}
|
|
24
24
|
bgColor="cornflowerblue"
|
|
25
25
|
bgColorHover="blue"
|
|
@@ -30,14 +30,14 @@ export const MultiHighlighterWithCustomColors = () => {
|
|
|
30
30
|
<br />
|
|
31
31
|
<br />
|
|
32
32
|
<MockedComponentWithMeta>also here</MockedComponentWithMeta>
|
|
33
|
-
</
|
|
33
|
+
</ChildrenHighlighter>
|
|
34
34
|
);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
export const
|
|
37
|
+
export const ChildrenHighlighterInsideIgnore = () => {
|
|
38
38
|
return (
|
|
39
39
|
<ExcludeHighlighter>
|
|
40
|
-
<
|
|
40
|
+
<ChildrenHighlighter>
|
|
41
41
|
Multi Highlighter should still work when inside <code>{'<ExcludeHighlighter>'}</code>
|
|
42
42
|
<br />
|
|
43
43
|
It should only skip exclusion zones inside of it.
|
|
@@ -49,47 +49,49 @@ export const MultiHighlighterInsideIgnore = () => {
|
|
|
49
49
|
<br />
|
|
50
50
|
<br />
|
|
51
51
|
<MockedComponentWithMeta>also here</MockedComponentWithMeta>
|
|
52
|
-
</
|
|
52
|
+
</ChildrenHighlighter>
|
|
53
53
|
</ExcludeHighlighter>
|
|
54
54
|
);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
export const
|
|
57
|
+
export const ChildrenHighlighterWithRule = () => {
|
|
58
58
|
return (
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
|
|
59
|
+
<ChildrenHighlighter rule="#someSubTree *" style={{ minWidth: 300 }}>
|
|
60
|
+
<div>
|
|
61
|
+
element filter: <code>"#someSubTree *"</code>
|
|
62
|
+
</div>
|
|
62
63
|
<br />
|
|
63
64
|
<MockedComponentWithMeta>no highlighter</MockedComponentWithMeta>
|
|
64
65
|
<br />
|
|
65
66
|
<br />
|
|
66
67
|
<br />
|
|
67
68
|
<div id="someSubTree">
|
|
68
|
-
<MockedComponentWithMeta>
|
|
69
|
+
<MockedComponentWithMeta>this will be highlighted</MockedComponentWithMeta>
|
|
69
70
|
</div>
|
|
70
|
-
</
|
|
71
|
+
</ChildrenHighlighter>
|
|
71
72
|
);
|
|
72
73
|
};
|
|
73
74
|
|
|
74
|
-
export const
|
|
75
|
+
export const ChildrenHighlighterWithComponentRule = () => {
|
|
75
76
|
return (
|
|
76
|
-
<
|
|
77
|
-
<
|
|
78
|
-
|
|
77
|
+
<ChildrenHighlighter componentRule="teambit.design/ui/icon-button" style={{ minWidth: 300 }}>
|
|
78
|
+
<div>
|
|
79
|
+
component filter: <code>"teambit.design/ui/icon-button"</code>
|
|
80
|
+
</div>
|
|
79
81
|
<br />
|
|
80
82
|
<MockedComponentWithMeta>no highlighter</MockedComponentWithMeta>
|
|
81
83
|
<br />
|
|
82
84
|
<br />
|
|
83
85
|
<br />
|
|
84
|
-
<IconButton>
|
|
85
|
-
</
|
|
86
|
+
<IconButton>this will be highlighted</IconButton>
|
|
87
|
+
</ChildrenHighlighter>
|
|
86
88
|
);
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
// export const HighlightingAllElementsInTheEnterprisePage = () => {
|
|
90
92
|
// return (
|
|
91
|
-
// <
|
|
93
|
+
// <ChildrenHighlighter>
|
|
92
94
|
// <EnterpriseOffering style={{ height: 300 }} />
|
|
93
|
-
// </
|
|
95
|
+
// </ChildrenHighlighter>
|
|
94
96
|
// );
|
|
95
97
|
// };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
import {
|
|
3
|
+
import { ChildrenHighlighterPreview } from './children-highlighter.composition';
|
|
4
4
|
|
|
5
|
-
it('should not throw when rendering the
|
|
6
|
-
const { getByText } = render(<
|
|
5
|
+
it('should not throw when rendering the children-highlighter', () => {
|
|
6
|
+
const { getByText } = render(<ChildrenHighlighterPreview />);
|
|
7
7
|
|
|
8
8
|
const rendered = getByText('hover here');
|
|
9
9
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { HybridHighlighter, HybridHighlighterProps } from '../hybrid-highlighter';
|
|
4
|
+
|
|
5
|
+
export type ChildrenHighlighterProps = Omit<HybridHighlighterProps, 'mode'>;
|
|
6
|
+
|
|
7
|
+
export function ChildrenHighlighter({ watchMotion = false, ...props }: ChildrenHighlighterProps) {
|
|
8
|
+
return <HybridHighlighter {...props} mode={'allChildren'} watchMotion={watchMotion} />;
|
|
9
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useChildrenHighlighter } from './use-children-highlighter';
|
|
2
|
+
export type { ChildrenHighlighterOptions } from './use-children-highlighter';
|
|
3
|
+
|
|
4
|
+
export { ChildrenHighlighter } from './children-highlighter';
|
|
5
|
+
export type { ChildrenHighlighterProps } from './children-highlighter';
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import { useEffect, RefObject } from 'react';
|
|
2
2
|
import getXPath from 'get-xpath';
|
|
3
|
-
import {
|
|
3
|
+
import { domToReacts, toRootElement } from '@teambit/react.modules.dom-to-react';
|
|
4
4
|
import {
|
|
5
|
-
hasComponentMeta,
|
|
6
5
|
componentMetaField,
|
|
7
|
-
|
|
6
|
+
hasComponentMeta,
|
|
7
|
+
ReactComponentMetaHolder,
|
|
8
8
|
} from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
9
9
|
import { HighlightTarget } from '../element-highlighter';
|
|
10
10
|
import { excludeHighlighterSelector } from '../ignore-highlighter';
|
|
11
11
|
import { ruleMatcher, MatchRule, ComponentMatchRule, componentRuleMatcher } from '../rule-matcher';
|
|
12
12
|
|
|
13
|
-
type
|
|
13
|
+
export type ChildrenHighlighterOptions = {
|
|
14
14
|
onChange: (highlighterTargets: Record<string, HighlightTarget>) => void;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
scopeRef: RefObject<HTMLElement>;
|
|
17
17
|
scopeClass?: string;
|
|
18
18
|
/** filter highlighter targets by this query selector. (May be a more complex object in the future) */
|
|
19
19
|
rule?: MatchRule;
|
|
20
|
-
/** filter targets by this component match rule */
|
|
21
20
|
componentRule?: ComponentMatchRule;
|
|
22
21
|
|
|
23
22
|
// /** automatically update when children update. Use with caution, might be slow */
|
|
24
23
|
// watchDom?: boolean;
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
export function
|
|
26
|
+
export function useChildrenHighlighter({
|
|
28
27
|
onChange,
|
|
29
28
|
disabled,
|
|
30
29
|
scopeRef,
|
|
31
30
|
scopeClass: scopeSelector = '',
|
|
32
31
|
rule,
|
|
33
32
|
componentRule,
|
|
34
|
-
}:
|
|
33
|
+
}: ChildrenHighlighterOptions) {
|
|
35
34
|
useEffect(() => {
|
|
36
35
|
const nextTargets: Record<string, HighlightTarget> = {};
|
|
37
36
|
const scopeElement = scopeRef.current;
|
|
@@ -47,16 +46,17 @@ export function useMultiHighlighter({
|
|
|
47
46
|
const uniqueRoots = new Set(rootElements);
|
|
48
47
|
|
|
49
48
|
uniqueRoots.forEach((element) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
49
|
+
if (!element) return;
|
|
50
|
+
const comps = domToReacts(element);
|
|
51
|
+
const componentsWithMeta = comps.filter(
|
|
52
|
+
(x) => hasComponentMeta(x) && componentRuleMatcher({ meta: x[componentMetaField] }, componentRule)
|
|
53
|
+
) as ReactComponentMetaHolder[];
|
|
54
|
+
|
|
55
|
+
if (componentsWithMeta.length < 1) return;
|
|
54
56
|
|
|
55
57
|
const key = getXPath(element);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const local = meta[componentMetaProperties.isExported] === false;
|
|
59
|
-
nextTargets[key] = { element, id: compId, link, local };
|
|
58
|
+
|
|
59
|
+
nextTargets[key] = { element, components: componentsWithMeta };
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
onChange(nextTargets);
|
|
@@ -94,7 +94,7 @@ The Component Highlighter comes in a few different modes:
|
|
|
94
94
|
In addition to changing the `mode` prop, you can also use convenience exports from the same package:
|
|
95
95
|
|
|
96
96
|
```tsx
|
|
97
|
-
import {
|
|
97
|
+
import { ChildrenHighlighter, HoverHighlighter } from '@teambit/react.ui.component-highlighter';
|
|
98
98
|
|
|
99
99
|
function example() {
|
|
100
100
|
return (
|
|
@@ -103,9 +103,9 @@ function example() {
|
|
|
103
103
|
<App />
|
|
104
104
|
</HoverHighlighter>
|
|
105
105
|
|
|
106
|
-
<
|
|
106
|
+
<ChildrenHighlighter>
|
|
107
107
|
<App />
|
|
108
|
-
</
|
|
108
|
+
</ChildrenHighlighter>
|
|
109
109
|
</div>
|
|
110
110
|
);
|
|
111
111
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ChildrenHighlighterPreview: () => JSX.Element;
|
|
2
|
+
export declare const ChildrenHighlighterWithCustomColors: () => JSX.Element;
|
|
3
|
+
export declare const ChildrenHighlighterInsideIgnore: () => JSX.Element;
|
|
4
|
+
export declare const ChildrenHighlighterWithRule: () => JSX.Element;
|
|
5
|
+
export declare const ChildrenHighlighterWithComponentRule: () => JSX.Element;
|
|
@@ -3,34 +3,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ChildrenHighlighterWithComponentRule = exports.ChildrenHighlighterWithRule = exports.ChildrenHighlighterInsideIgnore = exports.ChildrenHighlighterWithCustomColors = exports.ChildrenHighlighterPreview = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
// import { EnterpriseOffering } from '@teambit/evangelist.pages.enterprise-offering';
|
|
9
9
|
const react_ui_highlighter_component_metadata_bit_component_meta_1 = require("@teambit/react.ui.highlighter.component-metadata.bit-component-meta");
|
|
10
10
|
const design_ui_icon_button_1 = require("@teambit/design.ui.icon-button");
|
|
11
11
|
const ignore_highlighter_1 = require("../ignore-highlighter");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
return (react_1.default.createElement(
|
|
12
|
+
const children_highlighter_1 = require("./children-highlighter");
|
|
13
|
+
const ChildrenHighlighterPreview = () => {
|
|
14
|
+
return (react_1.default.createElement(children_highlighter_1.ChildrenHighlighter, { style: { padding: 40, minWidth: 200 } },
|
|
15
15
|
react_1.default.createElement(react_ui_highlighter_component_metadata_bit_component_meta_1.MockedComponentWithMeta, null, "hover here"),
|
|
16
16
|
react_1.default.createElement("br", null),
|
|
17
17
|
react_1.default.createElement("br", null),
|
|
18
18
|
react_1.default.createElement("br", null),
|
|
19
|
-
react_1.default.createElement(
|
|
19
|
+
react_1.default.createElement(design_ui_icon_button_1.IconButton, null, "this will be highlighted with dropdown")));
|
|
20
20
|
};
|
|
21
|
-
exports.
|
|
22
|
-
const
|
|
23
|
-
return (react_1.default.createElement(
|
|
21
|
+
exports.ChildrenHighlighterPreview = ChildrenHighlighterPreview;
|
|
22
|
+
const ChildrenHighlighterWithCustomColors = () => {
|
|
23
|
+
return (react_1.default.createElement(children_highlighter_1.ChildrenHighlighter, { style: { padding: 40, minWidth: 200, color: 'yellow' }, bgColor: "cornflowerblue", bgColorHover: "blue", bgColorActive: "DarkSlateBlue" },
|
|
24
24
|
react_1.default.createElement(react_ui_highlighter_component_metadata_bit_component_meta_1.MockedComponentWithMeta, null, "hover here"),
|
|
25
25
|
react_1.default.createElement("br", null),
|
|
26
26
|
react_1.default.createElement("br", null),
|
|
27
27
|
react_1.default.createElement("br", null),
|
|
28
28
|
react_1.default.createElement(react_ui_highlighter_component_metadata_bit_component_meta_1.MockedComponentWithMeta, null, "also here")));
|
|
29
29
|
};
|
|
30
|
-
exports.
|
|
31
|
-
const
|
|
30
|
+
exports.ChildrenHighlighterWithCustomColors = ChildrenHighlighterWithCustomColors;
|
|
31
|
+
const ChildrenHighlighterInsideIgnore = () => {
|
|
32
32
|
return (react_1.default.createElement(ignore_highlighter_1.ExcludeHighlighter, null,
|
|
33
|
-
react_1.default.createElement(
|
|
33
|
+
react_1.default.createElement(children_highlighter_1.ChildrenHighlighter, null,
|
|
34
34
|
"Multi Highlighter should still work when inside ",
|
|
35
35
|
react_1.default.createElement("code", null, '<ExcludeHighlighter>'),
|
|
36
36
|
react_1.default.createElement("br", null),
|
|
@@ -44,37 +44,39 @@ const MultiHighlighterInsideIgnore = () => {
|
|
|
44
44
|
react_1.default.createElement("br", null),
|
|
45
45
|
react_1.default.createElement(react_ui_highlighter_component_metadata_bit_component_meta_1.MockedComponentWithMeta, null, "also here"))));
|
|
46
46
|
};
|
|
47
|
-
exports.
|
|
48
|
-
const
|
|
49
|
-
return (react_1.default.createElement(
|
|
50
|
-
react_1.default.createElement("
|
|
51
|
-
|
|
47
|
+
exports.ChildrenHighlighterInsideIgnore = ChildrenHighlighterInsideIgnore;
|
|
48
|
+
const ChildrenHighlighterWithRule = () => {
|
|
49
|
+
return (react_1.default.createElement(children_highlighter_1.ChildrenHighlighter, { rule: "#someSubTree *", style: { minWidth: 300 } },
|
|
50
|
+
react_1.default.createElement("div", null,
|
|
51
|
+
"element filter: ",
|
|
52
|
+
react_1.default.createElement("code", null, "\"#someSubTree *\"")),
|
|
52
53
|
react_1.default.createElement("br", null),
|
|
53
54
|
react_1.default.createElement(react_ui_highlighter_component_metadata_bit_component_meta_1.MockedComponentWithMeta, null, "no highlighter"),
|
|
54
55
|
react_1.default.createElement("br", null),
|
|
55
56
|
react_1.default.createElement("br", null),
|
|
56
57
|
react_1.default.createElement("br", null),
|
|
57
58
|
react_1.default.createElement("div", { id: "someSubTree" },
|
|
58
|
-
react_1.default.createElement(react_ui_highlighter_component_metadata_bit_component_meta_1.MockedComponentWithMeta, null, "
|
|
59
|
+
react_1.default.createElement(react_ui_highlighter_component_metadata_bit_component_meta_1.MockedComponentWithMeta, null, "this will be highlighted"))));
|
|
59
60
|
};
|
|
60
|
-
exports.
|
|
61
|
-
const
|
|
62
|
-
return (react_1.default.createElement(
|
|
63
|
-
react_1.default.createElement("
|
|
64
|
-
|
|
61
|
+
exports.ChildrenHighlighterWithRule = ChildrenHighlighterWithRule;
|
|
62
|
+
const ChildrenHighlighterWithComponentRule = () => {
|
|
63
|
+
return (react_1.default.createElement(children_highlighter_1.ChildrenHighlighter, { componentRule: "teambit.design/ui/icon-button", style: { minWidth: 300 } },
|
|
64
|
+
react_1.default.createElement("div", null,
|
|
65
|
+
"component filter: ",
|
|
66
|
+
react_1.default.createElement("code", null, "\"teambit.design/ui/icon-button\"")),
|
|
65
67
|
react_1.default.createElement("br", null),
|
|
66
68
|
react_1.default.createElement(react_ui_highlighter_component_metadata_bit_component_meta_1.MockedComponentWithMeta, null, "no highlighter"),
|
|
67
69
|
react_1.default.createElement("br", null),
|
|
68
70
|
react_1.default.createElement("br", null),
|
|
69
71
|
react_1.default.createElement("br", null),
|
|
70
|
-
react_1.default.createElement(design_ui_icon_button_1.IconButton, null, "
|
|
72
|
+
react_1.default.createElement(design_ui_icon_button_1.IconButton, null, "this will be highlighted")));
|
|
71
73
|
};
|
|
72
|
-
exports.
|
|
74
|
+
exports.ChildrenHighlighterWithComponentRule = ChildrenHighlighterWithComponentRule;
|
|
73
75
|
// export const HighlightingAllElementsInTheEnterprisePage = () => {
|
|
74
76
|
// return (
|
|
75
|
-
// <
|
|
77
|
+
// <ChildrenHighlighter>
|
|
76
78
|
// <EnterpriseOffering style={{ height: 300 }} />
|
|
77
|
-
// </
|
|
79
|
+
// </ChildrenHighlighter>
|
|
78
80
|
// );
|
|
79
81
|
// };
|
|
80
|
-
//# sourceMappingURL=
|
|
82
|
+
//# sourceMappingURL=children-highlighter.composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children-highlighter.composition.js","sourceRoot":"","sources":["../../children-highlighter/children-highlighter.composition.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,sFAAsF;AACtF,oJAA8G;AAC9G,0EAA4D;AAC5D,8DAA2D;AAC3D,iEAA6D;AAEtD,MAAM,0BAA0B,GAAG,GAAG,EAAE;IAC7C,OAAO,CACL,8BAAC,0CAAmB,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;QACxD,8BAAC,oFAAuB,qBAAqC;QAC7D,yCAAM;QACN,yCAAM;QACN,yCAAM;QACN,8BAAC,kCAAU,iDAAoD,CAC3C,CACvB,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,0BAA0B,8BAUrC;AAEK,MAAM,mCAAmC,GAAG,GAAG,EAAE;IACtD,OAAO,CACL,8BAAC,0CAAmB,IAClB,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EACtD,OAAO,EAAC,gBAAgB,EACxB,YAAY,EAAC,MAAM,EACnB,aAAa,EAAC,eAAe;QAE7B,8BAAC,oFAAuB,qBAAqC;QAC7D,yCAAM;QACN,yCAAM;QACN,yCAAM;QACN,8BAAC,oFAAuB,oBAAoC,CACxC,CACvB,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,mCAAmC,uCAe9C;AAEK,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,OAAO,CACL,8BAAC,uCAAkB;QACjB,8BAAC,0CAAmB;;YAC8B,4CAAO,sBAAsB,CAAQ;YACrF,yCAAM;;YAEN,yCAAM;YACN,yCAAM;YACN,yCAAM;YACN,8BAAC,oFAAuB,qBAAqC;YAC7D,yCAAM;YACN,yCAAM;YACN,yCAAM;YACN,8BAAC,oFAAuB,oBAAoC,CACxC,CACH,CACtB,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,+BAA+B,mCAkB1C;AAEK,MAAM,2BAA2B,GAAG,GAAG,EAAE;IAC9C,OAAO,CACL,8BAAC,0CAAmB,IAAC,IAAI,EAAC,gBAAgB,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;QACjE;;YACkB,iEAA6B,CACzC;QACN,yCAAM;QACN,8BAAC,oFAAuB,yBAAyC;QACjE,yCAAM;QACN,yCAAM;QACN,yCAAM;QACN,uCAAK,EAAE,EAAC,aAAa;YACnB,8BAAC,oFAAuB,mCAAmD,CACvE,CACc,CACvB,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,2BAA2B,+BAgBtC;AAEK,MAAM,oCAAoC,GAAG,GAAG,EAAE;IACvD,OAAO,CACL,8BAAC,0CAAmB,IAAC,aAAa,EAAC,+BAA+B,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;QACzF;;YACoB,gFAA4C,CAC1D;QACN,yCAAM;QACN,8BAAC,oFAAuB,yBAAyC;QACjE,yCAAM;QACN,yCAAM;QACN,yCAAM;QACN,8BAAC,kCAAU,mCAAsC,CAC7B,CACvB,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,oCAAoC,wCAc/C;AAEF,oEAAoE;AACpE,aAAa;AACb,4BAA4B;AAC5B,uDAAuD;AACvD,6BAA6B;AAC7B,OAAO;AACP,KAAK"}
|
package/dist/{multi-highlighter/multi-highlighter.js → children-highlighter/children-highlighter.js}
RENAMED
|
@@ -14,12 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.ChildrenHighlighter = void 0;
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const
|
|
20
|
-
function
|
|
19
|
+
const hybrid_highlighter_1 = require("../hybrid-highlighter");
|
|
20
|
+
function ChildrenHighlighter(_a) {
|
|
21
21
|
var { watchMotion = false } = _a, props = __rest(_a, ["watchMotion"]);
|
|
22
|
-
return react_1.default.createElement(
|
|
22
|
+
return react_1.default.createElement(hybrid_highlighter_1.HybridHighlighter, Object.assign({}, props, { mode: 'allChildren', watchMotion: watchMotion }));
|
|
23
23
|
}
|
|
24
|
-
exports.
|
|
25
|
-
//# sourceMappingURL=
|
|
24
|
+
exports.ChildrenHighlighter = ChildrenHighlighter;
|
|
25
|
+
//# sourceMappingURL=children-highlighter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children-highlighter.js","sourceRoot":"","sources":["../../children-highlighter/children-highlighter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,8DAAkF;AAIlF,SAAgB,mBAAmB,CAAC,EAA2D;QAA3D,EAAE,WAAW,GAAG,KAAK,OAAsC,EAAjC,KAAK,cAA/B,eAAiC,CAAF;IACjE,OAAO,8BAAC,sCAAiB,oBAAK,KAAK,IAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,IAAI,CAAC;AACzF,CAAC;AAFD,kDAEC"}
|
|
File without changes
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const react_2 = require("@testing-library/react");
|
|
8
|
-
const
|
|
9
|
-
it('should not throw when rendering the
|
|
10
|
-
const { getByText } = (0, react_2.render)(react_1.default.createElement(
|
|
8
|
+
const children_highlighter_composition_1 = require("./children-highlighter.composition");
|
|
9
|
+
it('should not throw when rendering the children-highlighter', () => {
|
|
10
|
+
const { getByText } = (0, react_2.render)(react_1.default.createElement(children_highlighter_composition_1.ChildrenHighlighterPreview, null));
|
|
11
11
|
const rendered = getByText('hover here');
|
|
12
12
|
expect(rendered).toBeInstanceOf(HTMLElement);
|
|
13
13
|
});
|
|
@@ -19,4 +19,4 @@ it('should not throw when rendering the multi-highlighter', () => {
|
|
|
19
19
|
// const rendered = queryAllByText('input/button');
|
|
20
20
|
// expect(rendered).toHaveLength(2);
|
|
21
21
|
// });
|
|
22
|
-
//# sourceMappingURL=
|
|
22
|
+
//# sourceMappingURL=children-highlighter.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children-highlighter.spec.js","sourceRoot":"","sources":["../../children-highlighter/children-highlighter.spec.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,kDAAgD;AAChD,yFAAgF;AAEhF,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,cAAM,EAAC,8BAAC,6DAA0B,OAAG,CAAC,CAAC;IAE7D,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;IAEzC,MAAM,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEH,sFAAsF;AACtF,4EAA4E;AAC5E,oDAAoD;AAEpD,8BAA8B;AAC9B,sDAAsD;AAEtD,qDAAqD;AACrD,sCAAsC;AACtC,MAAM"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useChildrenHighlighter } from './use-children-highlighter';
|
|
2
|
+
export type { ChildrenHighlighterOptions } from './use-children-highlighter';
|
|
3
|
+
export { ChildrenHighlighter } from './children-highlighter';
|
|
4
|
+
export type { ChildrenHighlighterProps } from './children-highlighter';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChildrenHighlighter = exports.useChildrenHighlighter = void 0;
|
|
4
|
+
var use_children_highlighter_1 = require("./use-children-highlighter");
|
|
5
|
+
Object.defineProperty(exports, "useChildrenHighlighter", { enumerable: true, get: function () { return use_children_highlighter_1.useChildrenHighlighter; } });
|
|
6
|
+
var children_highlighter_1 = require("./children-highlighter");
|
|
7
|
+
Object.defineProperty(exports, "ChildrenHighlighter", { enumerable: true, get: function () { return children_highlighter_1.ChildrenHighlighter; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../children-highlighter/index.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA;AAG/B,+DAA6D;AAApD,2HAAA,mBAAmB,OAAA"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { HighlightTarget } from '../element-highlighter';
|
|
3
3
|
import { MatchRule, ComponentMatchRule } from '../rule-matcher';
|
|
4
|
-
declare type
|
|
4
|
+
export declare type ChildrenHighlighterOptions = {
|
|
5
5
|
onChange: (highlighterTargets: Record<string, HighlightTarget>) => void;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
scopeRef: RefObject<HTMLElement>;
|
|
8
8
|
scopeClass?: string;
|
|
9
9
|
/** filter highlighter targets by this query selector. (May be a more complex object in the future) */
|
|
10
10
|
rule?: MatchRule;
|
|
11
|
-
/** filter targets by this component match rule */
|
|
12
11
|
componentRule?: ComponentMatchRule;
|
|
13
12
|
};
|
|
14
|
-
export declare function
|
|
15
|
-
export {};
|
|
13
|
+
export declare function useChildrenHighlighter({ onChange, disabled, scopeRef, scopeClass: scopeSelector, rule, componentRule, }: ChildrenHighlighterOptions): void;
|
|
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.useChildrenHighlighter = void 0;
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const get_xpath_1 = __importDefault(require("get-xpath"));
|
|
9
9
|
const react_modules_dom_to_react_1 = require("@teambit/react.modules.dom-to-react");
|
|
10
10
|
const react_ui_highlighter_component_metadata_bit_component_meta_1 = require("@teambit/react.ui.highlighter.component-metadata.bit-component-meta");
|
|
11
11
|
const ignore_highlighter_1 = require("../ignore-highlighter");
|
|
12
12
|
const rule_matcher_1 = require("../rule-matcher");
|
|
13
|
-
function
|
|
13
|
+
function useChildrenHighlighter({ onChange, disabled, scopeRef, scopeClass: scopeSelector = '', rule, componentRule, }) {
|
|
14
14
|
(0, react_1.useEffect)(() => {
|
|
15
15
|
const nextTargets = {};
|
|
16
16
|
const scopeElement = scopeRef.current;
|
|
@@ -26,22 +26,19 @@ function useMultiHighlighter({ onChange, disabled, scopeRef, scopeClass: scopeSe
|
|
|
26
26
|
// deduplicate
|
|
27
27
|
const uniqueRoots = new Set(rootElements);
|
|
28
28
|
uniqueRoots.forEach((element) => {
|
|
29
|
-
|
|
30
|
-
if (!element || !(0, react_ui_highlighter_component_metadata_bit_component_meta_1.hasComponentMeta)(comp))
|
|
29
|
+
if (!element)
|
|
31
30
|
return;
|
|
32
|
-
const
|
|
33
|
-
|
|
31
|
+
const comps = (0, react_modules_dom_to_react_1.domToReacts)(element);
|
|
32
|
+
const componentsWithMeta = comps.filter((x) => (0, react_ui_highlighter_component_metadata_bit_component_meta_1.hasComponentMeta)(x) && (0, rule_matcher_1.componentRuleMatcher)({ meta: x[react_ui_highlighter_component_metadata_bit_component_meta_1.componentMetaField] }, componentRule));
|
|
33
|
+
if (componentsWithMeta.length < 1)
|
|
34
34
|
return;
|
|
35
35
|
const key = (0, get_xpath_1.default)(element);
|
|
36
|
-
|
|
37
|
-
const link = meta[react_ui_highlighter_component_metadata_bit_component_meta_1.componentMetaProperties.homepageUrl];
|
|
38
|
-
const local = meta[react_ui_highlighter_component_metadata_bit_component_meta_1.componentMetaProperties.isExported] === false;
|
|
39
|
-
nextTargets[key] = { element, id: compId, link, local };
|
|
36
|
+
nextTargets[key] = { element, components: componentsWithMeta };
|
|
40
37
|
});
|
|
41
38
|
onChange(nextTargets);
|
|
42
39
|
}, [disabled, scopeSelector]);
|
|
43
40
|
}
|
|
44
|
-
exports.
|
|
41
|
+
exports.useChildrenHighlighter = useChildrenHighlighter;
|
|
45
42
|
function targetsSelector(
|
|
46
43
|
/**
|
|
47
44
|
* the scope in which to consider the exclude selector.
|
|
@@ -50,4 +47,4 @@ function targetsSelector(
|
|
|
50
47
|
scopeSelector = ':scope') {
|
|
51
48
|
return `:not(${scopeSelector} ${ignore_highlighter_1.excludeHighlighterSelector}, ${scopeSelector} ${ignore_highlighter_1.excludeHighlighterSelector} *)`;
|
|
52
49
|
}
|
|
53
|
-
//# sourceMappingURL=use-
|
|
50
|
+
//# sourceMappingURL=use-children-highlighter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-children-highlighter.js","sourceRoot":"","sources":["../../children-highlighter/use-children-highlighter.tsx"],"names":[],"mappings":";;;;;;AAAA,iCAA6C;AAC7C,0DAAiC;AACjC,oFAAiF;AACjF,oJAI6E;AAE7E,8DAAmE;AACnE,kDAAmG;AAenG,SAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,EAAE,aAAa,GAAG,EAAE,EAC9B,IAAI,EACJ,aAAa,GACc;IAC3B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAoC,EAAE,CAAC;QACxD,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,YAAY,IAAI,QAAQ;YAAE,OAAO;QAEtC,wCAAwC;QACxC,IAAI,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAc,eAAe,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/G,uBAAuB;QACvB,IAAI,IAAI;YAAE,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,0BAAW,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC9E,yBAAyB;QACzB,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,0CAAa,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvE,cAAc;QACd,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAE1C,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,MAAM,KAAK,GAAG,IAAA,wCAAW,EAAC,OAAO,CAAC,CAAC;YACnC,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,6EAAgB,EAAC,CAAC,CAAC,IAAI,IAAA,mCAAoB,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,+EAAkB,CAAC,EAAE,EAAE,aAAa,CAAC,CACrE,CAAC;YAEhC,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO;YAE1C,MAAM,GAAG,GAAG,IAAA,mBAAQ,EAAC,OAAO,CAAC,CAAC;YAE9B,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,WAAW,CAAC,CAAC;IACxB,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;AAChC,CAAC;AAtCD,wDAsCC;AAED,SAAS,eAAe;AACtB;;;GAGG;AACH,aAAa,GAAG,QAAQ;IAExB,OAAO,QAAQ,aAAa,IAAI,+CAA0B,KAAK,aAAa,IAAI,+CAA0B,KAAK,CAAC;AAClH,CAAC"}
|
|
@@ -94,7 +94,7 @@ The Component Highlighter comes in a few different modes:
|
|
|
94
94
|
In addition to changing the `mode` prop, you can also use convenience exports from the same package:
|
|
95
95
|
|
|
96
96
|
```tsx
|
|
97
|
-
import {
|
|
97
|
+
import { ChildrenHighlighter, HoverHighlighter } from '@teambit/react.ui.component-highlighter';
|
|
98
98
|
|
|
99
99
|
function example() {
|
|
100
100
|
return (
|
|
@@ -103,9 +103,9 @@ function example() {
|
|
|
103
103
|
<App />
|
|
104
104
|
</HoverHighlighter>
|
|
105
105
|
|
|
106
|
-
<
|
|
106
|
+
<ChildrenHighlighter>
|
|
107
107
|
<App />
|
|
108
|
-
</
|
|
108
|
+
</ChildrenHighlighter>
|
|
109
109
|
</div>
|
|
110
110
|
);
|
|
111
111
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
+
import { HighlighterSize } from './element-highlighter';
|
|
2
3
|
declare type HighlightedElementProps = {
|
|
3
4
|
style?: CSSProperties;
|
|
4
5
|
targetStyle?: CSSProperties;
|
|
5
6
|
className?: string;
|
|
6
7
|
watchMotion?: boolean;
|
|
8
|
+
size?: HighlighterSize;
|
|
7
9
|
};
|
|
8
|
-
export declare const HighlightedElement: ({ style, targetStyle, watchMotion, className }: HighlightedElementProps) => JSX.Element;
|
|
10
|
+
export declare const HighlightedElement: ({ style, targetStyle, watchMotion, className, size }: HighlightedElementProps) => JSX.Element;
|
|
9
11
|
export declare const Customized: () => JSX.Element;
|
|
10
12
|
export declare const Sizes: () => JSX.Element;
|
|
11
13
|
export declare const MovingElement: () => JSX.Element;
|
|
@@ -20,21 +20,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.MovingElement = exports.Sizes = exports.Customized = exports.HighlightedElement = void 0;
|
|
23
|
+
const react_ui_highlighter_component_metadata_bit_component_meta_1 = require("@teambit/react.ui.highlighter.component-metadata.bit-component-meta");
|
|
23
24
|
const react_1 = __importStar(require("react"));
|
|
24
25
|
const element_highlighter_1 = require("./element-highlighter");
|
|
25
26
|
const mockTarget = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
components: [
|
|
28
|
+
{
|
|
29
|
+
[react_ui_highlighter_component_metadata_bit_component_meta_1.componentMetaField]: {
|
|
30
|
+
id: 'teambit.design/ui/icon-button@1.6.2',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
29
34
|
};
|
|
30
|
-
const HighlightedElement = ({ style, targetStyle, watchMotion, className }) => {
|
|
35
|
+
const HighlightedElement = ({ style, targetStyle, watchMotion, className, size }) => {
|
|
31
36
|
const [targetElement, setTargetElement] = (0, react_1.useState)(undefined);
|
|
32
37
|
const targetRef = (0, react_1.createRef)();
|
|
33
38
|
(0, react_1.useEffect)(() => setTargetElement(targetRef.current || undefined), [targetRef.current]);
|
|
34
39
|
const target = targetElement && Object.assign(Object.assign({}, mockTarget), { element: targetElement });
|
|
35
|
-
return (react_1.default.createElement("div", { className: className, style: { padding: '16px 16px
|
|
40
|
+
return (react_1.default.createElement("div", { className: className, style: { padding: '16px 16px 40px 16px', width: 300 } },
|
|
36
41
|
react_1.default.createElement("div", { ref: targetRef, style: Object.assign({ width: 100 }, targetStyle) }, "highlight target"),
|
|
37
|
-
target && react_1.default.createElement(element_highlighter_1.ElementHighlighter, { target: target, style: style, watchMotion: watchMotion, placement: "bottom" })));
|
|
42
|
+
target && (react_1.default.createElement(element_highlighter_1.ElementHighlighter, { target: target, style: style, watchMotion: watchMotion, placement: "bottom", size: size }))));
|
|
38
43
|
};
|
|
39
44
|
exports.HighlightedElement = HighlightedElement;
|
|
40
45
|
const Customized = () => {
|
|
@@ -46,7 +51,10 @@ const Customized = () => {
|
|
|
46
51
|
};
|
|
47
52
|
exports.Customized = Customized;
|
|
48
53
|
const Sizes = () => {
|
|
49
|
-
return react_1.default.createElement(
|
|
54
|
+
return (react_1.default.createElement("div", null,
|
|
55
|
+
react_1.default.createElement(exports.HighlightedElement, { size: "s" }),
|
|
56
|
+
react_1.default.createElement(exports.HighlightedElement, { size: "m" }),
|
|
57
|
+
react_1.default.createElement(exports.HighlightedElement, { size: "l" })));
|
|
50
58
|
};
|
|
51
59
|
exports.Sizes = Sizes;
|
|
52
60
|
const MovingElement = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-highlighter.compositions.js","sourceRoot":"","sources":["../../element-highlighter/element-highlighter.compositions.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA6E;AAC7E,+
|
|
1
|
+
{"version":3,"file":"element-highlighter.compositions.js","sourceRoot":"","sources":["../../element-highlighter/element-highlighter.compositions.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,oJAAyG;AACzG,+CAA6E;AAC7E,+DAA6F;AAE7F,MAAM,UAAU,GAA6B;IAC3C,UAAU,EAAE;QACV;YACE,CAAC,+EAAkB,CAAC,EAAE;gBACpB,EAAE,EAAE,qCAAqC;aAC1C;SACF;KACF;CACF,CAAC;AAUK,MAAM,kBAAkB,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAA2B,EAAE,EAAE;IAClH,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAA0B,SAAS,CAAC,CAAC;IACvF,MAAM,SAAS,GAAG,IAAA,iBAAS,GAAkB,CAAC;IAE9C,IAAA,iBAAS,EAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,aAAa,oCAAS,UAAU,KAAE,OAAO,EAAE,aAAa,GAAE,CAAC;IAE1E,OAAO,CACL,uCAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,GAAG,EAAE;QAC9E,uCAAK,GAAG,EAAE,SAAS,EAAE,KAAK,kBAAI,KAAK,EAAE,GAAG,IAAK,WAAW,wBAElD;QACL,MAAM,IAAI,CACT,8BAAC,wCAAkB,IAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,GAAI,CAC9G,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,kBAAkB,sBAiB7B;AAEK,MAAM,UAAU,GAAG,GAAG,EAAE;IAC7B,OAAO,CACL,8BAAC,0BAAkB,IACjB,KAAK,EACH;YACE,yBAAyB,EAAE,SAAS;YACpC,+BAA+B,EAAE,SAAS;YAC1C,gCAAgC,EAAE,SAAS;SAC3B,GAEpB,CACH,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,UAAU,cAYrB;AAEK,MAAM,KAAK,GAAG,GAAG,EAAE;IACxB,OAAO,CACL;QACE,8BAAC,0BAAkB,IAAC,IAAI,EAAC,GAAG,GAAG;QAC/B,8BAAC,0BAAkB,IAAC,IAAI,EAAC,GAAG,GAAG;QAC/B,8BAAC,0BAAkB,IAAC,IAAI,EAAC,GAAG,GAAG,CAC3B,CACP,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,KAAK,SAQhB;AAEK,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IAExC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1E,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,8BAAC,0BAAkB,IAAC,WAAW,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,GAAI,CAAC;AACrE,CAAC,CAAC;AATW,QAAA,aAAa,iBASxB"}
|