@teambit/react.ui.component-highlighter 0.0.492 → 0.0.496
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} +41 -19
- 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} +18 -14
- package/component-highlighter.docs.md +13 -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} +37 -20
- 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} +4 -4
- package/dist/{multi-highlighter/use-multi-highlighter.js → children-highlighter/use-children-highlighter.js} +10 -11
- package/dist/children-highlighter/use-children-highlighter.js.map +1 -0
- package/dist/component-highlighter.docs.md +13 -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/element-highlighter.module.scss +2 -5
- package/dist/element-highlighter/index.d.ts +1 -1
- package/dist/hover-highlighter/hover-highlighter.compositions.js +1 -1
- package/dist/hover-highlighter/hover-highlighter.compositions.js.map +1 -1
- package/dist/hover-highlighter/hover-highlighter.d.ts +1 -1
- 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 +5 -2
- package/dist/hover-highlighter/use-hover-highlighter.js +13 -15
- package/dist/hover-highlighter/use-hover-highlighter.js.map +1 -1
- package/dist/{hybrid-highligher → hybrid-highlighter}/hybrid-highlighter.d.ts +6 -3
- package/dist/{hybrid-highligher → hybrid-highlighter}/hybrid-highlighter.js +6 -4
- 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 +49 -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 +6 -0
- package/dist/rule-matcher.js +20 -2
- 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.module.scss +2 -5
- package/element-highlighter/element-highlighter.tsx +11 -16
- package/element-highlighter/index.ts +7 -1
- package/hover-highlighter/hover-highlighter.compositions.tsx +1 -1
- package/hover-highlighter/hover-highlighter.tsx +1 -1
- package/hover-highlighter/use-hover-highlighter.tsx +36 -19
- package/{hybrid-highligher → hybrid-highlighter}/hybrid-highlighter.tsx +18 -4
- package/{hybrid-highligher → hybrid-highlighter}/index.ts +0 -0
- package/index.ts +4 -4
- package/label/component-strip.module.scss +49 -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.496.tgz +0 -0
- package/package.json +15 -15
- package/rule-matcher.tsx +27 -0
- package/tsconfig.json +2 -1
- 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 -7
- 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 -9
- 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 -6
- 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 -5
- 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 -4
- package/dist/multi-highlighter/multi-highlighter.composition.js.map +0 -1
- package/dist/multi-highlighter/multi-highlighter.d.ts +0 -3
- 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.492.tgz +0 -0
package/dist/label/label.js
CHANGED
|
@@ -29,36 +29,29 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
29
29
|
}
|
|
30
30
|
return t;
|
|
31
31
|
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
32
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.Label =
|
|
36
|
+
exports.Label = void 0;
|
|
34
37
|
const react_1 = __importStar(require("react"));
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
require("
|
|
38
|
-
const
|
|
39
|
-
const component_label_1 = require("./component-label");
|
|
40
|
-
const use_animation_frame_1 = require("../use-animation-frame");
|
|
41
|
-
// TODO - replace this with TippyJS, when it supports a `targetElement={targetRef.current}` prop
|
|
42
|
-
function LabelContainer(_a) {
|
|
43
|
-
var { targetRef, offset, placement, flip = true, watchMotion, className } = _a, rest = __rest(_a, ["targetRef", "offset", "placement", "flip", "watchMotion", "className"]);
|
|
44
|
-
const [sourceRef, setSourceRef] = (0, react_1.useState)(null);
|
|
45
|
-
const modifiers = (0, react_1.useMemo)(() => [{ name: 'offset', options: { offset } }], [flip, offset]);
|
|
46
|
-
const { styles, attributes, update } = (0, react_popper_1.usePopper)(targetRef, sourceRef, {
|
|
47
|
-
modifiers,
|
|
48
|
-
placement,
|
|
49
|
-
});
|
|
50
|
-
(0, use_animation_frame_1.useAnimationFrame)(!!watchMotion && update);
|
|
51
|
-
if (!targetRef)
|
|
52
|
-
return null;
|
|
53
|
-
return react_1.default.createElement("div", Object.assign({}, rest, { ref: setSourceRef, className: className, style: styles.popper }, attributes.popper));
|
|
54
|
-
}
|
|
55
|
-
exports.LabelContainer = LabelContainer;
|
|
38
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
39
|
+
const label_module_scss_1 = __importDefault(require("./label.module.scss"));
|
|
40
|
+
const component_strip_1 = require("./component-strip");
|
|
41
|
+
const other_components_1 = require("./other-components");
|
|
56
42
|
function Label(_a) {
|
|
57
|
-
var {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
43
|
+
var { components, size } = _a, props = __rest(_a, ["components", "size"]);
|
|
44
|
+
const [showMore, setShowMore] = (0, react_1.useState)(false);
|
|
45
|
+
const last = components.slice(-1).pop();
|
|
46
|
+
if (!last)
|
|
47
|
+
return null;
|
|
48
|
+
const hasMore = components.length > 1;
|
|
49
|
+
// reset when switching targets
|
|
50
|
+
(0, react_1.useEffect)(() => {
|
|
51
|
+
setShowMore(false);
|
|
52
|
+
}, [components]);
|
|
53
|
+
return (react_1.default.createElement(other_components_1.OtherComponentsPopper, { components: components, visible: showMore, placement: "bottom-start", size: size },
|
|
54
|
+
react_1.default.createElement(component_strip_1.ComponentStrip, Object.assign({}, props, { component: last, size: size }), hasMore && (react_1.default.createElement("span", { className: (0, classnames_1.default)(label_module_scss_1.default.othersTooltip, showMore && label_module_scss_1.default.active), onClick: () => setShowMore((x) => !x) })))));
|
|
62
55
|
}
|
|
63
56
|
exports.Label = Label;
|
|
64
57
|
//# sourceMappingURL=label.js.map
|
package/dist/label/label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../label/label.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../label/label.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAmD;AACnD,4DAAoC;AAGpC,4EAAyC;AACzC,uDAAuE;AACvE,yDAA2D;AAQ3D,SAAgB,KAAK,CAAC,EAA0C;QAA1C,EAAE,UAAU,EAAE,IAAI,OAAwB,EAAnB,KAAK,cAA5B,sBAA8B,CAAF;IAChD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACxC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IAEtC,+BAA+B;IAC/B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,8BAAC,wCAAqB,IAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,cAAc,EAAC,IAAI,EAAE,IAAI;QACnG,8BAAC,gCAAc,oBAAK,KAAK,IAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KACnD,OAAO,IAAI,CACV,wCACE,SAAS,EAAE,IAAA,oBAAU,EAAC,2BAAM,CAAC,aAAa,EAAE,QAAQ,IAAI,2BAAM,CAAC,MAAM,CAAC,EACtE,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GACrC,CACH,CACc,CACK,CACzB,CAAC;AACJ,CAAC;AAxBD,sBAwBC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.othersContainer {
|
|
2
|
+
> * {
|
|
3
|
+
margin-bottom: 8px;
|
|
4
|
+
|
|
5
|
+
&:last-child {
|
|
6
|
+
margin-bottom: unset;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.othersTooltip {
|
|
12
|
+
user-select: none;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
|
|
15
|
+
&::before {
|
|
16
|
+
display: inline-block;
|
|
17
|
+
transition: transform 300ms;
|
|
18
|
+
content: '▾';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.active::before {
|
|
22
|
+
transform: rotate(-180deg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calcComponentLink = void 0;
|
|
7
|
+
const url_join_1 = __importDefault(require("url-join"));
|
|
8
|
+
const component_modules_component_url_1 = require("@teambit/component.modules.component-url");
|
|
9
|
+
function calcComponentLink(id, exported) {
|
|
10
|
+
if (!id)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (exported)
|
|
13
|
+
return component_modules_component_url_1.ComponentUrl.toUrl(id);
|
|
14
|
+
return (0, url_join_1.default)('/', id.fullName);
|
|
15
|
+
}
|
|
16
|
+
exports.calcComponentLink = calcComponentLink;
|
|
17
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../label/links.tsx"],"names":[],"mappings":";;;;;;AAAA,wDAA+B;AAE/B,8FAAwE;AAExE,SAAgB,iBAAiB,CAAC,EAA2B,EAAE,QAA6B;IAC1F,IAAI,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC;IAC1B,IAAI,QAAQ;QAAE,OAAO,8CAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5C,OAAO,IAAA,kBAAO,EAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC;AAJD,8CAIC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TippyProps } from '@tippyjs/react/headless';
|
|
2
|
+
import { ComponentMetaHolder } from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
3
|
+
import { ComponentStripSize } from './component-strip';
|
|
4
|
+
export declare type OtherComponentsProps = {
|
|
5
|
+
components: ComponentMetaHolder[];
|
|
6
|
+
size?: ComponentStripSize;
|
|
7
|
+
start?: number;
|
|
8
|
+
end?: number;
|
|
9
|
+
} & TippyProps;
|
|
10
|
+
export declare function OtherComponentsPopper({ components, children, start, end, size, placement, interactive, ...tippyProps }: OtherComponentsProps): JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.OtherComponentsPopper = void 0;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const headless_1 = __importDefault(require("@tippyjs/react/headless"));
|
|
20
|
+
const component_strip_1 = require("./component-strip");
|
|
21
|
+
const label_module_scss_1 = __importDefault(require("./label.module.scss"));
|
|
22
|
+
// a popper ("tooltip") that shows the additional React Components related to this dom element
|
|
23
|
+
function OtherComponentsPopper(_a) {
|
|
24
|
+
var { components, children, start, end = -1, size, placement = 'bottom', interactive = true } = _a, tippyProps = __rest(_a, ["components", "children", "start", "end", "size", "placement", "interactive"]);
|
|
25
|
+
const content = (react_1.default.createElement(react_1.default.Fragment, null, components
|
|
26
|
+
.slice(start, end)
|
|
27
|
+
.reverse()
|
|
28
|
+
.map((comp, idx) => (react_1.default.createElement(component_strip_1.ComponentStrip, { key: idx, component: comp, size: size })))));
|
|
29
|
+
return (react_1.default.createElement(headless_1.default, Object.assign({ placement: placement, interactive: interactive }, tippyProps, {
|
|
30
|
+
// second parameter "content" is always undefined, use content inline
|
|
31
|
+
// https://github.com/atomiks/tippyjs-react/issues/341
|
|
32
|
+
render: (attrs) => (react_1.default.createElement("div", Object.assign({}, attrs, { className: label_module_scss_1.default.othersContainer }), content)) }), children));
|
|
33
|
+
}
|
|
34
|
+
exports.OtherComponentsPopper = OtherComponentsPopper;
|
|
35
|
+
//# sourceMappingURL=other-components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"other-components.js","sourceRoot":"","sources":["../../label/other-components.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,uEAA4D;AAG5D,uDAAuE;AACvE,4EAAyC;AASzC,8FAA8F;AAC9F,SAAgB,qBAAqB,CAAC,EASf;QATe,EACpC,UAAU,EACV,QAAQ,EACR,KAAK,EACL,GAAG,GAAG,CAAC,CAAC,EACR,IAAI,EACJ,SAAS,GAAG,QAAQ,EACpB,WAAW,GAAG,IAAI,OAEG,EADlB,UAAU,cARuB,8EASrC,CADc;IAEb,MAAM,OAAO,GAAG,CACd,8DACG,UAAU;SACR,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC;SACjB,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAClB,8BAAC,gCAAc,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAI,CAC1D,CAAC,CACH,CACJ,CAAC;IAEF,OAAO,CACL,8BAAC,kBAAK,kBACJ,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,IACpB,UAAU;QACd,qEAAqE;QACrE,sDAAsD;QACtD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CACjB,uDAAS,KAAK,IAAE,SAAS,EAAE,2BAAM,CAAC,eAAe,KAC9C,OAAO,CACJ,CACP,KAEA,QAAQ,CACH,CACT,CAAC;AACJ,CAAC;AArCD,sDAqCC"}
|
package/dist/rule-matcher.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import { ComponentMeta } from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
1
2
|
export declare type MatchRule = undefined | string | ((element: HTMLElement) => boolean);
|
|
3
|
+
export declare type ComponentMatchRule = undefined | string | string[] | ((target: ComponentMatchTarget) => boolean);
|
|
2
4
|
export declare function ruleMatcher(element: HTMLElement, rule: MatchRule): boolean;
|
|
5
|
+
export declare type ComponentMatchTarget = {
|
|
6
|
+
meta: ComponentMeta;
|
|
7
|
+
};
|
|
8
|
+
export declare function componentRuleMatcher(target: ComponentMatchTarget, rule: ComponentMatchRule): boolean;
|
package/dist/rule-matcher.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// in the future, we will add more options here, like include / exclude objects.
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ruleMatcher = void 0;
|
|
3
|
+
exports.componentRuleMatcher = exports.ruleMatcher = void 0;
|
|
4
|
+
// in the future, we will add more options here, like include / exclude objects.
|
|
5
|
+
const component_id_1 = require("@teambit/component-id");
|
|
5
6
|
function ruleMatcher(element, rule) {
|
|
6
7
|
if (typeof rule === 'string') {
|
|
7
8
|
return element.matches(rule);
|
|
@@ -12,4 +13,21 @@ function ruleMatcher(element, rule) {
|
|
|
12
13
|
return true;
|
|
13
14
|
}
|
|
14
15
|
exports.ruleMatcher = ruleMatcher;
|
|
16
|
+
function componentRuleMatcher(target, rule) {
|
|
17
|
+
if (typeof rule === 'string') {
|
|
18
|
+
const targetCmpId = component_id_1.ComponentID.tryFromString(target.meta.id);
|
|
19
|
+
const ruleCmpId = component_id_1.ComponentID.tryFromString(rule);
|
|
20
|
+
return component_id_1.ComponentID.isEqual(ruleCmpId, targetCmpId, { ignoreVersion: true });
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(rule)) {
|
|
23
|
+
const targetCmpId = component_id_1.ComponentID.tryFromString(target.meta.id);
|
|
24
|
+
const ruleCmpIds = rule.map((x) => component_id_1.ComponentID.tryFromString(x));
|
|
25
|
+
return ruleCmpIds.some((cmdId) => component_id_1.ComponentID.isEqual(targetCmpId, cmdId, { ignoreVersion: true }));
|
|
26
|
+
}
|
|
27
|
+
if (typeof rule === 'function') {
|
|
28
|
+
return rule(target);
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
exports.componentRuleMatcher = componentRuleMatcher;
|
|
15
33
|
//# sourceMappingURL=rule-matcher.js.map
|
package/dist/rule-matcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-matcher.js","sourceRoot":"","sources":["../rule-matcher.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule-matcher.js","sourceRoot":"","sources":["../rule-matcher.tsx"],"names":[],"mappings":";;;AAAA,gFAAgF;AAChF,wDAAoD;AAMpD,SAAgB,WAAW,CAAC,OAAoB,EAAE,IAAe;IAC/D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9B;IAED,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;KACtB;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAVD,kCAUC;AAID,SAAgB,oBAAoB,CAAC,MAA4B,EAAE,IAAwB;IACzF,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,WAAW,GAAG,0BAAW,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9D,MAAM,SAAS,GAAG,0BAAW,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAElD,OAAO,0BAAW,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;KAC7E;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,MAAM,WAAW,GAAG,0BAAW,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,0BAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,0BAAW,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;KACrG;IAED,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;KACrB;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AApBD,oDAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useAnimationFrame(cb?: false | null | (() => any), deps?: []): void;
|
|
1
|
+
export declare function useAnimationFrame(cb?: false | null | (() => any), deps?: any[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-animation-frame.js","sourceRoot":"","sources":["../use-animation-frame.tsx"],"names":[],"mappings":";;;AAAA,iCAAkC;AAElC,sCAAsC;AAEtC,SAAgB,iBAAiB,CAAC,EAA+B,EAAE,
|
|
1
|
+
{"version":3,"file":"use-animation-frame.js","sourceRoot":"","sources":["../use-animation-frame.tsx"],"names":[],"mappings":";;;AAAA,iCAAkC;AAElC,sCAAsC;AAEtC,SAAgB,iBAAiB,CAAC,EAA+B,EAAE,OAAc,EAAE;IACjF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,EAAE;YAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;QAEzB,IAAI,gBAAgB,GAAG,CAAC,CAAC,CAAC;QAC1B,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,EAAE,EAAE,CAAC;YACL,gBAAgB,GAAG,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC,CAAC;QACF,OAAO,EAAE,CAAC;QAEV,OAAO,GAAG,EAAE;YACV,IAAI,gBAAgB,GAAG,CAAC,CAAC;gBAAE,MAAM,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;QAC3E,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AACpB,CAAC;AAfD,8CAeC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { componentMetaField } from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
1
2
|
import React, { useState, createRef, useEffect, CSSProperties } from 'react';
|
|
2
|
-
import { ElementHighlighter, HighlightTarget } from './element-highlighter';
|
|
3
|
+
import { ElementHighlighter, HighlighterSize, HighlightTarget } from './element-highlighter';
|
|
3
4
|
|
|
4
5
|
const mockTarget: Partial<HighlightTarget> = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
components: [
|
|
7
|
+
{
|
|
8
|
+
[componentMetaField]: {
|
|
9
|
+
id: 'teambit.design/ui/icon-button@1.6.2',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
],
|
|
8
13
|
};
|
|
9
14
|
|
|
10
15
|
type HighlightedElementProps = {
|
|
@@ -12,9 +17,10 @@ type HighlightedElementProps = {
|
|
|
12
17
|
targetStyle?: CSSProperties;
|
|
13
18
|
className?: string;
|
|
14
19
|
watchMotion?: boolean;
|
|
20
|
+
size?: HighlighterSize;
|
|
15
21
|
};
|
|
16
22
|
|
|
17
|
-
export const HighlightedElement = ({ style, targetStyle, watchMotion, className }: HighlightedElementProps) => {
|
|
23
|
+
export const HighlightedElement = ({ style, targetStyle, watchMotion, className, size }: HighlightedElementProps) => {
|
|
18
24
|
const [targetElement, setTargetElement] = useState<HTMLElement | undefined>(undefined);
|
|
19
25
|
const targetRef = createRef<HTMLDivElement>();
|
|
20
26
|
|
|
@@ -22,11 +28,13 @@ export const HighlightedElement = ({ style, targetStyle, watchMotion, className
|
|
|
22
28
|
const target = targetElement && { ...mockTarget, element: targetElement };
|
|
23
29
|
|
|
24
30
|
return (
|
|
25
|
-
<div className={className} style={{ padding: '16px 16px
|
|
31
|
+
<div className={className} style={{ padding: '16px 16px 40px 16px', width: 300, fontFamily: 'sans-serif' }}>
|
|
26
32
|
<div ref={targetRef} style={{ width: 100, ...targetStyle }}>
|
|
27
33
|
highlight target
|
|
28
34
|
</div>
|
|
29
|
-
{target &&
|
|
35
|
+
{target && (
|
|
36
|
+
<ElementHighlighter target={target} style={style} watchMotion={watchMotion} placement="bottom" size={size} />
|
|
37
|
+
)}
|
|
30
38
|
</div>
|
|
31
39
|
);
|
|
32
40
|
};
|
|
@@ -46,7 +54,13 @@ export const Customized = () => {
|
|
|
46
54
|
};
|
|
47
55
|
|
|
48
56
|
export const Sizes = () => {
|
|
49
|
-
return
|
|
57
|
+
return (
|
|
58
|
+
<div>
|
|
59
|
+
<HighlightedElement style={{ fontSize: 10 }} />
|
|
60
|
+
<HighlightedElement style={{ fontSize: 14 }} />
|
|
61
|
+
<HighlightedElement style={{ fontSize: 18 }} />
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
50
64
|
};
|
|
51
65
|
|
|
52
66
|
export const MovingElement = () => {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
@import '~@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
|
2
2
|
|
|
3
|
-
.container {
|
|
4
|
-
font-size: 12px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
3
|
.label {
|
|
8
|
-
|
|
4
|
+
// space between the label and the target
|
|
5
|
+
// keep this space so users can move their cursor in this space.
|
|
9
6
|
padding: 8px;
|
|
10
7
|
}
|
|
11
8
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
+
import { ComponentMetaHolder } from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
3
4
|
import { Frame } from '../frame';
|
|
4
|
-
import { Label, LabelContainer, Placement } from '../label';
|
|
5
|
+
import { Label, LabelContainer, Placement, LabelSize } from '../label';
|
|
5
6
|
import { excludeHighlighterAtt } from '../ignore-highlighter';
|
|
6
7
|
import styles from './element-highlighter.module.scss';
|
|
7
8
|
|
|
9
|
+
export type HighlighterSize = LabelSize;
|
|
10
|
+
|
|
8
11
|
export interface ElementHighlighterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
12
|
/** target element to highlight */
|
|
10
13
|
target: HighlightTarget;
|
|
@@ -14,19 +17,16 @@ export interface ElementHighlighterProps extends React.HTMLAttributes<HTMLDivEle
|
|
|
14
17
|
classes?: HighlightClasses;
|
|
15
18
|
/** continually update highlighter to match moving elements */
|
|
16
19
|
watchMotion?: boolean;
|
|
20
|
+
size?: HighlighterSize;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
export { Placement };
|
|
20
24
|
|
|
21
25
|
export type HighlightTarget = {
|
|
22
|
-
|
|
26
|
+
/** element to show the highlight at */
|
|
23
27
|
element: HTMLElement;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
/** e.g. 'https://bit.dev/teambit/base-ui' */
|
|
27
|
-
scopeLink?: string;
|
|
28
|
-
/** use full production url, or local workspace url */
|
|
29
|
-
local?: boolean;
|
|
28
|
+
/** components with metadata to show in the label */
|
|
29
|
+
components?: ComponentMetaHolder[];
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export type HighlightClasses = {
|
|
@@ -41,6 +41,7 @@ export function ElementHighlighter({
|
|
|
41
41
|
watchMotion = true,
|
|
42
42
|
className,
|
|
43
43
|
classes,
|
|
44
|
+
size,
|
|
44
45
|
...props
|
|
45
46
|
}: ElementHighlighterProps) {
|
|
46
47
|
return (
|
|
@@ -51,20 +52,14 @@ export function ElementHighlighter({
|
|
|
51
52
|
watchMotion={watchMotion}
|
|
52
53
|
/>
|
|
53
54
|
|
|
54
|
-
{target.
|
|
55
|
+
{target.components && (
|
|
55
56
|
<LabelContainer
|
|
56
57
|
className={styles.label}
|
|
57
58
|
targetRef={target.element}
|
|
58
59
|
placement={placement}
|
|
59
60
|
watchMotion={watchMotion}
|
|
60
61
|
>
|
|
61
|
-
<Label
|
|
62
|
-
componentId={target.id}
|
|
63
|
-
link={target.link}
|
|
64
|
-
scopeLink={target.scopeLink}
|
|
65
|
-
local={target.local}
|
|
66
|
-
className={classes?.label}
|
|
67
|
-
/>
|
|
62
|
+
<Label components={target.components} className={classes?.label} size={size} />
|
|
68
63
|
</LabelContainer>
|
|
69
64
|
)}
|
|
70
65
|
</div>
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export { ElementHighlighter } from './element-highlighter';
|
|
2
|
-
export type {
|
|
2
|
+
export type {
|
|
3
|
+
ElementHighlighterProps,
|
|
4
|
+
HighlightTarget,
|
|
5
|
+
Placement,
|
|
6
|
+
HighlightClasses,
|
|
7
|
+
HighlighterSize,
|
|
8
|
+
} from './element-highlighter';
|
|
@@ -6,7 +6,7 @@ export const ShowWhenHovering = () => {
|
|
|
6
6
|
const [disabled, setDisabled] = useState<boolean>(false);
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
|
-
<div style={{ padding: '16px 50px 32px 16px', minWidth: 300 }}>
|
|
9
|
+
<div style={{ padding: '16px 50px 32px 16px', minWidth: 300, fontFamily: 'sans-serif' }}>
|
|
10
10
|
<HoverHighlighter style={{ padding: 16 }} disabled={disabled}>
|
|
11
11
|
<div>
|
|
12
12
|
<br />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { HybridHighlighter, HybridHighlighterProps } from '../hybrid-
|
|
2
|
+
import { HybridHighlighter, HybridHighlighterProps } from '../hybrid-highlighter';
|
|
3
3
|
|
|
4
4
|
export type HoverHighlighterProps = Omit<HybridHighlighterProps, 'mode'>;
|
|
5
5
|
|
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { useDebouncedCallback } from 'use-debounce';
|
|
3
|
-
import {
|
|
3
|
+
import { domToReacts, toRootElement } from '@teambit/react.modules.dom-to-react';
|
|
4
4
|
import { useHoverSelection } from '@teambit/react.ui.hover-selector';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
componentMetaField,
|
|
7
|
+
hasComponentMeta,
|
|
8
|
+
ReactComponentMetaHolder,
|
|
9
|
+
} from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
6
10
|
|
|
7
11
|
import { excludeHighlighterSelector } from '../ignore-highlighter';
|
|
8
12
|
import { HighlightTarget } from '../element-highlighter';
|
|
9
|
-
import { ruleMatcher, MatchRule } from '../rule-matcher';
|
|
13
|
+
import { ruleMatcher, MatchRule, ComponentMatchRule, componentRuleMatcher } from '../rule-matcher';
|
|
10
14
|
|
|
11
15
|
export type useHoverHighlighterOptions = {
|
|
12
16
|
debounceDuration: number;
|
|
13
17
|
scopeClass: string;
|
|
14
18
|
disabled?: boolean;
|
|
19
|
+
/** filter highlighter targets by this query selector. (May be a more complex object in the future) */
|
|
15
20
|
rule?: MatchRule;
|
|
21
|
+
/** filter targets by this component match rule */
|
|
22
|
+
componentRule?: ComponentMatchRule;
|
|
16
23
|
};
|
|
17
24
|
|
|
18
25
|
/** fires onChange when targeting a new component */
|
|
19
26
|
export function useHoverHighlighter<T extends HTMLElement = HTMLElement>(
|
|
20
27
|
onChange: (target?: HighlightTarget) => void,
|
|
21
28
|
props: React.HTMLAttributes<T> = {},
|
|
22
|
-
{ debounceDuration, scopeClass, disabled, rule }: useHoverHighlighterOptions
|
|
29
|
+
{ debounceDuration, scopeClass, disabled, rule, componentRule }: useHoverHighlighterOptions
|
|
23
30
|
) {
|
|
24
|
-
const { handleElement } = useHoverHandler({ onChange, scopeClass, debounceDuration, disabled, rule });
|
|
31
|
+
const { handleElement } = useHoverHandler({ onChange, scopeClass, debounceDuration, disabled, rule, componentRule });
|
|
25
32
|
|
|
26
33
|
const handlers = useHoverSelection(disabled ? undefined : handleElement, props);
|
|
27
34
|
|
|
@@ -34,9 +41,17 @@ type useHoverHighlighterProps = {
|
|
|
34
41
|
debounceDuration?: number;
|
|
35
42
|
disabled?: boolean;
|
|
36
43
|
rule?: MatchRule;
|
|
44
|
+
componentRule?: ComponentMatchRule;
|
|
37
45
|
};
|
|
38
46
|
|
|
39
|
-
function useHoverHandler({
|
|
47
|
+
function useHoverHandler({
|
|
48
|
+
onChange,
|
|
49
|
+
scopeClass = '',
|
|
50
|
+
debounceDuration,
|
|
51
|
+
disabled,
|
|
52
|
+
rule,
|
|
53
|
+
componentRule,
|
|
54
|
+
}: useHoverHighlighterProps) {
|
|
40
55
|
// debounced method is ref'ed, so no need for useCallback
|
|
41
56
|
const _handleElement = (element: HTMLElement | null) => {
|
|
42
57
|
// clear highlighter at the edges:
|
|
@@ -48,15 +63,12 @@ function useHoverHandler({ onChange, scopeClass = '', debounceDuration, disabled
|
|
|
48
63
|
// skip DOM trees having 'data-ignore-component-highlight'
|
|
49
64
|
if (element.closest(`.${scopeClass} ${excludeHighlighterSelector}`)) return;
|
|
50
65
|
|
|
51
|
-
const result = bubbleToBitComponent(element, rule
|
|
66
|
+
const result = bubbleToBitComponent(element, rule, componentRule);
|
|
52
67
|
if (!result) return;
|
|
53
68
|
|
|
54
69
|
onChange({
|
|
55
70
|
element: result.element,
|
|
56
|
-
|
|
57
|
-
scopeLink: undefined,
|
|
58
|
-
link: result.meta.homepage,
|
|
59
|
-
local: result.meta.exported === false,
|
|
71
|
+
components: result.components,
|
|
60
72
|
});
|
|
61
73
|
};
|
|
62
74
|
|
|
@@ -71,20 +83,25 @@ function useHoverHandler({ onChange, scopeClass = '', debounceDuration, disabled
|
|
|
71
83
|
}
|
|
72
84
|
|
|
73
85
|
/** go up the dom tree until reaching a react bit component */
|
|
74
|
-
function bubbleToBitComponent(
|
|
86
|
+
function bubbleToBitComponent(
|
|
87
|
+
element: HTMLElement | null,
|
|
88
|
+
elementRule?: MatchRule,
|
|
89
|
+
componentRule?: ComponentMatchRule
|
|
90
|
+
) {
|
|
75
91
|
for (let current = element; current; current = current.parentElement) {
|
|
76
92
|
current = toRootElement(current);
|
|
77
|
-
if (!current
|
|
78
|
-
|
|
79
|
-
|
|
93
|
+
if (!current) return undefined;
|
|
94
|
+
if (ruleMatcher(current, elementRule)) {
|
|
95
|
+
const components = domToReacts(current);
|
|
80
96
|
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
const relevantComponents = components.filter(
|
|
98
|
+
(x) => hasComponentMeta(x) && componentRuleMatcher({ meta: x[componentMetaField] }, componentRule)
|
|
99
|
+
) as ReactComponentMetaHolder[];
|
|
83
100
|
|
|
101
|
+
if (relevantComponents.length < 1) return undefined;
|
|
84
102
|
return {
|
|
85
103
|
element: current,
|
|
86
|
-
|
|
87
|
-
meta,
|
|
104
|
+
components: relevantComponents,
|
|
88
105
|
};
|
|
89
106
|
}
|
|
90
107
|
}
|
|
@@ -3,9 +3,15 @@ import classnames from 'classnames';
|
|
|
3
3
|
import { v4 } from 'uuid';
|
|
4
4
|
|
|
5
5
|
import { useHoverHighlighter } from '../hover-highlighter';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
ElementHighlighter,
|
|
8
|
+
HighlightTarget,
|
|
9
|
+
Placement,
|
|
10
|
+
HighlightClasses,
|
|
11
|
+
HighlighterSize,
|
|
12
|
+
} from '../element-highlighter';
|
|
13
|
+
import { useChildrenHighlighter } from '../children-highlighter';
|
|
14
|
+
import type { MatchRule, ComponentMatchRule } from '../rule-matcher';
|
|
9
15
|
|
|
10
16
|
export interface HybridHighlighterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
17
|
/** stop all highlighting and drop listeners */
|
|
@@ -27,6 +33,8 @@ export interface HybridHighlighterProps extends React.HTMLAttributes<HTMLDivElem
|
|
|
27
33
|
|
|
28
34
|
/** filter highlighter targets by this query selector. (May be a more complex object in the future) */
|
|
29
35
|
rule?: MatchRule;
|
|
36
|
+
/** filter components to match this rule. Can be id, array of ids, or a function */
|
|
37
|
+
componentRule?: ComponentMatchRule;
|
|
30
38
|
|
|
31
39
|
/** set the behavior of the highlighter.
|
|
32
40
|
* `disabled` - stops highlighting.
|
|
@@ -37,6 +45,7 @@ export interface HybridHighlighterProps extends React.HTMLAttributes<HTMLDivElem
|
|
|
37
45
|
bgColor?: string;
|
|
38
46
|
bgColorHover?: string;
|
|
39
47
|
bgColorActive?: string;
|
|
48
|
+
size?: HighlighterSize;
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
/** automatically highlight components on hover */
|
|
@@ -47,6 +56,7 @@ export function HybridHighlighter({
|
|
|
47
56
|
watchMotion = true,
|
|
48
57
|
placement,
|
|
49
58
|
rule,
|
|
59
|
+
componentRule,
|
|
50
60
|
|
|
51
61
|
classes,
|
|
52
62
|
highlightStyle,
|
|
@@ -55,6 +65,7 @@ export function HybridHighlighter({
|
|
|
55
65
|
bgColor,
|
|
56
66
|
bgColorHover,
|
|
57
67
|
bgColorActive,
|
|
68
|
+
size,
|
|
58
69
|
children,
|
|
59
70
|
...rest
|
|
60
71
|
}: HybridHighlighterProps) {
|
|
@@ -76,15 +87,17 @@ export function HybridHighlighter({
|
|
|
76
87
|
scopeClass,
|
|
77
88
|
disabled: disabled || mode !== 'hover',
|
|
78
89
|
rule,
|
|
90
|
+
componentRule,
|
|
79
91
|
}
|
|
80
92
|
);
|
|
81
93
|
|
|
82
|
-
|
|
94
|
+
useChildrenHighlighter({
|
|
83
95
|
onChange: setTarget,
|
|
84
96
|
scopeRef: ref,
|
|
85
97
|
scopeClass,
|
|
86
98
|
disabled: disabled || mode !== 'allChildren',
|
|
87
99
|
rule,
|
|
100
|
+
componentRule,
|
|
88
101
|
});
|
|
89
102
|
|
|
90
103
|
const _styles = useMemo(
|
|
@@ -119,6 +132,7 @@ export function HybridHighlighter({
|
|
|
119
132
|
style={highlightStyle}
|
|
120
133
|
placement={placement}
|
|
121
134
|
watchMotion={watchMotion}
|
|
135
|
+
size={size}
|
|
122
136
|
/>
|
|
123
137
|
))}
|
|
124
138
|
</div>
|
|
File without changes
|
package/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { HybridHighlighter as ComponentHighlighter } from './hybrid-
|
|
2
|
-
export type { HybridHighlighterProps as ComponentHighlightProps } from './hybrid-
|
|
1
|
+
export { HybridHighlighter as ComponentHighlighter } from './hybrid-highlighter';
|
|
2
|
+
export type { HybridHighlighterProps as ComponentHighlightProps } from './hybrid-highlighter';
|
|
3
3
|
|
|
4
4
|
export { HoverHighlighter } from './hover-highlighter';
|
|
5
5
|
export type { HoverHighlighterProps } from './hover-highlighter';
|
|
6
6
|
|
|
7
|
-
export {
|
|
8
|
-
export type {
|
|
7
|
+
export { ChildrenHighlighter } from './children-highlighter';
|
|
8
|
+
export type { ChildrenHighlighterProps } from './children-highlighter';
|
|
9
9
|
|
|
10
10
|
export { ElementHighlighter } from './element-highlighter';
|
|
11
11
|
export type { ElementHighlighterProps, HighlightTarget, Placement, HighlightClasses } from './element-highlighter';
|