@khanacademy/wonder-blocks-modal 2.1.42 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,7 @@ const customViewports = {
38
38
  };
39
39
 
40
40
  export default {
41
- title: "OnePaneDialog",
41
+ title: "Floating/Modal/OnePaneDialog",
42
42
  parameters: {
43
43
  viewport: {
44
44
  viewports: customViewports,
@@ -50,7 +50,7 @@ export default {
50
50
  },
51
51
  };
52
52
 
53
- export const simple: StoryComponentType = () => {
53
+ export const Simple: StoryComponentType = () => {
54
54
  const modal = (
55
55
  <OnePaneDialog
56
56
  testId="one-pane-dialog-above"
@@ -98,7 +98,7 @@ const styles = StyleSheet.create({
98
98
  },
99
99
  });
100
100
 
101
- export const kitchenSink: StoryComponentType = () => {
101
+ export const KitchenSink: StoryComponentType = () => {
102
102
  const modal = (
103
103
  <OnePaneDialog
104
104
  title="Single-line title"
@@ -142,7 +142,7 @@ export const kitchenSink: StoryComponentType = () => {
142
142
  );
143
143
  };
144
144
 
145
- export const withOpener: StoryComponentType = () => {
145
+ export const WithOpener: StoryComponentType = () => {
146
146
  type MyModalProps = {|
147
147
  closeModal: () => void,
148
148
  |};
@@ -191,14 +191,12 @@ export const withOpener: StoryComponentType = () => {
191
191
  );
192
192
  };
193
193
 
194
- withOpener.story = {
195
- parameters: {
196
- viewport: {
197
- defaultViewport: null,
198
- },
199
- chromatic: {
200
- // Don't take screenshots of this story since it would only show a button.
201
- disable: true,
202
- },
194
+ WithOpener.parameters = {
195
+ viewport: {
196
+ defaultViewport: null,
197
+ },
198
+ chromatic: {
199
+ // Don't take screenshots of this story since it would only show a button.
200
+ disableSnapshot: true,
203
201
  },
204
202
  };
@@ -0,0 +1,14 @@
1
+ // @flow
2
+
3
+ /**
4
+ * List of elements that can be focused
5
+ * @see https://www.w3.org/TR/html5/editing.html#can-be-focused
6
+ */
7
+ const FOCUSABLE_ELEMENTS =
8
+ 'a[href], details, input, textarea, select, button:not([aria-label^="Close"])';
9
+
10
+ export function findFocusableNodes(
11
+ root: HTMLElement | Document,
12
+ ): Array<HTMLElement> {
13
+ return Array.from(root.querySelectorAll(FOCUSABLE_ELEMENTS));
14
+ }
@@ -2,6 +2,7 @@
2
2
  import * as React from "react";
3
3
  import * as ReactDOM from "react-dom";
4
4
  import {mount} from "enzyme";
5
+ import "jest-enzyme";
5
6
 
6
7
  import {ModalLauncherPortalAttributeName} from "./constants.js";
7
8
  import maybeGetPortalMountedModalHostElement from "./maybe-get-portal-mounted-modal-host-element.js";
@@ -108,9 +109,8 @@ describe("maybeGetPortalMountedModalHostElement", () => {
108
109
  if (node) {
109
110
  // Act
110
111
  const candidateElement = ReactDOM.findDOMNode(node);
111
- const result = maybeGetPortalMountedModalHostElement(
112
- candidateElement,
113
- );
112
+ const result =
113
+ maybeGetPortalMountedModalHostElement(candidateElement);
114
114
 
115
115
  // Assert
116
116
  expect(result).toBeTruthy();
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Khan Academy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.