@teambit/compositions.ui.composition-compare 0.0.1

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.
@@ -0,0 +1,42 @@
1
+ .dropdownContainer {
2
+ display: flex;
3
+ }
4
+
5
+ .leftDropdown {
6
+ flex: 1;
7
+ padding: 16px;
8
+ }
9
+
10
+ .rightDropdown {
11
+ flex: 1;
12
+ padding: 16px 16px 16px 0px;
13
+ }
14
+
15
+ .mainContainer {
16
+ display: flex;
17
+ height: 100%;
18
+ }
19
+
20
+ .subContainerLeft {
21
+ flex: 1;
22
+ background-color: #ededed;
23
+ padding: 16px;
24
+ }
25
+
26
+ .subContainerRight {
27
+ flex: 1;
28
+ background-color: #ededed;
29
+ padding: 16px 16px 16px 0px;
30
+ }
31
+
32
+ .subView {
33
+ height: 100%;
34
+ background-color: white;
35
+ overflow-y: scroll;
36
+ }
37
+
38
+ .loader {
39
+ display: flex;
40
+ align-items: center;
41
+ height: 100%;
42
+ }
@@ -0,0 +1,152 @@
1
+ import {
2
+ CompareSplitLayoutPreset,
3
+ useCompareQueryParam,
4
+ useComponentCompare,
5
+ useUpdatedUrlFromQuery,
6
+ } from '@teambit/component.ui.compare';
7
+ import { CompositionContent, EmptyStateSlot } from '@teambit/compositions';
8
+ import { CompositionContextProvider } from '@teambit/compositions.ui.hooks.use-composition';
9
+ import { RoundLoader } from '@teambit/design.ui.round-loader';
10
+ import queryString from 'query-string';
11
+ import React, { useMemo, useState } from 'react';
12
+ import styles from './composition-compare.module.scss';
13
+ import { CompositionDropdown } from './composition-dropdown';
14
+
15
+ export type CompositionCompareProps = {
16
+ emptyState?: EmptyStateSlot;
17
+ };
18
+
19
+ export function CompositionCompare(props: CompositionCompareProps) {
20
+ const { emptyState } = props;
21
+
22
+ const component = useComponentCompare();
23
+
24
+ const base = component?.base;
25
+ const compare = component?.compare;
26
+
27
+ const baseCompositions = base?.compositions;
28
+ const compareCompositions = compare?.compositions;
29
+ const selectedCompositionBaseFile = useCompareQueryParam('compositionBaseFile');
30
+ const selectedCompositionCompareFile = useCompareQueryParam('compositionCompareFile');
31
+
32
+ const selectedBaseComp =
33
+ (selectedCompositionBaseFile &&
34
+ baseCompositions &&
35
+ baseCompositions.find((c) => c.identifier === selectedCompositionBaseFile)) ||
36
+ (baseCompositions && baseCompositions[0]);
37
+
38
+ const selectedCompareComp =
39
+ (selectedCompositionCompareFile &&
40
+ compareCompositions &&
41
+ compareCompositions.find((c) => c.identifier === selectedCompositionCompareFile)) ||
42
+ (compareCompositions && compareCompositions[0]);
43
+
44
+ const baseCompositionDropdownSource =
45
+ baseCompositions?.map((c) => {
46
+ const href = useUpdatedUrlFromQuery({
47
+ compositionBaseFile: c.identifier,
48
+ compositionCompareFile: selectedCompareComp?.identifier,
49
+ });
50
+
51
+ return { id: c.identifier, label: c.displayName, value: href };
52
+ }) || [];
53
+
54
+ const compareCompositionDropdownSource =
55
+ compareCompositions?.map((c) => {
56
+ const href = useUpdatedUrlFromQuery({
57
+ compositionBaseFile: selectedBaseComp?.identifier,
58
+ compositionCompareFile: c.identifier,
59
+ });
60
+ return { id: c.identifier, label: c.displayName, value: href };
61
+ }) || [];
62
+
63
+ const [baseCompositionParams, setBaseCompositionParams] = useState<Record<string, any>>({});
64
+ const baseCompQueryParams = useMemo(() => queryString.stringify(baseCompositionParams), [baseCompositionParams]);
65
+
66
+ const [compareCompositionParams, setCompareCompositionParams] = useState<Record<string, any>>({});
67
+ const compareCompQueryParams = useMemo(
68
+ () => queryString.stringify(compareCompositionParams),
69
+ [compareCompositionParams]
70
+ );
71
+
72
+ const selectedBaseDropdown = selectedBaseComp && {
73
+ id: selectedBaseComp.identifier,
74
+ label: selectedBaseComp.displayName,
75
+ };
76
+
77
+ const selectedCompareDropdown = selectedCompareComp && {
78
+ id: selectedCompareComp.identifier,
79
+ label: selectedCompareComp.displayName,
80
+ };
81
+
82
+ const BaseLayout = useMemo(() => {
83
+ if (component?.base === undefined) {
84
+ return <></>;
85
+ }
86
+
87
+ return (
88
+ <div className={styles.subView}>
89
+ <CompositionContextProvider queryParams={baseCompositionParams} setQueryParams={setBaseCompositionParams}>
90
+ <CompositionContent
91
+ emptyState={emptyState}
92
+ component={component?.base}
93
+ selected={selectedBaseComp}
94
+ queryParams={baseCompQueryParams}
95
+ />
96
+ </CompositionContextProvider>
97
+ </div>
98
+ );
99
+ }, [component?.base, selectedBaseComp]);
100
+
101
+ const CompareLayout = useMemo(() => {
102
+ if (component?.compare === undefined) {
103
+ return <></>;
104
+ }
105
+
106
+ return (
107
+ <div className={styles.subView}>
108
+ <CompositionContextProvider queryParams={compareCompositionParams} setQueryParams={setCompareCompositionParams}>
109
+ <CompositionContent
110
+ emptyState={emptyState}
111
+ component={component.compare}
112
+ selected={selectedCompareComp}
113
+ queryParams={compareCompQueryParams}
114
+ />
115
+ </CompositionContextProvider>
116
+ </div>
117
+ );
118
+ }, [component?.compare, selectedCompareComp]);
119
+
120
+ function CompositionDropdowns() {
121
+ if (baseCompositionDropdownSource.length < 0 && compareCompositionDropdownSource.length < 0) {
122
+ return <></>;
123
+ }
124
+
125
+ return (
126
+ <div className={styles.dropdownContainer}>
127
+ <div className={styles.leftDropdown}>
128
+ {baseCompositionDropdownSource.length > 0 && (
129
+ <CompositionDropdown dropdownItems={baseCompositionDropdownSource} selected={selectedBaseDropdown} />
130
+ )}
131
+ </div>
132
+ <div className={styles.rightDropdown}>
133
+ {compareCompositionDropdownSource.length > 0 && (
134
+ <CompositionDropdown dropdownItems={compareCompositionDropdownSource} selected={selectedCompareDropdown} />
135
+ )}
136
+ </div>
137
+ </div>
138
+ );
139
+ }
140
+
141
+ return (
142
+ <>
143
+ {component?.loading && (
144
+ <div className={styles.loader}>
145
+ <RoundLoader />
146
+ </div>
147
+ )}
148
+ <CompositionDropdowns />
149
+ <CompareSplitLayoutPreset base={BaseLayout} compare={CompareLayout} />
150
+ </>
151
+ );
152
+ }
@@ -0,0 +1,25 @@
1
+ @import '~@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
2
+
3
+ .placeholder {
4
+ display: flex;
5
+ justify-content: space-between;
6
+ align-items: center;
7
+ box-sizing: border-box;
8
+ padding: 0 8px;
9
+ height: 30px;
10
+ border-radius: 6px;
11
+ user-select: none;
12
+ transition: background-color 300ms ease-in-out;
13
+ border: 1px solid var(--bit-border-color, #babec9);
14
+ }
15
+
16
+ .menu {
17
+ font-size: var(--bit-p-xs);
18
+ border-radius: 6px;
19
+ max-height: 240px;
20
+ overflow-y: scroll;
21
+ max-width: 100%;
22
+ width: 100%;
23
+ padding: 0px;
24
+ z-index: $nav-z-index + 1;
25
+ }
@@ -0,0 +1,57 @@
1
+ import { MenuLinkItem } from '@teambit/design.ui.surfaces.menu.link-item';
2
+ import { Icon } from '@teambit/evangelist.elements.icon';
3
+ import { Dropdown } from '@teambit/evangelist.surfaces.dropdown';
4
+ import React, { useEffect, useRef } from 'react';
5
+ import styles from './composition-dropdown.module.scss';
6
+
7
+ export type DropdownItem = { id: string; label: string; value: string };
8
+
9
+ export type CompositionDropdownProps = {
10
+ selected?: Omit<DropdownItem, 'value'>;
11
+ dropdownItems: Array<DropdownItem>;
12
+ };
13
+
14
+ export function CompositionDropdown(props: CompositionDropdownProps) {
15
+ const { selected, dropdownItems: data } = props;
16
+
17
+ return (
18
+ <Dropdown
19
+ dropClass={styles.menu}
20
+ placeholder={
21
+ <div className={styles.placeholder}>
22
+ <div>{selected && selected.label}</div>
23
+ <Icon of="fat-arrow-down" />
24
+ </div>
25
+ }
26
+ >
27
+ {data.map((item) => {
28
+ return <MenuItem key={item.id} current={item} selected={selected} />;
29
+ })}
30
+ </Dropdown>
31
+ );
32
+ }
33
+
34
+ type MenuItemProps = {
35
+ selected?: Omit<DropdownItem, 'value'>;
36
+ current: DropdownItem;
37
+ };
38
+
39
+ function MenuItem(props: MenuItemProps) {
40
+ const { selected, current } = props;
41
+
42
+ const isCurrent = selected?.id === current.id;
43
+ const currentVersionRef = useRef<HTMLDivElement>(null);
44
+ useEffect(() => {
45
+ if (isCurrent) {
46
+ currentVersionRef.current?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
47
+ }
48
+ }, [isCurrent]);
49
+
50
+ return (
51
+ <div ref={currentVersionRef}>
52
+ <MenuLinkItem isActive={() => current.id === selected?.id} href={current.value}>
53
+ <div>{current.label}</div>
54
+ </MenuLinkItem>
55
+ </div>
56
+ );
57
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { EmptyStateSlot } from '@teambit/compositions';
3
+ export declare type CompositionCompareProps = {
4
+ emptyState?: EmptyStateSlot;
5
+ };
6
+ export declare function CompositionCompare(props: CompositionCompareProps): JSX.Element;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.CompositionCompare = void 0;
26
+ const component_ui_compare_1 = require("@teambit/component.ui.compare");
27
+ const compositions_1 = require("@teambit/compositions");
28
+ const compositions_ui_hooks_use_composition_1 = require("@teambit/compositions.ui.hooks.use-composition");
29
+ const design_ui_round_loader_1 = require("@teambit/design.ui.round-loader");
30
+ const query_string_1 = __importDefault(require("query-string"));
31
+ const react_1 = __importStar(require("react"));
32
+ const composition_compare_module_scss_1 = __importDefault(require("./composition-compare.module.scss"));
33
+ const composition_dropdown_1 = require("./composition-dropdown");
34
+ function CompositionCompare(props) {
35
+ const { emptyState } = props;
36
+ const component = (0, component_ui_compare_1.useComponentCompare)();
37
+ const base = component === null || component === void 0 ? void 0 : component.base;
38
+ const compare = component === null || component === void 0 ? void 0 : component.compare;
39
+ const baseCompositions = base === null || base === void 0 ? void 0 : base.compositions;
40
+ const compareCompositions = compare === null || compare === void 0 ? void 0 : compare.compositions;
41
+ const selectedCompositionBaseFile = (0, component_ui_compare_1.useCompareQueryParam)('compositionBaseFile');
42
+ const selectedCompositionCompareFile = (0, component_ui_compare_1.useCompareQueryParam)('compositionCompareFile');
43
+ const selectedBaseComp = (selectedCompositionBaseFile &&
44
+ baseCompositions &&
45
+ baseCompositions.find((c) => c.identifier === selectedCompositionBaseFile)) ||
46
+ (baseCompositions && baseCompositions[0]);
47
+ const selectedCompareComp = (selectedCompositionCompareFile &&
48
+ compareCompositions &&
49
+ compareCompositions.find((c) => c.identifier === selectedCompositionCompareFile)) ||
50
+ (compareCompositions && compareCompositions[0]);
51
+ const baseCompositionDropdownSource = (baseCompositions === null || baseCompositions === void 0 ? void 0 : baseCompositions.map((c) => {
52
+ const href = (0, component_ui_compare_1.useUpdatedUrlFromQuery)({
53
+ compositionBaseFile: c.identifier,
54
+ compositionCompareFile: selectedCompareComp === null || selectedCompareComp === void 0 ? void 0 : selectedCompareComp.identifier,
55
+ });
56
+ return { id: c.identifier, label: c.displayName, value: href };
57
+ })) || [];
58
+ const compareCompositionDropdownSource = (compareCompositions === null || compareCompositions === void 0 ? void 0 : compareCompositions.map((c) => {
59
+ const href = (0, component_ui_compare_1.useUpdatedUrlFromQuery)({
60
+ compositionBaseFile: selectedBaseComp === null || selectedBaseComp === void 0 ? void 0 : selectedBaseComp.identifier,
61
+ compositionCompareFile: c.identifier,
62
+ });
63
+ return { id: c.identifier, label: c.displayName, value: href };
64
+ })) || [];
65
+ const [baseCompositionParams, setBaseCompositionParams] = (0, react_1.useState)({});
66
+ const baseCompQueryParams = (0, react_1.useMemo)(() => query_string_1.default.stringify(baseCompositionParams), [baseCompositionParams]);
67
+ const [compareCompositionParams, setCompareCompositionParams] = (0, react_1.useState)({});
68
+ const compareCompQueryParams = (0, react_1.useMemo)(() => query_string_1.default.stringify(compareCompositionParams), [compareCompositionParams]);
69
+ const selectedBaseDropdown = selectedBaseComp && {
70
+ id: selectedBaseComp.identifier,
71
+ label: selectedBaseComp.displayName,
72
+ };
73
+ const selectedCompareDropdown = selectedCompareComp && {
74
+ id: selectedCompareComp.identifier,
75
+ label: selectedCompareComp.displayName,
76
+ };
77
+ const BaseLayout = (0, react_1.useMemo)(() => {
78
+ if ((component === null || component === void 0 ? void 0 : component.base) === undefined) {
79
+ return react_1.default.createElement(react_1.default.Fragment, null);
80
+ }
81
+ return (react_1.default.createElement("div", { className: composition_compare_module_scss_1.default.subView },
82
+ react_1.default.createElement(compositions_ui_hooks_use_composition_1.CompositionContextProvider, { queryParams: baseCompositionParams, setQueryParams: setBaseCompositionParams },
83
+ react_1.default.createElement(compositions_1.CompositionContent, { emptyState: emptyState, component: component === null || component === void 0 ? void 0 : component.base, selected: selectedBaseComp, queryParams: baseCompQueryParams }))));
84
+ }, [component === null || component === void 0 ? void 0 : component.base, selectedBaseComp]);
85
+ const CompareLayout = (0, react_1.useMemo)(() => {
86
+ if ((component === null || component === void 0 ? void 0 : component.compare) === undefined) {
87
+ return react_1.default.createElement(react_1.default.Fragment, null);
88
+ }
89
+ return (react_1.default.createElement("div", { className: composition_compare_module_scss_1.default.subView },
90
+ react_1.default.createElement(compositions_ui_hooks_use_composition_1.CompositionContextProvider, { queryParams: compareCompositionParams, setQueryParams: setCompareCompositionParams },
91
+ react_1.default.createElement(compositions_1.CompositionContent, { emptyState: emptyState, component: component.compare, selected: selectedCompareComp, queryParams: compareCompQueryParams }))));
92
+ }, [component === null || component === void 0 ? void 0 : component.compare, selectedCompareComp]);
93
+ function CompositionDropdowns() {
94
+ if (baseCompositionDropdownSource.length < 0 && compareCompositionDropdownSource.length < 0) {
95
+ return react_1.default.createElement(react_1.default.Fragment, null);
96
+ }
97
+ return (react_1.default.createElement("div", { className: composition_compare_module_scss_1.default.dropdownContainer },
98
+ react_1.default.createElement("div", { className: composition_compare_module_scss_1.default.leftDropdown }, baseCompositionDropdownSource.length > 0 && (react_1.default.createElement(composition_dropdown_1.CompositionDropdown, { dropdownItems: baseCompositionDropdownSource, selected: selectedBaseDropdown }))),
99
+ react_1.default.createElement("div", { className: composition_compare_module_scss_1.default.rightDropdown }, compareCompositionDropdownSource.length > 0 && (react_1.default.createElement(composition_dropdown_1.CompositionDropdown, { dropdownItems: compareCompositionDropdownSource, selected: selectedCompareDropdown })))));
100
+ }
101
+ return (react_1.default.createElement(react_1.default.Fragment, null,
102
+ (component === null || component === void 0 ? void 0 : component.loading) && (react_1.default.createElement("div", { className: composition_compare_module_scss_1.default.loader },
103
+ react_1.default.createElement(design_ui_round_loader_1.RoundLoader, null))),
104
+ react_1.default.createElement(CompositionDropdowns, null),
105
+ react_1.default.createElement(component_ui_compare_1.CompareSplitLayoutPreset, { base: BaseLayout, compare: CompareLayout })));
106
+ }
107
+ exports.CompositionCompare = CompositionCompare;
108
+ //# sourceMappingURL=composition-compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition-compare.js","sourceRoot":"","sources":["../composition-compare.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wEAKuC;AACvC,wDAA2E;AAC3E,0GAA4F;AAC5F,4EAA8D;AAC9D,gEAAuC;AACvC,+CAAiD;AACjD,wGAAuD;AACvD,iEAA6D;AAM7D,SAAgB,kBAAkB,CAAC,KAA8B;IAC/D,MAAM,EAAE,UAAU,EAAE,GA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AAS,CAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAE9C,SAAS,oBAAoB;QAC3B,IAAI,6BAA6B,CAAC,MAAM,GAAG,CAAC,IAAI,gCAAgC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3F,OAAO,6DAAK,CAAC;SACd;QAED,OAAO,CACL,uCAAK,SAAS,EAAE,yCAAM,CAAC,iBAAiB;YACtC,uCAAK,SAAS,EAAE,yCAAM,CAAC,YAAY,IAChC,6BAA6B,CAAC,MAAM,GAAG,CAAC,IAAI,CAC3C,8BAAC,0CAAmB,IAAC,aAAa,EAAE,6BAA6B,EAAE,QAAQ,EAAE,oBAAoB,GAAI,CACtG,CACG;YACN,uCAAK,SAAS,EAAE,yCAAM,CAAC,aAAa,IACjC,gCAAgC,CAAC,MAAM,GAAG,CAAC,IAAI,CAC9C,8BAAC,0CAAmB,IAAC,aAAa,EAAE,gCAAgC,EAAE,QAAQ,EAAE,uBAAuB,GAAI,CAC5G,CACG,CACF,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL;QACG,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,KAAI,CACrB,uCAAK,SAAS,EAAE,yCAAM,CAAC,MAAM;YAC3B,8BAAC,oCAAW,OAAG,CACX,CACP;QACD,8BAAC,oBAAoB,OAAG;QACxB,8BAAC,+CAAwB,IAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,GAAI,CACrE,CACJ,CAAC;AACJ,CAAC;AArID,gDAqIC"}
@@ -0,0 +1,42 @@
1
+ .dropdownContainer {
2
+ display: flex;
3
+ }
4
+
5
+ .leftDropdown {
6
+ flex: 1;
7
+ padding: 16px;
8
+ }
9
+
10
+ .rightDropdown {
11
+ flex: 1;
12
+ padding: 16px 16px 16px 0px;
13
+ }
14
+
15
+ .mainContainer {
16
+ display: flex;
17
+ height: 100%;
18
+ }
19
+
20
+ .subContainerLeft {
21
+ flex: 1;
22
+ background-color: #ededed;
23
+ padding: 16px;
24
+ }
25
+
26
+ .subContainerRight {
27
+ flex: 1;
28
+ background-color: #ededed;
29
+ padding: 16px 16px 16px 0px;
30
+ }
31
+
32
+ .subView {
33
+ height: 100%;
34
+ background-color: white;
35
+ overflow-y: scroll;
36
+ }
37
+
38
+ .loader {
39
+ display: flex;
40
+ align-items: center;
41
+ height: 100%;
42
+ }
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export declare type DropdownItem = {
3
+ id: string;
4
+ label: string;
5
+ value: string;
6
+ };
7
+ export declare type CompositionDropdownProps = {
8
+ selected?: Omit<DropdownItem, 'value'>;
9
+ dropdownItems: Array<DropdownItem>;
10
+ };
11
+ export declare function CompositionDropdown(props: CompositionDropdownProps): JSX.Element;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.CompositionDropdown = void 0;
26
+ const design_ui_surfaces_menu_link_item_1 = require("@teambit/design.ui.surfaces.menu.link-item");
27
+ const evangelist_elements_icon_1 = require("@teambit/evangelist.elements.icon");
28
+ const evangelist_surfaces_dropdown_1 = require("@teambit/evangelist.surfaces.dropdown");
29
+ const react_1 = __importStar(require("react"));
30
+ const composition_dropdown_module_scss_1 = __importDefault(require("./composition-dropdown.module.scss"));
31
+ function CompositionDropdown(props) {
32
+ const { selected, dropdownItems: data } = props;
33
+ return (react_1.default.createElement(evangelist_surfaces_dropdown_1.Dropdown, { dropClass: composition_dropdown_module_scss_1.default.menu, placeholder: react_1.default.createElement("div", { className: composition_dropdown_module_scss_1.default.placeholder },
34
+ react_1.default.createElement("div", null, selected && selected.label),
35
+ react_1.default.createElement(evangelist_elements_icon_1.Icon, { of: "fat-arrow-down" })) }, data.map((item) => {
36
+ return react_1.default.createElement(MenuItem, { key: item.id, current: item, selected: selected });
37
+ })));
38
+ }
39
+ exports.CompositionDropdown = CompositionDropdown;
40
+ function MenuItem(props) {
41
+ const { selected, current } = props;
42
+ const isCurrent = (selected === null || selected === void 0 ? void 0 : selected.id) === current.id;
43
+ const currentVersionRef = (0, react_1.useRef)(null);
44
+ (0, react_1.useEffect)(() => {
45
+ var _a;
46
+ if (isCurrent) {
47
+ (_a = currentVersionRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
48
+ }
49
+ }, [isCurrent]);
50
+ return (react_1.default.createElement("div", { ref: currentVersionRef },
51
+ react_1.default.createElement(design_ui_surfaces_menu_link_item_1.MenuLinkItem, { isActive: () => current.id === (selected === null || selected === void 0 ? void 0 : selected.id), href: current.value },
52
+ react_1.default.createElement("div", null, current.label))));
53
+ }
54
+ //# sourceMappingURL=composition-dropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition-dropdown.js","sourceRoot":"","sources":["../composition-dropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kGAA0E;AAC1E,gFAAyD;AACzD,wFAAiE;AACjE,+CAAiD;AACjD,0GAAwD;AASxD,SA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,QAAQ,CAAE,EAAE,CAAA,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK;YAC5E,2CAAM,OAAO,CAAC,KAAK,CAAO,CACb,CACX,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ @import '~@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
2
+
3
+ .placeholder {
4
+ display: flex;
5
+ justify-content: space-between;
6
+ align-items: center;
7
+ box-sizing: border-box;
8
+ padding: 0 8px;
9
+ height: 30px;
10
+ border-radius: 6px;
11
+ user-select: none;
12
+ transition: background-color 300ms ease-in-out;
13
+ border: 1px solid var(--bit-border-color, #babec9);
14
+ }
15
+
16
+ .menu {
17
+ font-size: var(--bit-p-xs);
18
+ border-radius: 6px;
19
+ max-height: 240px;
20
+ overflow-y: scroll;
21
+ max-width: 100%;
22
+ width: 100%;
23
+ padding: 0px;
24
+ z-index: $nav-z-index + 1;
25
+ }
@@ -0,0 +1 @@
1
+ export { CompositionCompare } from './composition-compare';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompositionCompare = void 0;
4
+ var composition_compare_1 = require("./composition-compare");
5
+ Object.defineProperty(exports, "CompositionCompare", { enumerable: true, get: function () { return composition_compare_1.CompositionCompare; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,yHAAA,kBAAkB,OAAA"}
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": [
4
+ "es2019",
5
+ "DOM",
6
+ "ES6",
7
+ "DOM.Iterable"
8
+ ],
9
+ "target": "es2015",
10
+ "module": "CommonJS",
11
+ "jsx": "react",
12
+ "allowJs": true,
13
+ "composite": true,
14
+ "declaration": true,
15
+ "sourceMap": true,
16
+ "skipLibCheck": true,
17
+ "experimentalDecorators": true,
18
+ "outDir": "dist",
19
+ "moduleResolution": "node",
20
+ "esModuleInterop": true,
21
+ "rootDir": ".",
22
+ "resolveJsonModule": true
23
+ },
24
+ "exclude": [
25
+ "dist",
26
+ "package.json"
27
+ ],
28
+ "include": [
29
+ "**/*",
30
+ "**/*.json"
31
+ ]
32
+ }
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { CompositionCompare } from './composition-compare';
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@teambit/compositions.ui.composition-compare",
3
+ "version": "0.0.1",
4
+ "main": "dist/index.js",
5
+ "componentId": {
6
+ "scope": "teambit.compositions",
7
+ "name": "ui/composition-compare",
8
+ "version": "0.0.1"
9
+ },
10
+ "dependencies": {
11
+ "query-string": "7.0.0",
12
+ "core-js": "^3.0.0",
13
+ "@teambit/design.ui.surfaces.menu.link-item": "0.0.379",
14
+ "@teambit/evangelist.elements.icon": "1.0.2",
15
+ "@teambit/evangelist.surfaces.dropdown": "1.0.2",
16
+ "@teambit/component.ui.compare": "0.0.1",
17
+ "@teambit/compositions.ui.hooks.use-composition": "0.0.163",
18
+ "@teambit/design.ui.round-loader": "0.0.346",
19
+ "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.487"
20
+ },
21
+ "devDependencies": {
22
+ "@types/react": "^17.0.8",
23
+ "@types/mocha": "9.1.0",
24
+ "@types/testing-library__jest-dom": "5.9.5",
25
+ "@babel/runtime": "7.12.18",
26
+ "@types/jest": "^26.0.0",
27
+ "@types/react-dom": "^17.0.5",
28
+ "@types/node": "12.20.4"
29
+ },
30
+ "peerDependencies": {
31
+ "react-dom": "^16.8.0 || ^17.0.0",
32
+ "react": "^16.8.0 || ^17.0.0"
33
+ },
34
+ "license": "Apache-2.0",
35
+ "bit": {
36
+ "bindingPrefix": "@teambit",
37
+ "env": {},
38
+ "overrides": {
39
+ "dependencies": {
40
+ "@teambit/legacy": "-",
41
+ "core-js": "^3.0.0",
42
+ "react-dom": "-",
43
+ "react": "-"
44
+ },
45
+ "devDependencies": {
46
+ "@teambit/legacy": "-",
47
+ "@types/mocha": "9.1.0",
48
+ "@types/testing-library__jest-dom": "5.9.5",
49
+ "@babel/runtime": "7.12.18",
50
+ "@types/jest": "^26.0.0",
51
+ "@types/react-dom": "^17.0.5",
52
+ "@types/react": "^17.0.8",
53
+ "@types/node": "12.20.4",
54
+ "react-dom": "-",
55
+ "react": "-"
56
+ },
57
+ "peerDependencies": {
58
+ "react-dom": "^16.8.0 || ^17.0.0",
59
+ "react": "^16.8.0 || ^17.0.0"
60
+ }
61
+ }
62
+ },
63
+ "private": false,
64
+ "engines": {
65
+ "node": ">=12.22.0"
66
+ },
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "https://github.com/teambit/bit"
70
+ },
71
+ "keywords": [
72
+ "bit",
73
+ "components",
74
+ "collaboration",
75
+ "web",
76
+ "react",
77
+ "react-components",
78
+ "angular",
79
+ "angular-components",
80
+ "vue",
81
+ "vue-components"
82
+ ]
83
+ }
@@ -0,0 +1 @@
1
+
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": [
4
+ "es2019",
5
+ "DOM",
6
+ "ES6",
7
+ "DOM.Iterable"
8
+ ],
9
+ "target": "es2015",
10
+ "module": "CommonJS",
11
+ "jsx": "react",
12
+ "allowJs": true,
13
+ "composite": true,
14
+ "declaration": true,
15
+ "sourceMap": true,
16
+ "skipLibCheck": true,
17
+ "experimentalDecorators": true,
18
+ "outDir": "dist",
19
+ "moduleResolution": "node",
20
+ "esModuleInterop": true,
21
+ "rootDir": ".",
22
+ "resolveJsonModule": true
23
+ },
24
+ "exclude": [
25
+ "dist",
26
+ "package.json"
27
+ ],
28
+ "include": [
29
+ "**/*",
30
+ "**/*.json"
31
+ ]
32
+ }
@@ -0,0 +1,29 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
9
+ const src: string;
10
+ export default src;
11
+ }
12
+
13
+ // @TODO Gilad
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }