Skip to content

Commit 24e36e9

Browse files
authored
Merge branch 'adobe:main' into fix-ssr-on-react-18-strictmode
2 parents 925383e + 286dbcd commit 24e36e9

File tree

142 files changed

+5645
-3411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+5645
-3411
lines changed

.circleci/comment.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const Octokit = require('@octokit/rest');
2+
const fs = require('fs');
23

34
const octokit = new Octokit({
45
auth: `token ${process.env.GITHUB_TOKEN}`
@@ -64,6 +65,7 @@ async function run() {
6465
}
6566

6667
if (pr != null) {
68+
let diffs = fs.readFileSync('/tmp/dist/ts-diff.txt');
6769
await octokit.issues.createComment({
6870
owner: 'adobe',
6971
repo: 'react-spectrum',
@@ -75,5 +77,14 @@ async function run() {
7577
* [View the storybook-16](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-16/index.html)
7678
* [View the documentation](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/docs/index.html)`
7779
});
80+
if (diffs.length > 0) {
81+
await octokit.issues.createComment({
82+
owner: 'adobe',
83+
repo: 'react-spectrum',
84+
issue_number: pr,
85+
body: `## API Changes
86+
${diffs}
87+
`});
88+
}
7889
}
7990
}

.circleci/config.yml

Lines changed: 86 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,57 @@ jobs:
216216
name: lint
217217
command: yarn lint
218218

219+
ts-build-branch:
220+
executor: rsp-large
221+
steps:
222+
- restore_cache:
223+
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
224+
225+
- run:
226+
name: build branch apis
227+
command: yarn build:api-branch
228+
229+
- persist_to_workspace:
230+
root: dist
231+
paths:
232+
- 'branch-api/'
233+
234+
ts-build-fork-point:
235+
executor: rsp-large
236+
steps:
237+
- restore_cache:
238+
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
239+
240+
- run:
241+
name: build fork-point apis
242+
command: |
243+
yarn build:api-branch --githash="origin/main" --output="base-api" && yarn build:api-branch && yarn compare:apis
244+
245+
- persist_to_workspace:
246+
root: dist
247+
paths:
248+
- 'base-api/'
249+
250+
ts-diff:
251+
executor: rsp-large
252+
steps:
253+
- restore_cache:
254+
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
255+
256+
- attach_workspace:
257+
at: /tmp/dist
258+
259+
- run:
260+
name: compare api
261+
command: |
262+
mkdir -p dist
263+
yarn --silent compare:apis --isCI --branch-api-dir="/tmp/dist/branch-api" --base-api-dir="/tmp/dist/base-api" | tee dist/ts-diff.txt
264+
265+
- persist_to_workspace:
266+
root: dist
267+
paths:
268+
- 'ts-diff.txt'
269+
219270
storybook:
220271
executor: rsp-large
221272
steps:
@@ -349,6 +400,9 @@ jobs:
349400
- restore_cache:
350401
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
351402

403+
- attach_workspace:
404+
at: /tmp/dist
405+
352406
- run:
353407
name: comment on pr
354408
command: |
@@ -398,6 +452,25 @@ workflows:
398452
- lint:
399453
requires:
400454
- install
455+
- ts-build-fork-point:
456+
requires:
457+
- install
458+
filters:
459+
branches:
460+
ignore: main
461+
- ts-build-branch:
462+
requires:
463+
- install
464+
filters:
465+
branches:
466+
ignore: main
467+
- ts-diff:
468+
requires:
469+
- ts-build-fork-point
470+
- ts-build-branch
471+
filters:
472+
branches:
473+
ignore: main
401474
- storybook:
402475
requires:
403476
- install
@@ -410,12 +483,12 @@ workflows:
410483
- docs:
411484
requires:
412485
- install
413-
- docs-production:
414-
filters:
415-
branches:
416-
only: main
417-
requires:
418-
- install
486+
# - docs-production:
487+
# filters:
488+
# branches:
489+
# only: main
490+
# requires:
491+
# - install
419492
- docs-verdaccio:
420493
filters:
421494
branches:
@@ -435,12 +508,12 @@ workflows:
435508
- storybook-16
436509
- storybook-17
437510
- docs
438-
- deploy-production:
439-
filters:
440-
branches:
441-
only: main
442-
requires:
443-
- docs-production
511+
# - deploy-production:
512+
# filters:
513+
# branches:
514+
# only: main
515+
# requires:
516+
# - docs-production
444517
- deploy-verdaccio:
445518
requires:
446519
- docs-verdaccio
@@ -450,6 +523,7 @@ workflows:
450523
branches:
451524
ignore: main
452525
requires:
526+
- ts-diff
453527
- deploy
454528
- comment:
455529
name: comment-verdaccio

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ rulesDirPlugin.RULES_DIR = './bin';
77
module.exports = {
88
plugins: ['react', 'rulesdir', 'jsx-a11y', 'react-hooks', 'jest', 'monorepo', 'eslint-plugin-rsp-rules'],
99
extends: ['eslint:recommended'],
10-
parser: 'babel-eslint',
10+
parser: '@babel/eslint-parser',
1111
parserOptions: {
1212
ecmaFeatures: {
1313
'legacyDecorators': true
@@ -149,7 +149,7 @@ module.exports = {
149149
'react/no-did-update-set-state': ERROR,
150150
'react/no-multi-comp': OFF,
151151
'react/no-set-state': OFF,
152-
'react/no-unknown-property': ERROR,
152+
'react/no-unknown-property': [ERROR, {ignore: ['prefix']}],
153153
'react/react-in-jsx-scope': ERROR,
154154
'react/require-extension': OFF,
155155
'react/jsx-equals-spacing': ERROR,

bin/sort-imports.js

Lines changed: 67 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,77 +10,82 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
module.exports = function (context) {
14-
const sourceCode = context.getSourceCode();
15-
let previousDeclaration = null;
13+
module.exports = {
14+
meta: {
15+
fixable: 'code'
16+
},
17+
create: function (context) {
18+
const sourceCode = context.getSourceCode();
19+
let previousDeclaration = null;
1620

17-
/**
18-
* Gets the local name of the first imported module.
19-
* @param {ASTNode} node - the ImportDeclaration node.
20-
* @returns {?string} the local name of the first imported module.
21-
*/
22-
function getFirstLocalMemberName(node) {
23-
if (node.specifiers[0]) {
24-
return node.specifiers[0].local.name.toLowerCase();
25-
}
26-
return null;
21+
/**
22+
* Gets the local name of the first imported module.
23+
* @param {ASTNode} node - the ImportDeclaration node.
24+
* @returns {?string} the local name of the first imported module.
25+
*/
26+
function getFirstLocalMemberName(node) {
27+
if (node.specifiers[0]) {
28+
return node.specifiers[0].local.name.toLowerCase();
29+
}
30+
return null;
2731

28-
}
32+
}
2933

30-
return {
31-
ImportDeclaration(node) {
32-
if (previousDeclaration) {
33-
let currentLocalMemberName = getFirstLocalMemberName(node),
34-
previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
34+
return {
35+
ImportDeclaration(node) {
36+
if (previousDeclaration) {
37+
let currentLocalMemberName = getFirstLocalMemberName(node),
38+
previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
3539

36-
if (previousLocalMemberName &&
37-
currentLocalMemberName &&
38-
currentLocalMemberName < previousLocalMemberName
39-
) {
40-
context.report({
41-
node,
42-
message: "Imports should be sorted alphabetically."
43-
});
40+
if (previousLocalMemberName &&
41+
currentLocalMemberName &&
42+
currentLocalMemberName < previousLocalMemberName
43+
) {
44+
context.report({
45+
node,
46+
message: 'Imports should be sorted alphabetically.'
47+
});
48+
}
4449
}
45-
}
4650

47-
const importSpecifiers = node.specifiers.filter(specifier => specifier.type === "ImportSpecifier");
48-
const getSortableName = specifier => specifier.local.name.toLowerCase();
49-
const firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex((name, index, array) => array[index - 1] > name);
51+
const importSpecifiers = node.specifiers.filter(specifier => specifier.type === 'ImportSpecifier');
52+
const getSortableName = specifier => specifier.local.name.toLowerCase();
53+
const firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex((name, index, array) => array[index - 1] > name);
5054

51-
if (firstUnsortedIndex !== -1) {
52-
context.report({
53-
node: importSpecifiers[firstUnsortedIndex],
54-
message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.",
55-
data: { memberName: importSpecifiers[firstUnsortedIndex].local.name },
56-
fix(fixer) {
57-
return fixer.replaceTextRange(
58-
[importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]],
59-
importSpecifiers
60-
// Clone the importSpecifiers array to avoid mutating it
61-
.slice()
55+
if (firstUnsortedIndex !== -1) {
56+
context.report({
57+
node: importSpecifiers[firstUnsortedIndex],
58+
message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.",
59+
data: {memberName: importSpecifiers[firstUnsortedIndex].local.name},
60+
fix(fixer) {
61+
return fixer.replaceTextRange(
62+
[importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]],
63+
importSpecifiers
64+
// Clone the importSpecifiers array to avoid mutating it
65+
.slice()
6266

63-
// Sort the array into the desired order
64-
.sort((specifierA, specifierB) => {
65-
const aName = getSortableName(specifierA);
66-
const bName = getSortableName(specifierB);
67-
return aName > bName ? 1 : -1;
68-
})
67+
// Sort the array into the desired order
68+
.sort((specifierA, specifierB) => {
69+
const aName = getSortableName(specifierA);
70+
const bName = getSortableName(specifierB);
71+
return aName > bName ? 1 : -1;
72+
})
6973

70-
// Build a string out of the sorted list of import specifiers and the text between the originals
71-
.reduce((sourceText, specifier, index) => {
72-
const textAfterSpecifier = index === importSpecifiers.length - 1
73-
? ""
74-
: sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]);
74+
// Build a string out of the sorted list of import specifiers and the text between the originals
75+
.reduce((sourceText, specifier, index) => {
76+
const textAfterSpecifier = index === importSpecifiers.length - 1
77+
? ''
78+
: sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]);
7579

76-
return sourceText + sourceCode.getText(specifier) + textAfterSpecifier;
77-
}, "")
78-
);
79-
}
80-
});
81-
}
80+
return sourceText + sourceCode.getText(specifier) + textAfterSpecifier;
81+
}, '')
82+
);
83+
}
84+
});
85+
}
8286

83-
previousDeclaration = node;
84-
}
85-
};
87+
previousDeclaration = node;
88+
}
89+
};
90+
}
8691
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Item, ListView, Text, useListData } from "@adobe/react-spectrum";
2+
import { useDragAndDrop } from "@react-spectrum/dnd";
3+
import Folder from "@spectrum-icons/illustrations/Folder";
4+
5+
export default function ReorderableListView() {
6+
let list = useListData({
7+
initialItems: [
8+
{ id: "1", type: "file", name: "Adobe Photoshop" },
9+
{ id: "2", type: "file", name: "Adobe XD" },
10+
{ id: "3", type: "folder", name: "Documents", childNodes: [] },
11+
{ id: "4", type: "file", name: "Adobe InDesign" },
12+
{ id: "5", type: "folder", name: "Utilities", childNodes: [] },
13+
{ id: "6", type: "file", name: "Adobe AfterEffects" },
14+
],
15+
});
16+
17+
// Append a generated key to the item type so they can only be reordered within this list and not dragged elsewhere.
18+
let { dragAndDropHooks } = useDragAndDrop({
19+
getItems(keys) {
20+
return [...keys].map((key) => {
21+
let item = list.getItem(key);
22+
// Setup the drag types and associated info for each dragged item.
23+
return {
24+
"custom-app-type-reorder": JSON.stringify(item),
25+
"text/plain": item.name,
26+
};
27+
});
28+
},
29+
acceptedDragTypes: ["custom-app-type-reorder"],
30+
onReorder: async (e) => {
31+
let { keys, target, dropOperation } = e;
32+
33+
if (target.dropPosition === "before") {
34+
list.moveBefore(target.key, [...keys]);
35+
} else if (target.dropPosition === "after") {
36+
list.moveAfter(target.key, [...keys]);
37+
}
38+
},
39+
getAllowedDropOperations: () => ["move"],
40+
});
41+
42+
return (
43+
<ListView
44+
aria-label="Reorderable ListView"
45+
selectionMode="multiple"
46+
width="size-3600"
47+
height="size-3600"
48+
items={list.items}
49+
dragAndDropHooks={dragAndDropHooks}
50+
>
51+
{(item) => (
52+
<Item textValue={item.name}>
53+
{item.type === "folder" && <Folder />}
54+
<Text>{item.name}</Text>
55+
</Item>
56+
)}
57+
</ListView>
58+
);
59+
}

examples/rsp-next-ts/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const withTM = require("next-transpile-modules")([
1313
"@react-spectrum/datepicker",
1414
"@react-spectrum/dialog",
1515
"@react-spectrum/divider",
16+
"@react-spectrum/dnd",
1617
"@react-spectrum/form",
1718
"@react-spectrum/icon",
1819
"@react-spectrum/illustratedmessage",

0 commit comments

Comments
 (0)