Skip to content

Commit 4d9325b

Browse files
authored
Merge pull request #819 from rvsia/fixCarbonImports
fix(carbon): add seperate transformation for progressStep/structuredList
2 parents fa83fcc + 3f48cc6 commit 4d9325b

File tree

5 files changed

+48
-25
lines changed

5 files changed

+48
-25
lines changed

packages/carbon-component-mapper/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[![Data Driven Form logo](https://raw.githubusercontent.com/data-driven-forms/react-forms/master/images/logo.png)](https://data-driven-forms.org/)
66

7-
carbon component mapper for [Data Driven Forms](https://github.com/data-driven-forms/react-forms).
7+
Carbon component mapper for [Data Driven Forms](https://github.com/data-driven-forms/react-forms).
88

99
:book: For more information please visit the [documentation](https://data-driven-forms.org/). :book:
1010

packages/carbon-component-mapper/rollup.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ const globals = {
3636
'prop-types': 'PropTypes',
3737
'@data-driven-forms/react-form-renderer': '@data-driven-forms/react-form-renderer',
3838
'carbon-components-react': 'carbon-components-react',
39-
'@carbon/icons-react': '@carbon/icons-react'
39+
'@carbon/icons-react': '@carbon/icons-react',
40+
'carbon-components-react/lib/components/StructuredList/StructuredList': 'carbon-components-react/lib/components/StructuredList/StructuredList',
41+
'carbon-components-react/lib/components/ProgressIndicator/ProgressIndicator':
42+
'carbon-components-react/lib/components/ProgressIndicator/ProgressIndicator'
4043
};
4144

4245
const babelOptions = {

packages/carbon-component-mapper/src/files/dual-list-select.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ import PropTypes from 'prop-types';
33
import DualListSelectCommon from '@data-driven-forms/common/src/dual-list-select';
44
import clsx from 'clsx';
55

6+
import { Grid, Row, Column, Button, FormGroup, Search, TooltipIcon } from 'carbon-components-react';
7+
import { CheckmarkFilled16, ChevronRight32, ChevronLeft32, CaretSortDown32, CaretSortUp32 } from '@carbon/icons-react';
8+
69
import {
710
StructuredListWrapper,
8-
Grid,
9-
Row,
10-
Column,
11-
StructuredListBody,
1211
StructuredListRow,
13-
StructuredListCell,
14-
Button,
15-
FormGroup,
16-
Search,
17-
TooltipIcon
18-
} from 'carbon-components-react';
19-
import { CheckmarkFilled16, ChevronRight32, ChevronLeft32, CaretSortDown32, CaretSortUp32 } from '@carbon/icons-react';
12+
StructuredListBody,
13+
StructuredListCell
14+
} from 'carbon-components-react/lib/components/StructuredList/StructuredList';
2015

2116
import './dual-list-select.scss';
2217

packages/carbon-component-mapper/src/files/wizard.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import clsx from 'clsx';
44

55
import WizardCommon from '@data-driven-forms/common/src/wizard/wizard';
66
import { FormSpy, WizardContext } from '@data-driven-forms/react-form-renderer';
7-
import { ProgressIndicator, ProgressStep, Button, Column, Grid, Row } from 'carbon-components-react';
7+
import { Button, Column, Grid, Row } from 'carbon-components-react';
8+
9+
import { ProgressStep, ProgressIndicator } from 'carbon-components-react/lib/components/ProgressIndicator/ProgressIndicator';
810

911
import './wizard.scss';
1012

packages/common/babel.config.js

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,39 @@ const createCarbonCJSTransform = (env) => [
201201
},
202202
preventFullImport: false,
203203
skipDefaultConversion: false
204-
}
205-
},
206-
`carbon-components-react-${env}`
207-
];
208-
209-
const createCarbonIconsCJSTransform = (env) => [
210-
'transform-imports',
211-
{
204+
},
205+
'carbon-components-react/lib/components/StructuredList/StructuredList': {
206+
transform: (importName) => {
207+
let res;
208+
const files = glob.sync(path.resolve(__dirname, `../../node_modules/carbon-components-react/${env === 'cjs' ? 'lib' : 'es' }/**/${carbonMapper(importName)}.js`));
209+
if (files.length > 0) {
210+
res = files[0];
211+
} else {
212+
throw new Error(`File with importName ${importName} does not exist`);
213+
}
214+
res = res.replace(path.resolve(__dirname, '../../node_modules/'), '');
215+
res = res.replace(/^\//, '');
216+
return res;
217+
},
218+
preventFullImport: false,
219+
skipDefaultConversion: true
220+
},
221+
'carbon-components-react/lib/components/ProgressIndicator/ProgressIndicator': {
222+
transform: (importName) => {
223+
let res;
224+
const files = glob.sync(path.resolve(__dirname, `../../node_modules/carbon-components-react/${env === 'cjs' ? 'lib' : 'es' }/**/${carbonMapper(importName)}.js`));
225+
if (files.length > 0) {
226+
res = files[0];
227+
} else {
228+
throw new Error(`File with importName ${importName} does not exist`);
229+
}
230+
res = res.replace(path.resolve(__dirname, '../../node_modules/'), '');
231+
res = res.replace(/^\//, '');
232+
return res;
233+
},
234+
preventFullImport: false,
235+
skipDefaultConversion: true
236+
},
212237
'@carbon/icons-react': {
213238
transform: (importName) => {
214239
let size = importName.match(/\d+/)[0];
@@ -229,7 +254,7 @@ const createCarbonIconsCJSTransform = (env) => [
229254
skipDefaultConversion: false
230255
}
231256
},
232-
`@carbon/icons-react-${env}`
257+
`carbon-components-react-${env}`
233258
];
234259

235260
module.exports = {
@@ -243,7 +268,6 @@ module.exports = {
243268
createBluePrintTransform('cjs'),
244269
createAntTransform('cjs'),
245270
createCarbonCJSTransform('cjs'),
246-
createCarbonIconsCJSTransform('cjs')
247271
]
248272
},
249273
esm: {
@@ -254,7 +278,6 @@ module.exports = {
254278
createBluePrintTransform('esm'),
255279
createAntTransform('esm'),
256280
createCarbonCJSTransform('esm'),
257-
createCarbonIconsCJSTransform('esm')
258281
]
259282
}
260283
}

0 commit comments

Comments
 (0)