@teambit/lanes.hooks.use-lane-components 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 @@
1
+ export { useLaneComponents } from './use-lane-components';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLaneComponents = void 0;
4
+ var use_lane_components_1 = require("./use-lane-components");
5
+ Object.defineProperty(exports, "useLaneComponents", { enumerable: true, get: function () { return use_lane_components_1.useLaneComponents; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAAjD,wHAAA,iBAAiB,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
+ }
@@ -0,0 +1,6 @@
1
+ import { QueryResult } from '@apollo/client';
2
+ import { LaneModel, LanesQuery } from '@teambit/lanes.ui.models';
3
+ import { ComponentModel } from '@teambit/component';
4
+ export declare function useLaneComponents(lane: LaneModel): {
5
+ components?: Array<ComponentModel>;
6
+ } & Omit<QueryResult<LanesQuery>, 'data'>;
@@ -0,0 +1,51 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.useLaneComponents = void 0;
15
+ const ui_foundation_ui_hooks_use_data_query_1 = require("@teambit/ui-foundation.ui.hooks.use-data-query");
16
+ const client_1 = require("@apollo/client");
17
+ const component_1 = require("@teambit/component");
18
+ const GET_LANE_COMPONENTS = (0, client_1.gql) `
19
+ query LaneComponent($ids: [String!], $extensionId: String) {
20
+ lanes {
21
+ id
22
+ list(ids: $ids) {
23
+ id
24
+ remote
25
+ isMerged
26
+ components {
27
+ ...componentOverviewFields
28
+ }
29
+ readmeComponent {
30
+ ...componentOverviewFields
31
+ }
32
+ }
33
+ }
34
+ getHost(id: $extensionId) {
35
+ id
36
+ }
37
+ }
38
+ ${component_1.componentOverviewFields}
39
+ `;
40
+ function useLaneComponents(lane) {
41
+ const _a = (0, ui_foundation_ui_hooks_use_data_query_1.useDataQuery)(GET_LANE_COMPONENTS, {
42
+ variables: { ids: [lane.name] },
43
+ }), { data } = _a, rest = __rest(_a, ["data"]);
44
+ const components = data === null || data === void 0 ? void 0 : data.lanes.list[0].components.map((component) => {
45
+ const componentModel = component_1.ComponentModel.from(Object.assign(Object.assign({}, component), { host: data.getHost.id }));
46
+ return componentModel;
47
+ });
48
+ return Object.assign(Object.assign({}, rest), { components });
49
+ }
50
+ exports.useLaneComponents = useLaneComponents;
51
+ //# sourceMappingURL=use-lane-components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-lane-components.js","sourceRoot":"","sources":["../use-lane-components.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,0GAA8E;AAC9E,2CAAkD;AAElD,kDAA6E;AAE7E,MAAM,mBAAmB,GAAG,IAAA,YAAG,EAAA;;;;;;;;;;;;;;;;;;;;IAoB3B,mCAAuB;CAC1B,CAAC;AAEF,SAAgB,iBAAiB,CAAC,IAAe;IAG/C,MAAM,KAAoB,IAAA,oDAAY,EAAC,mBAAmB,EAAE;QAC1D,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;KAChC,CAAC,EAFI,EAAE,IAAI,OAEV,EAFe,IAAI,cAAf,QAAiB,CAErB,CAAC;IAEH,MAAM,UAAU,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAClE,MAAM,cAAc,GAAG,0BAAc,CAAC,IAAI,iCAAM,SAAS,KAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,IAAG,CAAC;QACpF,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,uCACK,IAAI,KACP,UAAU,IACV;AACJ,CAAC;AAhBD,8CAgBC"}
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { useLaneComponents } from './use-lane-components';
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@teambit/lanes.hooks.use-lane-components",
3
+ "version": "0.0.1",
4
+ "main": "dist/index.js",
5
+ "componentId": {
6
+ "scope": "teambit.lanes",
7
+ "name": "hooks/use-lane-components",
8
+ "version": "0.0.1"
9
+ },
10
+ "dependencies": {
11
+ "@teambit/lanes.ui.models": "0.0.1",
12
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.488"
13
+ },
14
+ "devDependencies": {
15
+ "@types/mocha": "9.1.0",
16
+ "@babel/runtime": "7.12.18",
17
+ "@types/node": "12.20.4",
18
+ "@types/jest": "26.0.20"
19
+ },
20
+ "peerDependencies": {
21
+ "@apollo/client": "^3.0.0"
22
+ },
23
+ "license": "Apache-2.0",
24
+ "private": false,
25
+ "engines": {
26
+ "node": ">=12.22.0"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/teambit/bit"
31
+ },
32
+ "keywords": [
33
+ "bit",
34
+ "components",
35
+ "collaboration",
36
+ "web",
37
+ "react",
38
+ "react-components",
39
+ "angular",
40
+ "angular-components",
41
+ "vue",
42
+ "vue-components"
43
+ ]
44
+ }
@@ -0,0 +1,5 @@
1
+ ;
2
+ ;
3
+
4
+ export const compositions = [];
5
+ export const overview = [];
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
+ }
@@ -0,0 +1,45 @@
1
+ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
2
+ import { gql, QueryResult } from '@apollo/client';
3
+ import { LaneModel, LanesQuery } from '@teambit/lanes.ui.models';
4
+ import { ComponentModel, componentOverviewFields } from '@teambit/component';
5
+
6
+ const GET_LANE_COMPONENTS = gql`
7
+ query LaneComponent($ids: [String!], $extensionId: String) {
8
+ lanes {
9
+ id
10
+ list(ids: $ids) {
11
+ id
12
+ remote
13
+ isMerged
14
+ components {
15
+ ...componentOverviewFields
16
+ }
17
+ readmeComponent {
18
+ ...componentOverviewFields
19
+ }
20
+ }
21
+ }
22
+ getHost(id: $extensionId) {
23
+ id
24
+ }
25
+ }
26
+ ${componentOverviewFields}
27
+ `;
28
+
29
+ export function useLaneComponents(lane: LaneModel): {
30
+ components?: Array<ComponentModel>;
31
+ } & Omit<QueryResult<LanesQuery>, 'data'> {
32
+ const { data, ...rest } = useDataQuery(GET_LANE_COMPONENTS, {
33
+ variables: { ids: [lane.name] },
34
+ });
35
+
36
+ const components = data?.lanes.list[0].components.map((component) => {
37
+ const componentModel = ComponentModel.from({ ...component, host: data.getHost.id });
38
+ return componentModel;
39
+ });
40
+
41
+ return {
42
+ ...rest,
43
+ components,
44
+ };
45
+ }