Skip to content

Commit 7c81ea2

Browse files
committed
Merge remote-tracking branch 'upstream/main' into tree-dnd
2 parents 121712a + 412a518 commit 7c81ea2

File tree

236 files changed

+7580
-2599
lines changed

Some content is hidden

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

236 files changed

+7580
-2599
lines changed

CODE_OF_CONDUCT.md

+53-48
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,78 @@
22

33
## Our Pledge
44

5-
In the interest of fostering an open and welcoming environment, we as
6-
contributors and maintainers pledge to making participation in our project and
7-
our community a harassment-free experience for everyone, regardless of age, body
8-
size, disability, ethnicity, gender identity and expression, level of experience,
9-
nationality, personal appearance, race, religion, or sexual identity and
10-
orientation.
5+
We as members, contributors, and leaders pledge to make participation in our project and community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
118

129
## Our Standards
1310

14-
Examples of behavior that contributes to creating a positive environment
15-
include:
11+
Examples of behavior that contribute to a positive environment for our project and community include:
1612

17-
* Using welcoming and inclusive language.
18-
* Being respectful of differing viewpoints and experiences.
19-
* Gracefully accepting constructive criticism.
20-
* Focusing on what is best for the community.
21-
* Showing empathy towards other community members.
13+
* Demonstrating empathy and kindness toward other people
14+
* Being respectful of differing opinions, viewpoints, and experiences
15+
* Giving and gracefully accepting constructive feedback
16+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
* Focusing on what is best, not just for us as individuals but for the overall community
2218

23-
Examples of unacceptable behavior by participants include:
19+
Examples of unacceptable behavior include:
2420

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances.
27-
* Trolling, insulting/derogatory comments, and personal or political attacks.
28-
* Public or private harassment.
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission.
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting.
21+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
22+
* Trolling, insulting or derogatory comments, and personal or political attacks
23+
* Public or private harassment
24+
* Publishing others’ private information, such as a physical or email address, without their explicit permission
25+
* Other conduct which could reasonably be considered inappropriate in a professional setting
3326

3427
## Our Responsibilities
3528

36-
Project maintainers are responsible for clarifying the standards of acceptable
37-
behavior and are expected to take appropriate and fair corrective action in
38-
response to any instances of unacceptable behavior.
29+
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any instances of unacceptable behavior.
3930

40-
Project maintainers have the right and responsibility to remove, edit, or
41-
reject comments, commits, code, wiki edits, issues, and other contributions
42-
that are not aligned to this Code of Conduct, or to ban temporarily or
43-
permanently any contributor for other behaviors that they deem inappropriate,
44-
threatening, offensive, or harmful.
31+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for behaviors that they deem inappropriate, threatening, offensive, or harmful.
4532

4633
## Scope
4734

48-
This Code of Conduct applies both within project spaces and in public spaces
49-
when an individual is representing the project or its community. Examples of
50-
representing a project or community include using an official project e-mail
51-
address, posting via an official social media account, or acting as an appointed
52-
representative at an online or offline event. Representation of a project may be
53-
further defined and clarified by project maintainers.
35+
This Code of Conduct applies when an individual is representing the project or its community both within project spaces and in public spaces. Examples of representing a project or community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
5436

5537
## Enforcement
5638

57-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at Grp-opensourceoffice@adobe.com. All
59-
complaints will be reviewed and investigated and will result in a response that
60-
is deemed necessary and appropriate to the circumstances. The project team is
61-
obligated to maintain confidentiality with regard to the reporter of an incident.
62-
Further details of specific enforcement policies may be posted separately.
39+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by first contacting the project team. Oversight of Adobe projects is handled by the Adobe Open Source Office, which has final say in any violations and enforcement of this Code of Conduct and can be reached at Grp-opensourceoffice@adobe.com. All complaints will be reviewed and investigated promptly and fairly.
40+
41+
The project team must respect the privacy and security of the reporter of any incident.
42+
43+
Project maintainers who do not follow or enforce the Code of Conduct may face temporary or permanent repercussions as determined by other members of the project's leadership or the Adobe Open Source Office.
44+
45+
## Enforcement Guidelines
46+
47+
Project maintainers will follow these Community Impact Guidelines in determining the consequences for any action they deem to be in violation of this Code of Conduct:
48+
49+
**1. Correction**
50+
51+
Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
52+
53+
Consequence: A private, written warning from project maintainers describing the violation and why the behavior was unacceptable. A public apology may be requested from the violator before any further involvement in the project by violator.
54+
55+
**2. Warning**
56+
57+
Community Impact: A relatively minor violation through a single incident or series of actions.
58+
59+
Consequence: A written warning from project maintainers that includes stated consequences for continued unacceptable behavior. Violator must refrain from interacting with the people involved for a specified period of time as determined by the project maintainers, including, but not limited to, unsolicited interaction with those enforcing the Code of Conduct through channels such as community spaces and social media. Continued violations may lead to a temporary or permanent ban.
60+
61+
**3. Temporary Ban**
62+
63+
Community Impact: A more serious violation of community standards, including sustained unacceptable behavior.
64+
65+
Consequence: A temporary ban from any interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Failure to comply with the temporary ban may lead to a permanent ban.
66+
67+
**4. Permanent Ban**
68+
69+
Community Impact: Demonstrating a consistent pattern of violation of community standards or an egregious violation of community standards, including, but not limited to, sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
6370

64-
Project maintainers who do not follow or enforce the Code of Conduct in good
65-
faith may face temporary or permanent repercussions as determined by other
66-
members of the project's leadership.
71+
Consequence: A permanent ban from any interaction with the community.
6772

6873
## Attribution
6974

70-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71-
available at [https://contributor-covenant.org/version/1/4][version].
75+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1,
76+
available at [https://contributor-covenant.org/version/2/1][version]
7277

7378
[homepage]: https://contributor-covenant.org
74-
[version]: https://contributor-covenant.org/version/1/4/
79+
[version]: https://contributor-covenant.org/version/2/1

CONTRIBUTING.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ You may have run `yarn build` before. Please run `make clean_all && yarn` to cle
216216

217217
It may also just be a stale cache, you can try deleting the `.parcel-cache`
218218

219-
## Contributor to committer
219+
## From Contributor To Committer
220220

221-
We love contributions from our community! If you'd like to go a step beyond contributor and become a committer with full write access and a say in the project, you must be invited. The existing committers employ an internal nomination process that must reach lazy consensus (silence is approval) before invitations are issued. If you feel you are qualified and want to get more deeply involved, feel free to reach out to existing committers to have a conversation.
221+
We love contributions from our community! At this time, we are not accepting new committers. We thank you for your understanding.
222+
223+
## Security Issues
224+
225+
Security issues shouldn't be reported on this issue tracker. Instead, [file an issue to our security experts](https://helpx.adobe.com/security/alertus.html).

NOTICE.txt

+29
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,32 @@ This codebase contains a modified portion of code from Yarn berry which can be o
211211
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
212212

213213
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
214+
215+
216+
-------------------------------------------------------------------------------
217+
This codebase contains a modified portion of code from Microsoft which can be obtained at:
218+
* SOURCE:
219+
* https://github.com/microsoft/tabster
220+
221+
* LICENSE:
222+
MIT License
223+
224+
Copyright (c) Microsoft Corporation.
225+
226+
Permission is hereby granted, free of charge, to any person obtaining a copy
227+
of this software and associated documentation files (the "Software"), to deal
228+
in the Software without restriction, including without limitation the rights
229+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
230+
copies of the Software, and to permit persons to whom the Software is
231+
furnished to do so, subject to the following conditions:
232+
233+
The above copyright notice and this permission notice shall be included in all
234+
copies or substantial portions of the Software.
235+
236+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
237+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
238+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
239+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
240+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
241+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
242+
SOFTWARE

bin/pure-render.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ module.exports = {
5252
node.type === 'IfStatement' &&
5353
node.test.type === 'BinaryExpression' &&
5454
(node.test.operator === '==' || node.test.operator === '===') &&
55-
isMemberExpressionEqual(node.test.left, member)
55+
(isMemberExpressionEqual(node.test.left, member) ||
56+
isMemberExpressionEqual(node.test.right, member))
5657
) {
5758
conditional = node.test;
5859
}
@@ -98,7 +99,7 @@ module.exports = {
9899
type: 'Identifier',
99100
name: 'undefined'
100101
};
101-
if (isLiteralEqual(conditional.operator, init, conditional.right)) {
102+
if (isLiteralEqual(conditional.operator, init, conditional.right) || isLiteralEqual(conditional.operator, init, conditional.left)) {
102103
return;
103104
}
104105
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
"babel-plugin-transform-glob-import": "^1.0.1",
141141
"babelify": "^10.0.0",
142142
"chalk": "^4.1.2",
143-
"chromatic": "^11.3.0",
143+
"chromatic": "^11.25.2",
144144
"clsx": "^2.0.0",
145145
"color-space": "^1.16.0",
146146
"concurrently": "^6.0.2",

packages/@react-aria/autocomplete/src/useAutocomplete.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ export function UNSTABLE_useAutocomplete(props: AriaAutocompleteOptions, state:
171171
break;
172172
case ' ':
173173
// Space shouldn't trigger onAction so early return.
174-
174+
return;
175+
case 'Tab':
176+
// Don't propogate Tab down to the collection, otherwise we will try to focus the collection via useSelectableCollection's Tab handler (aka shift tab logic)
177+
// We want FocusScope to handle Tab if one exists (aka sub dialog), so special casepropogate
178+
if ('continuePropagation' in e) {
179+
e.continuePropagation();
180+
}
175181
return;
176182
case 'Home':
177183
case 'End':

packages/@react-aria/button/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"url": "https://github.com/adobe/react-spectrum"
2323
},
2424
"dependencies": {
25-
"@react-aria/focus": "^3.19.1",
2625
"@react-aria/interactions": "^3.23.0",
2726
"@react-aria/toolbar": "3.0.0-beta.12",
2827
"@react-aria/utils": "^3.27.0",

packages/@react-aria/button/src/useButton.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
import {AriaButtonProps} from '@react-types/button';
2222
import {DOMAttributes} from '@react-types/shared';
2323
import {filterDOMProps, mergeProps} from '@react-aria/utils';
24-
import {useFocusable} from '@react-aria/focus';
25-
import {usePress} from '@react-aria/interactions';
24+
import {useFocusable, usePress} from '@react-aria/interactions';
2625

2726
export interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {}
2827

packages/@react-aria/collections/src/useCachedChildren.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface CachedChildrenOptions<T> {
1919
/** The contents of the collection. */
2020
children?: ReactNode | ((item: T) => ReactNode),
2121
/** Values that should invalidate the item cache when using dynamic collections. */
22-
dependencies?: any[],
22+
dependencies?: ReadonlyArray<any>,
2323
/** A scope to prepend to all child item ids to ensure they are unique. */
2424
idScope?: Key,
2525
/** Whether to add `id` and `value` props to all child items. */

packages/@react-aria/datepicker/src/useDateSegment.ts

+5
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,14 @@ export function useDateSegment(segment: DateSegment, state: DateFieldState, ref:
388388
let dateSegments = ['day', 'month', 'year'];
389389
let segmentStyle : CSSProperties = {caretColor: 'transparent'};
390390
if (direction === 'rtl') {
391+
// While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
392+
// To ensure placeholder render in correct format, we apply the CSS equivalent of LRE (left-to-right embedding). See https://www.unicode.org/reports/tr9/#Explicit_Directional_Embeddings.
393+
// However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
391394
if (dateSegments.includes(segment.type)) {
392395
segmentStyle = {caretColor: 'transparent', direction: 'ltr', unicodeBidi: 'embed'};
393396
} else if (segment.type === 'timeZoneName') {
397+
// This is needed so that the time zone renders on the left side of the time segments (hour:minute).
398+
// Otherwise, it will render on the right side which is incorrect.
394399
segmentStyle = {caretColor: 'transparent', unicodeBidi: 'embed'};
395400
}
396401
}

packages/@react-aria/dialog/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
2727
},
2828
"dependencies": {
29-
"@react-aria/focus": "^3.19.1",
29+
"@react-aria/interactions": "^3.23.0",
3030
"@react-aria/overlays": "^3.25.0",
3131
"@react-aria/utils": "^3.27.0",
3232
"@react-types/dialog": "^3.5.15",

packages/@react-aria/dialog/src/useDialog.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import {AriaDialogProps} from '@react-types/dialog';
1414
import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
1515
import {filterDOMProps, useSlotId} from '@react-aria/utils';
16-
import {focusSafely} from '@react-aria/focus';
16+
import {focusSafely} from '@react-aria/interactions';
1717
import {useEffect, useRef} from 'react';
1818
import {useOverlayFocusContain} from '@react-aria/overlays';
1919

packages/@react-aria/dnd/src/useClipboard.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {useFocus} from '@react-aria/interactions';
1818

1919
export interface ClipboardProps {
2020
/** A function that returns the items to copy. */
21-
getItems?: () => DragItem[],
21+
getItems?: (details: {type: 'cut' | 'copy'}) => DragItem[],
2222
/** Handler that is called when the user triggers a copy interaction. */
2323
onCopy?: () => void,
2424
/** Handler that is called when the user triggers a cut interaction. */
@@ -88,7 +88,7 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
8888

8989
e.preventDefault();
9090
if (e.clipboardData) {
91-
writeToDataTransfer(e.clipboardData, options.getItems());
91+
writeToDataTransfer(e.clipboardData, options.getItems({type: 'copy'}));
9292
options.onCopy?.();
9393
}
9494
});
@@ -106,7 +106,7 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
106106

107107
e.preventDefault();
108108
if (e.clipboardData) {
109-
writeToDataTransfer(e.clipboardData, options.getItems());
109+
writeToDataTransfer(e.clipboardData, options.getItems({type: 'cut'}));
110110
options.onCut();
111111
}
112112
});

packages/@react-aria/dnd/test/useClipboard.test.js

+37
Original file line numberDiff line numberDiff line change
@@ -363,5 +363,42 @@ describe('useClipboard', () => {
363363
expect(await onPaste.mock.calls[0][0][1].getText('test')).toBe('item 2');
364364
expect(await onPaste.mock.calls[0][0][1].getText('text/plain')).toBe('item 2');
365365
});
366+
367+
it('should show the type of the clipboard event if cutting', async () => {
368+
let getItems = (details) => [{
369+
[details.type]: 'test data'
370+
}];
371+
372+
let onCut = jest.fn();
373+
let tree = render(<Copyable getItems={getItems} onCut={onCut} />);
374+
let button = tree.getByRole('button');
375+
376+
await user.tab();
377+
expect(document.activeElement).toBe(button);
378+
379+
let clipboardData = new DataTransfer();
380+
fireEvent(button, new ClipboardEvent('cut', {clipboardData}));
381+
expect([...clipboardData.items]).toEqual([new DataTransferItem('cut', 'test data')]);
382+
expect(onCut).toHaveBeenCalledTimes(1);
383+
});
384+
385+
it('should show the type of the clipboard event if copying', async () => {
386+
let getItems = (details) => [{
387+
[details.type]: 'test data'
388+
}];
389+
390+
let onCopy = jest.fn();
391+
let tree = render(<Copyable getItems={getItems} onCopy={onCopy} />);
392+
let button = tree.getByRole('button');
393+
394+
await user.tab();
395+
expect(document.activeElement).toBe(button);
396+
397+
let clipboardData = new DataTransfer();
398+
fireEvent(button, new ClipboardEvent('copy', {clipboardData}));
399+
expect([...clipboardData.items]).toEqual([new DataTransferItem('copy', 'test data')]);
400+
expect(onCopy).toHaveBeenCalledTimes(1);
401+
});
366402
});
367403
});
404+

0 commit comments

Comments
 (0)