@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
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,8 +1,8 @@
|
|
|
1
1
|
import { ComponentMeta } from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
2
|
-
export declare type ComponentMatchTarget = {
|
|
3
|
-
meta: ComponentMeta;
|
|
4
|
-
};
|
|
5
2
|
export declare type MatchRule = undefined | string | ((element: HTMLElement) => boolean);
|
|
6
3
|
export declare type ComponentMatchRule = undefined | string | string[] | ((target: ComponentMatchTarget) => boolean);
|
|
7
4
|
export declare function ruleMatcher(element: HTMLElement, rule: MatchRule): boolean;
|
|
5
|
+
export declare type ComponentMatchTarget = {
|
|
6
|
+
meta: ComponentMeta;
|
|
7
|
+
};
|
|
8
8
|
export declare function componentRuleMatcher(target: ComponentMatchTarget, rule: ComponentMatchRule): boolean;
|
package/dist/rule-matcher.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.componentRuleMatcher = exports.ruleMatcher = void 0;
|
|
4
|
+
// in the future, we will add more options here, like include / exclude objects.
|
|
4
5
|
const component_id_1 = require("@teambit/component-id");
|
|
5
6
|
function ruleMatcher(element, rule) {
|
|
6
7
|
if (typeof rule === 'string') {
|
package/dist/rule-matcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-matcher.js","sourceRoot":"","sources":["../rule-matcher.tsx"],"names":[],"mappings":";;;AAAA,wDAAoD;
|
|
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 }}>
|
|
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 size="s" />
|
|
60
|
+
<HighlightedElement size="m" />
|
|
61
|
+
<HighlightedElement size="l" />
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
50
64
|
};
|
|
51
65
|
|
|
52
66
|
export const MovingElement = () => {
|
|
@@ -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';
|
|
@@ -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,8 +1,12 @@
|
|
|
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';
|
|
@@ -64,10 +68,7 @@ function useHoverHandler({
|
|
|
64
68
|
|
|
65
69
|
onChange({
|
|
66
70
|
element: result.element,
|
|
67
|
-
|
|
68
|
-
scopeLink: undefined,
|
|
69
|
-
link: result.meta.homepage,
|
|
70
|
-
local: result.meta.exported === false,
|
|
71
|
+
components: result.components,
|
|
71
72
|
});
|
|
72
73
|
};
|
|
73
74
|
|
|
@@ -91,18 +92,17 @@ function bubbleToBitComponent(
|
|
|
91
92
|
current = toRootElement(current);
|
|
92
93
|
if (!current) return undefined;
|
|
93
94
|
if (ruleMatcher(current, elementRule)) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
95
|
+
const components = domToReacts(current);
|
|
96
|
+
|
|
97
|
+
const relevantComponents = components.filter(
|
|
98
|
+
(x) => hasComponentMeta(x) && componentRuleMatcher({ meta: x[componentMetaField] }, componentRule)
|
|
99
|
+
) as ReactComponentMetaHolder[];
|
|
100
|
+
|
|
101
|
+
if (relevantComponents.length < 1) return undefined;
|
|
102
|
+
return {
|
|
103
|
+
element: current,
|
|
104
|
+
components: relevantComponents,
|
|
105
|
+
};
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -3,8 +3,14 @@ import classnames from 'classnames';
|
|
|
3
3
|
import { v4 } from 'uuid';
|
|
4
4
|
|
|
5
5
|
import { useHoverHighlighter } from '../hover-highlighter';
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
ElementHighlighter,
|
|
8
|
+
HighlightTarget,
|
|
9
|
+
Placement,
|
|
10
|
+
HighlightClasses,
|
|
11
|
+
HighlighterSize,
|
|
12
|
+
} from '../element-highlighter';
|
|
13
|
+
import { useChildrenHighlighter } from '../children-highlighter';
|
|
8
14
|
import type { MatchRule, ComponentMatchRule } from '../rule-matcher';
|
|
9
15
|
|
|
10
16
|
export interface HybridHighlighterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -27,6 +33,7 @@ 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 */
|
|
30
37
|
componentRule?: ComponentMatchRule;
|
|
31
38
|
|
|
32
39
|
/** set the behavior of the highlighter.
|
|
@@ -38,6 +45,7 @@ export interface HybridHighlighterProps extends React.HTMLAttributes<HTMLDivElem
|
|
|
38
45
|
bgColor?: string;
|
|
39
46
|
bgColorHover?: string;
|
|
40
47
|
bgColorActive?: string;
|
|
48
|
+
size?: HighlighterSize;
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
/** automatically highlight components on hover */
|
|
@@ -57,6 +65,7 @@ export function HybridHighlighter({
|
|
|
57
65
|
bgColor,
|
|
58
66
|
bgColorHover,
|
|
59
67
|
bgColorActive,
|
|
68
|
+
size,
|
|
60
69
|
children,
|
|
61
70
|
...rest
|
|
62
71
|
}: HybridHighlighterProps) {
|
|
@@ -78,17 +87,17 @@ export function HybridHighlighter({
|
|
|
78
87
|
scopeClass,
|
|
79
88
|
disabled: disabled || mode !== 'hover',
|
|
80
89
|
rule,
|
|
81
|
-
componentRule
|
|
90
|
+
componentRule,
|
|
82
91
|
}
|
|
83
92
|
);
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
useChildrenHighlighter({
|
|
86
95
|
onChange: setTarget,
|
|
87
96
|
scopeRef: ref,
|
|
88
97
|
scopeClass,
|
|
89
98
|
disabled: disabled || mode !== 'allChildren',
|
|
90
99
|
rule,
|
|
91
|
-
componentRule
|
|
100
|
+
componentRule,
|
|
92
101
|
});
|
|
93
102
|
|
|
94
103
|
const _styles = useMemo(
|
|
@@ -123,6 +132,7 @@ export function HybridHighlighter({
|
|
|
123
132
|
style={highlightStyle}
|
|
124
133
|
placement={placement}
|
|
125
134
|
watchMotion={watchMotion}
|
|
135
|
+
size={size}
|
|
126
136
|
/>
|
|
127
137
|
))}
|
|
128
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';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
$borderRadius: 8px;
|
|
2
|
+
$gap: 2px;
|
|
3
|
+
|
|
4
|
+
.componentStrip {
|
|
5
|
+
display: flex;
|
|
6
|
+
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
line-height: 16px;
|
|
9
|
+
border-radius: $borderRadius;
|
|
10
|
+
box-shadow: 0px 11px 29px 0px rgba(0, 0, 0, 0.23);
|
|
11
|
+
|
|
12
|
+
&[data-size='s'] {
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
line-height: 16px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&[data-size='m'] {
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
line-height: 16px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&[data-size='l'] {
|
|
23
|
+
font-size: 16px;
|
|
24
|
+
line-height: 24px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
> * {
|
|
28
|
+
padding: 4px 8px;
|
|
29
|
+
|
|
30
|
+
transition: filter 300ms, background-color 300ms;
|
|
31
|
+
transform: translateZ(0); //fix blurriness in Safari
|
|
32
|
+
|
|
33
|
+
background: var(--bit-highlighter-color, #eebcc9);
|
|
34
|
+
|
|
35
|
+
&:link,
|
|
36
|
+
&:visited {
|
|
37
|
+
text-decoration: inherit; // reset browser defaults
|
|
38
|
+
color: inherit; // reset browser defaults
|
|
39
|
+
|
|
40
|
+
&:hover {
|
|
41
|
+
background: var(--bit-highlighter-color-hover, #f6dae2);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&:active {
|
|
45
|
+
background: var(--bit-highlighter-color-active, #e79db1);
|
|
46
|
+
color: inherit;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:first-child {
|
|
51
|
+
border-top-left-radius: $borderRadius;
|
|
52
|
+
border-bottom-left-radius: $borderRadius;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
margin-right: $gap;
|
|
56
|
+
|
|
57
|
+
&:last-child {
|
|
58
|
+
border-top-right-radius: $borderRadius;
|
|
59
|
+
border-bottom-right-radius: $borderRadius;
|
|
60
|
+
|
|
61
|
+
margin-right: unset;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { useMemo, ReactNode, forwardRef, ForwardedRef } from 'react';
|
|
2
|
+
import { NativeLink } from '@teambit/base-ui.routing.native-link';
|
|
3
|
+
import { ComponentID } from '@teambit/component-id';
|
|
4
|
+
import { ScopeUrl } from '@teambit/component.modules.component-url';
|
|
5
|
+
import {
|
|
6
|
+
componentMetaField,
|
|
7
|
+
ComponentMetaHolder,
|
|
8
|
+
} from '@teambit/react.ui.highlighter.component-metadata.bit-component-meta';
|
|
9
|
+
import styles from './component-strip.module.scss';
|
|
10
|
+
import { calcComponentLink } from './links';
|
|
11
|
+
|
|
12
|
+
export type ComponentStripSize = 's' | 'm' | 'l';
|
|
13
|
+
|
|
14
|
+
interface ComponentStripProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
15
|
+
component: ComponentMetaHolder;
|
|
16
|
+
size?: ComponentStripSize;
|
|
17
|
+
}
|
|
18
|
+
export const ComponentStrip = forwardRef(function ComponentStrip(
|
|
19
|
+
{ component, size = 'm', children }: ComponentStripProps,
|
|
20
|
+
ref: ForwardedRef<HTMLDivElement>
|
|
21
|
+
) {
|
|
22
|
+
const { id, homepage, exported } = component[componentMetaField];
|
|
23
|
+
|
|
24
|
+
const parsedId = useMemo(() => ComponentID.tryFromString(id), [id]);
|
|
25
|
+
const componentLink = homepage || calcComponentLink(parsedId, exported);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className={styles.componentStrip} ref={ref} data-size={size}>
|
|
29
|
+
{!parsedId && <LabelBlock link={homepage}>{id}</LabelBlock>}
|
|
30
|
+
{parsedId && <LabelBlock link={ScopeUrl.toUrl(parsedId.scope)}>{parsedId.scope}</LabelBlock>}
|
|
31
|
+
{parsedId && (
|
|
32
|
+
<LabelBlock link={componentLink}>
|
|
33
|
+
{parsedId.fullName}
|
|
34
|
+
{parsedId.version && parsedId.version !== 'latest' && `@${parsedId.version}`}
|
|
35
|
+
</LabelBlock>
|
|
36
|
+
)}
|
|
37
|
+
{children}
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
function LabelBlock({ link, children }: { link?: string; children: ReactNode }) {
|
|
43
|
+
const Comp = link ? NativeLink : 'span';
|
|
44
|
+
return (
|
|
45
|
+
<Comp href={link} external={!!link}>
|
|
46
|
+
{children}
|
|
47
|
+
</Comp>
|
|
48
|
+
);
|
|
49
|
+
}
|
package/label/index.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { Label } from './label';
|
|
2
|
+
export type { LabelProps, LabelSize } from './label';
|
|
3
|
+
|
|
4
|
+
export { LabelContainer } from './label-container';
|
|
5
|
+
export type { LabelContainerProps, Placement } from './label-container';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import { usePopper } from 'react-popper';
|
|
3
|
+
import type { Placement, Modifier } from '@popperjs/core';
|
|
4
|
+
import '@popperjs/core';
|
|
5
|
+
|
|
6
|
+
import { useAnimationFrame } from '../use-animation-frame';
|
|
7
|
+
|
|
8
|
+
export interface LabelContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
targetRef: HTMLElement | null;
|
|
10
|
+
offset?: [number, number];
|
|
11
|
+
placement?: Placement;
|
|
12
|
+
flip?: boolean;
|
|
13
|
+
/** continually update label position to match moving elements */
|
|
14
|
+
watchMotion?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { Placement };
|
|
18
|
+
|
|
19
|
+
// TODO - replace this with TippyJS, when it supports a `targetElement={targetRef.current}` prop
|
|
20
|
+
export function LabelContainer({
|
|
21
|
+
targetRef,
|
|
22
|
+
offset,
|
|
23
|
+
placement,
|
|
24
|
+
flip = true,
|
|
25
|
+
watchMotion,
|
|
26
|
+
className,
|
|
27
|
+
...rest
|
|
28
|
+
}: LabelContainerProps) {
|
|
29
|
+
const [sourceRef, setSourceRef] = useState<HTMLDivElement | null>(null);
|
|
30
|
+
|
|
31
|
+
const modifiers = useMemo<Partial<Modifier<any, any>>[]>(
|
|
32
|
+
() => [{ name: 'offset', options: { offset } }],
|
|
33
|
+
[flip, offset]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const { styles, attributes, update } = usePopper(targetRef, sourceRef, {
|
|
37
|
+
modifiers,
|
|
38
|
+
placement,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
useAnimationFrame(!!watchMotion && update);
|
|
42
|
+
|
|
43
|
+
if (!targetRef) return null;
|
|
44
|
+
|
|
45
|
+
return <div {...rest} ref={setSourceRef} className={className} style={styles.popper} {...attributes.popper} />;
|
|
46
|
+
}
|
|
@@ -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
|
+
}
|