@teambit/react.ui.component-highlighter 0.0.447 → 0.0.451

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 (68) hide show
  1. package/bubble/bubble.module.scss +1 -1
  2. package/component-highlighter/hover-highlighter/hover-highlighter.compositions.tsx +21 -0
  3. package/{dist/component-highlighter/component-highlighter.module.scss → component-highlighter/hover-highlighter/hover-highlighter.module.scss} +0 -9
  4. package/component-highlighter/hover-highlighter/hover-highlighter.tsx +100 -0
  5. package/component-highlighter/hover-highlighter/index.ts +1 -0
  6. package/component-highlighter/index.ts +2 -2
  7. package/component-highlighter.docs.md +110 -0
  8. package/dist/bubble/bubble.module.scss +1 -1
  9. package/dist/component-highlighter/hover-highlighter/hover-highlighter.compositions.d.ts +1 -0
  10. package/dist/component-highlighter/hover-highlighter/hover-highlighter.compositions.js +37 -0
  11. package/dist/component-highlighter/hover-highlighter/hover-highlighter.compositions.js.map +1 -0
  12. package/dist/component-highlighter/hover-highlighter/hover-highlighter.d.ts +13 -0
  13. package/dist/component-highlighter/{component-highlighter.js → hover-highlighter/hover-highlighter.js} +22 -18
  14. package/dist/component-highlighter/hover-highlighter/hover-highlighter.js.map +1 -0
  15. package/{component-highlighter/component-highlighter.module.scss → dist/component-highlighter/hover-highlighter/hover-highlighter.module.scss} +0 -9
  16. package/dist/component-highlighter/hover-highlighter/index.d.ts +1 -0
  17. package/dist/component-highlighter/hover-highlighter/index.js +6 -0
  18. package/dist/component-highlighter/hover-highlighter/index.js.map +1 -0
  19. package/dist/component-highlighter/index.d.ts +2 -2
  20. package/dist/component-highlighter/index.js +3 -3
  21. package/dist/component-highlighter/index.js.map +1 -1
  22. package/dist/component-highlighter.docs.md +110 -0
  23. package/dist/element-highlighter/element-highlighter.compositions.d.ts +6 -0
  24. package/dist/element-highlighter/element-highlighter.compositions.js +56 -0
  25. package/dist/element-highlighter/element-highlighter.compositions.js.map +1 -0
  26. package/dist/element-highlighter/element-highlighter.d.ts +27 -0
  27. package/dist/element-highlighter/element-highlighter.js +32 -0
  28. package/dist/element-highlighter/element-highlighter.js.map +1 -0
  29. package/dist/element-highlighter/element-highlighter.module.scss +8 -0
  30. package/dist/element-highlighter/index.d.ts +2 -0
  31. package/dist/element-highlighter/index.js +6 -0
  32. package/dist/element-highlighter/index.js.map +1 -0
  33. package/dist/ignore-highlighter.d.ts +10 -0
  34. package/dist/ignore-highlighter.js +18 -0
  35. package/dist/ignore-highlighter.js.map +1 -0
  36. package/dist/index.d.ts +5 -2
  37. package/dist/index.js +7 -2
  38. package/dist/index.js.map +1 -1
  39. package/dist/label/component-label/component-label.js +3 -3
  40. package/dist/label/component-label/component-label.js.map +1 -1
  41. package/dist/label/default-label/default-label.js +1 -2
  42. package/dist/label/default-label/default-label.js.map +1 -1
  43. package/dist/label/default-label/default-label.module.scss +4 -0
  44. package/dist/label/index.d.ts +1 -1
  45. package/dist/label/label.d.ts +1 -0
  46. package/dist/label/label.js +3 -8
  47. package/dist/label/label.js.map +1 -1
  48. package/element-highlighter/element-highlighter.compositions.tsx +46 -0
  49. package/element-highlighter/element-highlighter.module.scss +8 -0
  50. package/element-highlighter/element-highlighter.tsx +60 -0
  51. package/element-highlighter/index.ts +2 -0
  52. package/ignore-highlighter.tsx +14 -0
  53. package/index.ts +7 -2
  54. package/label/component-label/component-label.tsx +2 -3
  55. package/label/default-label/default-label.module.scss +4 -0
  56. package/label/default-label/default-label.tsx +1 -2
  57. package/label/index.ts +1 -1
  58. package/label/label.tsx +13 -9
  59. package/package-tar/teambit-react.ui.component-highlighter-0.0.451.tgz +0 -0
  60. package/package.json +12 -12
  61. package/component-highlighter/component-highlighter.docs.md +0 -23
  62. package/component-highlighter/component-highlighter.tsx +0 -109
  63. package/dist/component-highlighter/component-highlighter.d.ts +0 -5
  64. package/dist/component-highlighter/component-highlighter.docs.md +0 -23
  65. package/dist/component-highlighter/component-highlighter.js.map +0 -1
  66. package/dist/label/label.module.scss +0 -3
  67. package/label/label.module.scss +0 -3
  68. package/package-tar/teambit-react.ui.component-highlighter-0.0.447.tgz +0 -0
@@ -1,23 +0,0 @@
1
- ---
2
- description: Highlights Bit Components and links to their Bit scope
3
- labels: ['component', 'highlight', 'react']
4
- ---
5
-
6
- import {ComponentHighlighter} from './component-highlighter'
7
- import {useEffect} from 'react';
8
-
9
- Highlights React components in web pages and add links to their Bit scope and component page.
10
-
11
- <img style={{border: '1px solid rgb(212, 212, 212', borderRadius: 6, maxWidth: 800}} src="https://storage.googleapis.com/docs-images/component_highlighter.png"></img>
12
-
13
- ## How to use?
14
-
15
- Invoke the `ComponentHighlighter()` to start highlighting components.
16
-
17
- ```ts
18
- import { ComponentHighlighter } from '@teambit/react.ui.component-highlighter';
19
-
20
- // 'options' are optional.
21
- ComponentHighlighter({ borderColor: 'red' });
22
- ReactDOM.render(App);
23
- ```
@@ -1,109 +0,0 @@
1
- import React, { useState, useCallback, useEffect } from 'react';
2
- import classnames from 'classnames';
3
- import { domToReact, toRootElement } from '@teambit/react.modules.dom-to-react';
4
- import { HoverSelector } from '@teambit/react.ui.hover-selector';
5
- import { useDebouncedCallback } from 'use-debounce';
6
- import { Frame } from '../frame';
7
- import { Label, LabelContainer } from '../label';
8
- import { hasComponentMeta } from './bit-react-component';
9
-
10
- import styles from './component-highlighter.module.scss';
11
-
12
- type HighlightTarget = {
13
- id?: string;
14
- element: HTMLElement;
15
- /** e.g. 'https://bit.dev/teambit/base-ui/elements/dots-loader', */
16
- link?: string;
17
- /** e.g. 'https://bit.dev/teambit/base-ui' */
18
- scopeLink?: string;
19
- /** use full production url, or local workspace url */
20
- local?: boolean;
21
- };
22
-
23
- export interface ComponentHighlightProps extends React.HTMLAttributes<HTMLDivElement> {
24
- disabled?: boolean;
25
- }
26
-
27
- export function ComponentHighlighter({ children, disabled, ...rest }: ComponentHighlightProps) {
28
- const [target, setTarget] = useState<HighlightTarget | undefined>();
29
-
30
- const _handleElement = useCallback((element: HTMLElement | null) => {
31
- if (!element || element?.hasAttribute('data-nullify-component-highlight')) {
32
- setTarget(undefined);
33
- return;
34
- }
35
-
36
- const result = bubbleToBitComponent(element, (elem) => !elem.hasAttribute('data-ignore-component-highlight'));
37
- if (!result) return;
38
-
39
- setTarget({
40
- element: result.element,
41
- id: result.meta.id,
42
- scopeLink: undefined,
43
- link: result.meta.homepage,
44
- local: result.meta.exported === false,
45
- });
46
- }, []);
47
-
48
- const handleElement = useDebouncedCallback(_handleElement, target ? 80 : 0);
49
-
50
- useEffect(() => {
51
- if (disabled) {
52
- setTarget(undefined);
53
- }
54
- }, [disabled]);
55
-
56
- return (
57
- <HoverSelector
58
- {...rest}
59
- className={classnames(styles.highlighter, !disabled && styles.active)}
60
- onElementChange={handleElement}
61
- disabled={disabled}
62
- data-nullify-component-highlight
63
- >
64
- {children}
65
- {target && (
66
- <>
67
- <Frame targetRef={target.element} data-ignore-component-highlight />
68
- {target.id && (
69
- <LabelContainer
70
- className={styles.label}
71
- targetRef={target.element}
72
- placement="top"
73
- data-ignore-component-highlight
74
- >
75
- <Label
76
- componentId={target.id}
77
- link={target.link}
78
- scopeLink={target.scopeLink}
79
- local={target.local}
80
- data-ignore-component-highlight
81
- />
82
- </LabelContainer>
83
- )}
84
- </>
85
- )}
86
- </HoverSelector>
87
- );
88
- }
89
-
90
- function bubbleToBitComponent(element: HTMLElement | null, filter?: (elem: Element) => boolean) {
91
- for (let current = element; current; current = current.parentElement) {
92
- current = toRootElement(current);
93
- if (!current || filter?.(current) === false) return undefined;
94
-
95
- const component = domToReact(current);
96
-
97
- if (hasComponentMeta(component)) {
98
- const meta = component.__bit_component;
99
-
100
- return {
101
- element: current,
102
- component,
103
- meta,
104
- };
105
- }
106
- }
107
-
108
- return undefined;
109
- }
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- export interface ComponentHighlightProps extends React.HTMLAttributes<HTMLDivElement> {
3
- disabled?: boolean;
4
- }
5
- export declare function ComponentHighlighter({ children, disabled, ...rest }: ComponentHighlightProps): JSX.Element;
@@ -1,23 +0,0 @@
1
- ---
2
- description: Highlights Bit Components and links to their Bit scope
3
- labels: ['component', 'highlight', 'react']
4
- ---
5
-
6
- import {ComponentHighlighter} from './component-highlighter'
7
- import {useEffect} from 'react';
8
-
9
- Highlights React components in web pages and add links to their Bit scope and component page.
10
-
11
- <img style={{border: '1px solid rgb(212, 212, 212', borderRadius: 6, maxWidth: 800}} src="https://storage.googleapis.com/docs-images/component_highlighter.png"></img>
12
-
13
- ## How to use?
14
-
15
- Invoke the `ComponentHighlighter()` to start highlighting components.
16
-
17
- ```ts
18
- import { ComponentHighlighter } from '@teambit/react.ui.component-highlighter';
19
-
20
- // 'options' are optional.
21
- ComponentHighlighter({ borderColor: 'red' });
22
- ReactDOM.render(App);
23
- ```
@@ -1 +0,0 @@
1
- {"version":3,"file":"component-highlighter.js","sourceRoot":"","sources":["../../component-highlighter/component-highlighter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgE;AAChE,4DAAoC;AACpC,oFAAgF;AAChF,8EAAiE;AACjE,+CAAoD;AACpD,oCAAiC;AACjC,oCAAiD;AACjD,+DAAyD;AAEzD,4GAAyD;AAiBzD,SAAgB,oBAAoB,CAAC,EAAwD;QAAxD,EAAE,QAAQ,EAAE,QAAQ,OAAoC,EAA/B,IAAI,cAA7B,wBAA+B,CAAF;IAChE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,GAA+B,CAAC;IAEpE,MAAM,cAAc,GAAG,IAAA,mBAAW,EAAC,CAAC,OAA2B,EAAE,EAAE;QACjE,IAAI,CAAC,OAAO,KAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC,kCAAkC,CAAC,CAAA,EAAE;YACzE,SAAS,CAAC,SAAS,CAAC,CAAC;YACrB,OAAO;SACR;QAED,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC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