Skip to content

Commit c62b520

Browse files
tay1orjonessstrubbergkodiakhq[bot]
authored
feat(project): add flat exports for namespaced components (#9008)
* feat(project): add flat exports for namespaced components, #8901 * feat(exports): add deprecation notice for namespaced exports * chore: update snaps * test: ignore field deprecation warnings * fix(exports): properly mock deprecateFieldOnObject, add name fallback * test(multiselect): correct import paths, add deprecation mock to tests Co-authored-by: Scott Strubberg <sstrubberg@protonmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent cdd7208 commit c62b520

File tree

16 files changed

+387
-22
lines changed

16 files changed

+387
-22
lines changed

packages/react/__tests__/PublicAPI-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ beforeEach(() => {
124124
* the components that we export and their corresponding API.
125125
*/
126126
test('Public API should only change with a semver change', () => {
127+
jest.mock('../src/internal/deprecateFieldOnObject');
128+
127129
const CarbonReact = require('../src');
128130
const PublicAPI = new Map();
129131

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4331,6 +4331,249 @@ Map {
43314331
},
43324332
"render": [Function],
43334333
},
4334+
"ControlledPasswordInput" => Object {
4335+
"$$typeof": Symbol(react.forward_ref),
4336+
"defaultProps": Object {
4337+
"className": "\${prefix}--text__input",
4338+
"disabled": false,
4339+
"helperText": "",
4340+
"invalid": false,
4341+
"invalidText": "",
4342+
"light": false,
4343+
"onChange": [Function],
4344+
"onClick": [Function],
4345+
"size": "",
4346+
},
4347+
"propTypes": Object {
4348+
"className": Object {
4349+
"type": "string",
4350+
},
4351+
"defaultValue": Object {
4352+
"args": Array [
4353+
Array [
4354+
Object {
4355+
"type": "string",
4356+
},
4357+
Object {
4358+
"type": "number",
4359+
},
4360+
],
4361+
],
4362+
"type": "oneOfType",
4363+
},
4364+
"disabled": Object {
4365+
"type": "bool",
4366+
},
4367+
"helperText": Object {
4368+
"type": "node",
4369+
},
4370+
"hideLabel": Object {
4371+
"type": "bool",
4372+
},
4373+
"hidePasswordLabel": Object {
4374+
"type": "string",
4375+
},
4376+
"id": Object {
4377+
"isRequired": true,
4378+
"type": "string",
4379+
},
4380+
"invalid": Object {
4381+
"type": "bool",
4382+
},
4383+
"invalidText": Object {
4384+
"type": "node",
4385+
},
4386+
"labelText": Object {
4387+
"isRequired": true,
4388+
"type": "node",
4389+
},
4390+
"light": Object {
4391+
"type": "bool",
4392+
},
4393+
"onChange": Object {
4394+
"type": "func",
4395+
},
4396+
"onClick": Object {
4397+
"type": "func",
4398+
},
4399+
"placeholder": Object {
4400+
"type": "string",
4401+
},
4402+
"showPasswordLabel": Object {
4403+
"type": "string",
4404+
},
4405+
"size": Object {
4406+
"type": "string",
4407+
},
4408+
"tooltipAlignment": Object {
4409+
"args": Array [
4410+
Array [
4411+
"start",
4412+
"center",
4413+
"end",
4414+
],
4415+
],
4416+
"type": "oneOf",
4417+
},
4418+
"tooltipPosition": Object {
4419+
"args": Array [
4420+
Array [
4421+
"top",
4422+
"right",
4423+
"bottom",
4424+
"left",
4425+
],
4426+
],
4427+
"type": "oneOf",
4428+
},
4429+
"value": Object {
4430+
"args": Array [
4431+
Array [
4432+
Object {
4433+
"type": "string",
4434+
},
4435+
Object {
4436+
"type": "number",
4437+
},
4438+
],
4439+
],
4440+
"type": "oneOfType",
4441+
},
4442+
},
4443+
"render": [Function],
4444+
},
4445+
"PasswordInput" => Object {
4446+
"$$typeof": Symbol(react.forward_ref),
4447+
"defaultProps": Object {
4448+
"className": "\${prefix}--text__input",
4449+
"disabled": false,
4450+
"helperText": "",
4451+
"invalid": false,
4452+
"invalidText": "",
4453+
"light": false,
4454+
"onChange": [Function],
4455+
"onClick": [Function],
4456+
"size": "",
4457+
},
4458+
"propTypes": Object {
4459+
"className": Object {
4460+
"type": "string",
4461+
},
4462+
"defaultValue": Object {
4463+
"args": Array [
4464+
Array [
4465+
Object {
4466+
"type": "string",
4467+
},
4468+
Object {
4469+
"type": "number",
4470+
},
4471+
],
4472+
],
4473+
"type": "oneOfType",
4474+
},
4475+
"disabled": Object {
4476+
"type": "bool",
4477+
},
4478+
"helperText": Object {
4479+
"type": "node",
4480+
},
4481+
"hideLabel": Object {
4482+
"type": "bool",
4483+
},
4484+
"hidePasswordLabel": Object {
4485+
"type": "string",
4486+
},
4487+
"id": Object {
4488+
"isRequired": true,
4489+
"type": "string",
4490+
},
4491+
"inline": Object {
4492+
"type": "bool",
4493+
},
4494+
"invalid": Object {
4495+
"type": "bool",
4496+
},
4497+
"invalidText": Object {
4498+
"type": "node",
4499+
},
4500+
"labelText": Object {
4501+
"isRequired": true,
4502+
"type": "node",
4503+
},
4504+
"light": Object {
4505+
"type": "bool",
4506+
},
4507+
"onChange": Object {
4508+
"type": "func",
4509+
},
4510+
"onClick": Object {
4511+
"type": "func",
4512+
},
4513+
"onTogglePasswordVisibility": Object {
4514+
"type": "func",
4515+
},
4516+
"placeholder": Object {
4517+
"type": "string",
4518+
},
4519+
"showPasswordLabel": Object {
4520+
"type": "string",
4521+
},
4522+
"size": Object {
4523+
"type": "string",
4524+
},
4525+
"tooltipAlignment": Object {
4526+
"args": Array [
4527+
Array [
4528+
"start",
4529+
"center",
4530+
"end",
4531+
],
4532+
],
4533+
"type": "oneOf",
4534+
},
4535+
"tooltipPosition": Object {
4536+
"args": Array [
4537+
Array [
4538+
"top",
4539+
"right",
4540+
"bottom",
4541+
"left",
4542+
],
4543+
],
4544+
"type": "oneOf",
4545+
},
4546+
"type": Object {
4547+
"args": Array [
4548+
Array [
4549+
"password",
4550+
"text",
4551+
],
4552+
],
4553+
"type": "oneOf",
4554+
},
4555+
"value": Object {
4556+
"args": Array [
4557+
Array [
4558+
Object {
4559+
"type": "string",
4560+
},
4561+
Object {
4562+
"type": "number",
4563+
},
4564+
],
4565+
],
4566+
"type": "oneOfType",
4567+
},
4568+
"warn": Object {
4569+
"type": "bool",
4570+
},
4571+
"warnText": Object {
4572+
"type": "node",
4573+
},
4574+
},
4575+
"render": [Function],
4576+
},
43344577
"PrimaryButton" => Object {},
43354578
"ProgressIndicator" => Object {
43364579
"defaultProps": Object {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Namespaced exports
2+
3+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
4+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
5+
6+
## Table of Contents
7+
8+
- [Overview](#overview)
9+
- [Process](#process)
10+
- [Changes:](#changes)
11+
12+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
13+
14+
## Overview
15+
16+
In v10.x there were a few exported components that were only exposed under the
17+
namespace of another component. These have been deprecated, and a new export has
18+
been made available for each so these can be imported directly. In v11.x the
19+
namespaced exports will be removed.
20+
21+
## Process
22+
23+
1. Update imports for the components listed in the table below.
24+
25+
```diff
26+
- import { TextInput } from 'carbon-components-react';
27+
+ import { PasswordInput } from 'carbon-components-react';
28+
```
29+
30+
2. Update usages of the components listed in the table below, they no longer
31+
need the namespace
32+
33+
```diff
34+
- <TextInput.PasswordInput/>
35+
+ <PasswordInput/>
36+
```
37+
38+
## Changes:
39+
40+
| v10.x | v11.x |
41+
| ----------------------------------- | ------------------------- |
42+
| `TextInput.ControlledPasswordInput` | `ControlledPasswordInput` |
43+
| `TextInput.PasswordInput` | `PasswordInput` |
44+
| `MultiSelect.Filterable` | `FilterableMultiSelect` |

packages/react/src/__tests__/index-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('Carbon Components React', () => {
3535
"ComposedModal",
3636
"Content",
3737
"ContentSwitcher",
38+
"ControlledPasswordInput",
3839
"Copy",
3940
"CopyButton",
4041
"DangerButton",
@@ -96,6 +97,7 @@ describe('Carbon Components React', () => {
9697
"Pagination",
9798
"PaginationNav",
9899
"PaginationSkeleton",
100+
"PasswordInput",
99101
"PrimaryButton",
100102
"ProgressIndicator",
101103
"ProgressIndicatorSkeleton",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export FilterableMultiSelect from '../MultiSelect/FilterableMultiSelect';

packages/react/src/components/MultiSelect/MultiSelect-story.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { withReadme } from 'storybook-readme';
1818
import readme from './README.md';
1919
import MultiSelect from '../MultiSelect';
20+
import FilterableMultiSelect from '../MultiSelect/FilterableMultiSelect';
2021
import Checkbox from '../Checkbox';
2122
import mdx from './MultiSelect.mdx';
2223

@@ -116,7 +117,7 @@ export default {
116117
page: mdx,
117118
},
118119
subcomponents: {
119-
'MultiSelect.Filterable': MultiSelect.Filterable,
120+
FilterableMultiSelect,
120121
},
121122
},
122123
};
@@ -190,7 +191,7 @@ export const _Filterable = withReadme(readme, () => {
190191

191192
return (
192193
<div style={{ width: 300 }}>
193-
<MultiSelect.Filterable
194+
<FilterableMultiSelect
194195
{...multiSelectProps}
195196
items={items}
196197
itemToString={(item) => (item ? item.text : '')}

0 commit comments

Comments
 (0)