Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(project): add flat exports for namespaced components #9008

Merged
merged 9 commits into from
Jul 23, 2021
2 changes: 2 additions & 0 deletions packages/react/__tests__/PublicAPI-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ beforeEach(() => {
* the components that we export and their corresponding API.
*/
test('Public API should only change with a semver change', () => {
jest.mock('../src/internal/deprecateFieldOnObject');

const CarbonReact = require('../src');
const PublicAPI = new Map();

Expand Down
243 changes: 243 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4331,6 +4331,249 @@ Map {
},
"render": [Function],
},
"ControlledPasswordInput" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"className": "\${prefix}--text__input",
"disabled": false,
"helperText": "",
"invalid": false,
"invalidText": "",
"light": false,
"onChange": [Function],
"onClick": [Function],
"size": "",
},
"propTypes": Object {
"className": Object {
"type": "string",
},
"defaultValue": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"disabled": Object {
"type": "bool",
},
"helperText": Object {
"type": "node",
},
"hideLabel": Object {
"type": "bool",
},
"hidePasswordLabel": Object {
"type": "string",
},
"id": Object {
"isRequired": true,
"type": "string",
},
"invalid": Object {
"type": "bool",
},
"invalidText": Object {
"type": "node",
},
"labelText": Object {
"isRequired": true,
"type": "node",
},
"light": Object {
"type": "bool",
},
"onChange": Object {
"type": "func",
},
"onClick": Object {
"type": "func",
},
"placeholder": Object {
"type": "string",
},
"showPasswordLabel": Object {
"type": "string",
},
"size": Object {
"type": "string",
},
"tooltipAlignment": Object {
"args": Array [
Array [
"start",
"center",
"end",
],
],
"type": "oneOf",
},
"tooltipPosition": Object {
"args": Array [
Array [
"top",
"right",
"bottom",
"left",
],
],
"type": "oneOf",
},
"value": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
},
"render": [Function],
},
"PasswordInput" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"className": "\${prefix}--text__input",
"disabled": false,
"helperText": "",
"invalid": false,
"invalidText": "",
"light": false,
"onChange": [Function],
"onClick": [Function],
"size": "",
},
"propTypes": Object {
"className": Object {
"type": "string",
},
"defaultValue": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"disabled": Object {
"type": "bool",
},
"helperText": Object {
"type": "node",
},
"hideLabel": Object {
"type": "bool",
},
"hidePasswordLabel": Object {
"type": "string",
},
"id": Object {
"isRequired": true,
"type": "string",
},
"inline": Object {
"type": "bool",
},
"invalid": Object {
"type": "bool",
},
"invalidText": Object {
"type": "node",
},
"labelText": Object {
"isRequired": true,
"type": "node",
},
"light": Object {
"type": "bool",
},
"onChange": Object {
"type": "func",
},
"onClick": Object {
"type": "func",
},
"onTogglePasswordVisibility": Object {
"type": "func",
},
"placeholder": Object {
"type": "string",
},
"showPasswordLabel": Object {
"type": "string",
},
"size": Object {
"type": "string",
},
"tooltipAlignment": Object {
"args": Array [
Array [
"start",
"center",
"end",
],
],
"type": "oneOf",
},
"tooltipPosition": Object {
"args": Array [
Array [
"top",
"right",
"bottom",
"left",
],
],
"type": "oneOf",
},
"type": Object {
"args": Array [
Array [
"password",
"text",
],
],
"type": "oneOf",
},
"value": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"warn": Object {
"type": "bool",
},
"warnText": Object {
"type": "node",
},
},
"render": [Function],
},
"PrimaryButton" => Object {},
"ProgressIndicator" => Object {
"defaultProps": Object {
Expand Down
44 changes: 44 additions & 0 deletions packages/react/docs/migration/11.x-namespaced-exports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Namespaced exports

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

## Table of Contents

- [Overview](#overview)
- [Process](#process)
- [Changes:](#changes)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Overview

In v10.x there were a few exported components that were only exposed under the
namespace of another component. These have been deprecated, and a new export has
been made available for each so these can be imported directly. In v11.x the
namespaced exports will be removed.

## Process

1. Update imports for the components listed in the table below.

```diff
- import { TextInput } from 'carbon-components-react';
+ import { PasswordInput } from 'carbon-components-react';
```

2. Update usages of the components listed in the table below, they no longer
need the namespace

```diff
- <TextInput.PasswordInput/>
+ <PasswordInput/>
```

## Changes:
tay1orjones marked this conversation as resolved.
Show resolved Hide resolved

| v10.x | v11.x |
| ----------------------------------- | ------------------------- |
| `TextInput.ControlledPasswordInput` | `ControlledPasswordInput` |
| `TextInput.PasswordInput` | `PasswordInput` |
| `MultiSelect.Filterable` | `FilterableMultiSelect` |
2 changes: 2 additions & 0 deletions packages/react/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('Carbon Components React', () => {
"ComposedModal",
"Content",
"ContentSwitcher",
"ControlledPasswordInput",
"Copy",
"CopyButton",
"DangerButton",
Expand Down Expand Up @@ -96,6 +97,7 @@ describe('Carbon Components React', () => {
"Pagination",
"PaginationNav",
"PaginationSkeleton",
"PasswordInput",
"PrimaryButton",
"ProgressIndicator",
"ProgressIndicatorSkeleton",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export FilterableMultiSelect from '../MultiSelect/FilterableMultiSelect';
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { withReadme } from 'storybook-readme';
import readme from './README.md';
import MultiSelect from '../MultiSelect';
import FilterableMultiSelect from '../MultiSelect/FilterableMultiSelect';
import Checkbox from '../Checkbox';
import mdx from './MultiSelect.mdx';

Expand Down Expand Up @@ -116,7 +117,7 @@ export default {
page: mdx,
},
subcomponents: {
'MultiSelect.Filterable': MultiSelect.Filterable,
FilterableMultiSelect,
},
},
};
Expand Down Expand Up @@ -190,7 +191,7 @@ export const _Filterable = withReadme(readme, () => {

return (
<div style={{ width: 300 }}>
<MultiSelect.Filterable
<FilterableMultiSelect
{...multiSelectProps}
items={items}
itemToString={(item) => (item ? item.text : '')}
Expand Down
Loading