@teambit/lanes.hooks.use-lane-components 0.0.253 → 0.0.255
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.
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ComponentModel } from '@teambit/component';
|
|
2
2
|
import { LaneId } from '@teambit/lane-id';
|
|
3
|
+
import { ComponentDescriptor } from '@teambit/component-descriptor';
|
|
3
4
|
export declare type UseLaneComponentsResult = {
|
|
4
5
|
components?: Array<ComponentModel>;
|
|
6
|
+
componentDescriptors?: Array<ComponentDescriptor>;
|
|
5
7
|
loading?: boolean;
|
|
6
8
|
};
|
|
7
9
|
export declare function useLaneComponents(laneId?: LaneId): UseLaneComponentsResult;
|
|
@@ -4,6 +4,8 @@ exports.useLaneComponents = void 0;
|
|
|
4
4
|
const ui_foundation_ui_hooks_use_data_query_1 = require("@teambit/ui-foundation.ui.hooks.use-data-query");
|
|
5
5
|
const client_1 = require("@apollo/client");
|
|
6
6
|
const component_1 = require("@teambit/component");
|
|
7
|
+
const component_descriptor_1 = require("@teambit/component-descriptor");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
7
9
|
const GET_LANE_COMPONENTS = (0, client_1.gql) `
|
|
8
10
|
query LaneComponent($ids: [String!], $extensionId: String, $skipList: Boolean!) {
|
|
9
11
|
lanes {
|
|
@@ -39,7 +41,7 @@ const GET_LANE_COMPONENTS = (0, client_1.gql) `
|
|
|
39
41
|
${component_1.componentOverviewFields}
|
|
40
42
|
`;
|
|
41
43
|
function useLaneComponents(laneId) {
|
|
42
|
-
var _a;
|
|
44
|
+
var _a, _b;
|
|
43
45
|
const { data, loading } = (0, ui_foundation_ui_hooks_use_data_query_1.useDataQuery)(GET_LANE_COMPONENTS, {
|
|
44
46
|
variables: { ids: [laneId === null || laneId === void 0 ? void 0 : laneId.toString()], skipList: laneId === null || laneId === void 0 ? void 0 : laneId.isDefault() },
|
|
45
47
|
skip: !laneId,
|
|
@@ -49,9 +51,19 @@ function useLaneComponents(laneId) {
|
|
|
49
51
|
const componentModel = component_1.ComponentModel.from(Object.assign(Object.assign({}, component), { host: data.getHost.id }));
|
|
50
52
|
return componentModel;
|
|
51
53
|
});
|
|
54
|
+
const componentDescriptors = (0, lodash_1.compact)((_b = rawComps === null || rawComps === void 0 ? void 0 : rawComps.components) === null || _b === void 0 ? void 0 : _b.map((rawComponent) => {
|
|
55
|
+
const id = rawComponent ? component_1.ComponentID.fromObject(rawComponent.id) : undefined;
|
|
56
|
+
const aspectList = {
|
|
57
|
+
entries: rawComponent === null || rawComponent === void 0 ? void 0 : rawComponent.aspects.map((aspectObject) => {
|
|
58
|
+
return Object.assign(Object.assign({}, aspectObject), { aspectId: aspectObject.id, aspectData: aspectObject.data });
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
return id ? component_descriptor_1.ComponentDescriptor.fromObject({ id: id.toString(), aspectList }) : undefined;
|
|
62
|
+
}));
|
|
52
63
|
return {
|
|
53
64
|
loading,
|
|
54
65
|
components,
|
|
66
|
+
componentDescriptors,
|
|
55
67
|
};
|
|
56
68
|
}
|
|
57
69
|
exports.useLaneComponents = useLaneComponents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-lane-components.js","sourceRoot":"","sources":["../use-lane-components.tsx"],"names":[],"mappings":";;;AAAA,0GAA8E;AAC9E,2CAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"use-lane-components.js","sourceRoot":"","sources":["../use-lane-components.tsx"],"names":[],"mappings":";;;AAAA,0GAA8E;AAC9E,2CAAqC;AACrC,kDAA0F;AAE1F,wEAAoE;AACpE,mCAAiC;AAEjC,MAAM,mBAAmB,GAAG,IAAA,YAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgC3B,mCAAuB;CAC1B,CAAC;AAQF,SAAgB,iBAAiB,CAAC,MAAe;;IAC/C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAA,oDAAY,E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,CAAE,OAAO,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;gBAClD,uCACK,YAAY,KACf,QAAQ,EAAE,YAAY,CAAC,EAAE,EACzB,UAAU,EAAE,YAAY,CAAC,IAAI,IAC7B;YACJ,CAAC,CAAC;SACH,CAAC;QACF,OAAO,EAAE,CAAC,CAAC,CAAC,0CAAmB,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5F,CAAC,CAAC,CACH,CAAC;IAEF,OAAO;QACL,OAAO;QACP,UAAU;QACV,oBAAoB;KACrB,CAAC;AACJ,CAAC;AAlCD,8CAkCC"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/lanes.hooks.use-lane-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.255",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/lanes/hooks/use-lane-components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.lanes",
|
|
8
8
|
"name": "hooks/use-lane-components",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.255"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"
|
|
13
|
-
"@teambit/
|
|
12
|
+
"lodash": "4.17.21",
|
|
13
|
+
"@teambit/lane-id": "0.0.311",
|
|
14
|
+
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.505",
|
|
15
|
+
"@teambit/component-descriptor": "0.0.412"
|
|
14
16
|
},
|
|
15
17
|
"devDependencies": {
|
|
18
|
+
"@types/lodash": "4.14.165",
|
|
16
19
|
"@types/mocha": "9.1.0",
|
|
17
20
|
"@types/jest": "26.0.20",
|
|
18
21
|
"@types/node": "12.20.4",
|
|
@@ -22,6 +25,8 @@
|
|
|
22
25
|
"@apollo/client": "^3.6.0"
|
|
23
26
|
},
|
|
24
27
|
"license": "Apache-2.0",
|
|
28
|
+
"optionalDependencies": {},
|
|
29
|
+
"peerDependenciesMeta": {},
|
|
25
30
|
"private": false,
|
|
26
31
|
"engines": {
|
|
27
32
|
"node": ">=12.22.0"
|
|
@@ -40,4 +45,4 @@
|
|
|
40
45
|
"angular",
|
|
41
46
|
"angular-components"
|
|
42
47
|
]
|
|
43
|
-
}
|
|
48
|
+
}
|
package/use-lane-components.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
|
|
2
2
|
import { gql } from '@apollo/client';
|
|
3
|
-
import { ComponentModel, componentOverviewFields } from '@teambit/component';
|
|
3
|
+
import { ComponentID, ComponentModel, componentOverviewFields } from '@teambit/component';
|
|
4
4
|
import { LaneId } from '@teambit/lane-id';
|
|
5
|
+
import { ComponentDescriptor } from '@teambit/component-descriptor';
|
|
6
|
+
import { compact } from 'lodash';
|
|
5
7
|
|
|
6
8
|
const GET_LANE_COMPONENTS = gql`
|
|
7
9
|
query LaneComponent($ids: [String!], $extensionId: String, $skipList: Boolean!) {
|
|
@@ -40,6 +42,7 @@ const GET_LANE_COMPONENTS = gql`
|
|
|
40
42
|
|
|
41
43
|
export type UseLaneComponentsResult = {
|
|
42
44
|
components?: Array<ComponentModel>;
|
|
45
|
+
componentDescriptors?: Array<ComponentDescriptor>;
|
|
43
46
|
loading?: boolean;
|
|
44
47
|
};
|
|
45
48
|
|
|
@@ -56,8 +59,25 @@ export function useLaneComponents(laneId?: LaneId): UseLaneComponentsResult {
|
|
|
56
59
|
return componentModel;
|
|
57
60
|
});
|
|
58
61
|
|
|
62
|
+
const componentDescriptors: ComponentDescriptor[] = compact(
|
|
63
|
+
rawComps?.components?.map((rawComponent) => {
|
|
64
|
+
const id = rawComponent ? ComponentID.fromObject(rawComponent.id) : undefined;
|
|
65
|
+
const aspectList = {
|
|
66
|
+
entries: rawComponent?.aspects.map((aspectObject) => {
|
|
67
|
+
return {
|
|
68
|
+
...aspectObject,
|
|
69
|
+
aspectId: aspectObject.id,
|
|
70
|
+
aspectData: aspectObject.data,
|
|
71
|
+
};
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
return id ? ComponentDescriptor.fromObject({ id: id.toString(), aspectList }) : undefined;
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
|
|
59
78
|
return {
|
|
60
79
|
loading,
|
|
61
80
|
components,
|
|
81
|
+
componentDescriptors,
|
|
62
82
|
};
|
|
63
83
|
}
|
|
File without changes
|