@khanacademy/wonder-blocks-core 4.9.1 → 5.0.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @khanacademy/wonder-blocks-core
2
2
 
3
+ ## 5.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ccb6fe00: Miscellaneous TS type fixes
8
+ - d4c2b18c: Fix a variety of issues with Flow types generated by flowgen
9
+
10
+ ## 5.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - 1ca4d7e3: Fix minor issue with generate Flow types (this is a major bump b/c I forgot to do one after doing the TS conversion)
15
+
3
16
  ## 4.9.1
4
17
 
5
18
  ### Patch Changes
@@ -6,7 +6,7 @@ type Props = {
6
6
  * use anywhere within children. This provides a way of adding a unique identifier
7
7
  * to a given component for a11y purposes.
8
8
  */
9
- children: (uniqueId: string) => React.ReactElement;
9
+ children: (uniqueId: string) => React.ReactNode;
10
10
  /**
11
11
  * Scope for the unique identifier
12
12
  */
@@ -53,6 +53,6 @@ type Props = {
53
53
  export default class IDProvider extends React.Component<Props> {
54
54
  static defaultId: string;
55
55
  renderChildren(ids?: IIdentifierFactory): React.ReactNode;
56
- render(): React.ReactElement;
56
+ render(): React.ReactNode;
57
57
  }
58
58
  export {};
@@ -7,13 +7,13 @@
7
7
 
8
8
  import * as React from "react";
9
9
  import type { IIdentifierFactory } from "../util/types";
10
- declare type Props = {
10
+ declare type Props = {|
11
11
  /**
12
12
  * Use the children-as-function pattern to pass a uniqueId string for
13
13
  * use anywhere within children. This provides a way of adding a unique identifier
14
14
  * to a given component for a11y purposes.
15
15
  */
16
- children: (uniqueId: string) => React.Element<>,
16
+ children: (uniqueId: string) => React.Node,
17
17
 
18
18
  /**
19
19
  * Scope for the unique identifier
@@ -30,8 +30,7 @@ declare type Props = {
30
30
  * Test ID used for e2e testing.
31
31
  */
32
32
  testId?: string,
33
- ...
34
- };
33
+ |};
35
34
  /**
36
35
  * This is a wrapper that returns an identifier. If the `id` prop is set, the
37
36
  * component will return the same id to be consumed by its children. Otherwise,
@@ -63,5 +62,5 @@ declare type Props = {
63
62
  declare export default class IDProvider extends React.Component<Props> {
64
63
  static defaultId: string;
65
64
  renderChildren(ids?: IIdentifierFactory): React.Node;
66
- render(): React.Element<>;
65
+ render(): React.Node;
67
66
  }
@@ -6,12 +6,11 @@
6
6
  */
7
7
 
8
8
  import * as React from "react";
9
- declare export var RenderState: {
9
+ declare export var RenderState: {|
10
10
  +Root: "root",
11
11
  +Initial: "initial",
12
12
  +Standard: "standard",
13
- ...
14
- };
13
+ |};
15
14
  /**
16
15
  * This is the context that tracks who is doing what in our SSR component tree.
17
16
  *
@@ -6,14 +6,13 @@
6
6
  */
7
7
 
8
8
  import * as React from "react";
9
- declare type Props = {
9
+ declare type Props = {|
10
10
  children: React.Node,
11
11
 
12
12
  /**
13
13
  * Whether the component should throw when nested. Defaults to `true`.
14
14
  */
15
15
  throwIfNested?: boolean,
16
- ...
17
- };
18
- declare var RenderStateRoot: React.FC<Props>;
16
+ |};
17
+ declare var RenderStateRoot: React.StatelessFunctionalComponent<Props>;
19
18
  declare export { RenderStateRoot };
@@ -20,6 +20,6 @@ type DefaultProps = {
20
20
  */
21
21
  export default class Text extends React.Component<Props> {
22
22
  static defaultProps: DefaultProps;
23
- render(): React.ReactElement;
23
+ render(): React.ReactNode;
24
24
  }
25
25
  export {};
@@ -7,17 +7,15 @@
7
7
 
8
8
  import * as React from "react";
9
9
  import type { TextViewSharedProps } from "../util/types";
10
- declare type Props = {
10
+ declare type Props = {|
11
11
  ...TextViewSharedProps,
12
- ...{
12
+ ...{|
13
13
  tag: string,
14
- ...
15
- },
16
- };
17
- declare type DefaultProps = {
14
+ |},
15
+ |};
16
+ declare type DefaultProps = {|
18
17
  tag: $PropertyType<Props, "tag">,
19
- ...
20
- };
18
+ |};
21
19
  /**
22
20
  * Text is a building block for constructing other components. `Text` roughly
23
21
  * maps to `span`. You can override which tag is used to render the component
@@ -32,5 +30,5 @@ declare type DefaultProps = {
32
30
  */
33
31
  declare export default class Text extends React.Component<Props> {
34
32
  static defaultProps: DefaultProps;
35
- render(): React.Element<>;
33
+ render(): React.Node;
36
34
  }
@@ -18,7 +18,7 @@ type Props = {
18
18
  *
19
19
  * `{get(id: string): string} => React.Node`
20
20
  */
21
- children: (arg1: IIdentifierFactory) => React.ReactElement;
21
+ children: (arg1: IIdentifierFactory) => React.ReactNode;
22
22
  /**
23
23
  * If mockOnFirstRender is false, children is only called
24
24
  * after the initial render has occurred.
@@ -64,6 +64,6 @@ type Props = {
64
64
  export default class UniqueIDProvider extends React.Component<Props> {
65
65
  _idFactory: IIdentifierFactory;
66
66
  _performRender(firstRender: boolean): React.ReactNode;
67
- render(): React.ReactElement;
67
+ render(): React.ReactNode;
68
68
  }
69
69
  export {};
@@ -7,7 +7,7 @@
7
7
 
8
8
  import * as React from "react";
9
9
  import type { IIdentifierFactory } from "../util/types";
10
- declare type Props = {
10
+ declare type Props = {|
11
11
  /**
12
12
  * A render prop that takes an instance of IIdentifierFactory and returns
13
13
  * the content to be rendered.
@@ -25,7 +25,7 @@ declare type Props = {
25
25
  *
26
26
  * `{get(id: string): string} => React.Node`
27
27
  */
28
- children: (arg1: IIdentifierFactory) => React.Element<>,
28
+ children: (arg1: IIdentifierFactory) => React.Node,
29
29
 
30
30
  /**
31
31
  * If mockOnFirstRender is false, children is only called
@@ -41,8 +41,7 @@ declare type Props = {
41
41
  * given scope. This can be useful for making easily readable identifiers.
42
42
  */
43
43
  +scope?: string,
44
- ...
45
- };
44
+ |};
46
45
  /**
47
46
  * The `UniqueIDProvider` component is how Wonder Blocks components obtain
48
47
  * unique identifiers. This component ensures that server-side rendering and
@@ -74,5 +73,5 @@ declare type Props = {
74
73
  declare export default class UniqueIDProvider extends React.Component<Props> {
75
74
  _idFactory: IIdentifierFactory;
76
75
  _performRender(firstRender: boolean): React.Node;
77
- render(): React.Element<>;
76
+ render(): React.Node;
78
77
  }
@@ -38,6 +38,6 @@ type DefaultProps = {
38
38
  */
39
39
  export default class View extends React.Component<Props> {
40
40
  static defaultProps: DefaultProps;
41
- render(): React.ReactElement;
41
+ render(): React.ReactNode;
42
42
  }
43
43
  export {};
@@ -8,20 +8,18 @@
8
8
  import * as React from "react";
9
9
  import type { TextViewSharedProps } from "../util/types";
10
10
  declare type ValidViewTags = "div" | "article" | "aside" | "nav" | "section";
11
- declare type Props = {
11
+ declare type Props = {|
12
12
  ...TextViewSharedProps,
13
- ...{
13
+ ...{|
14
14
  /**
15
15
  * The HTML tag to render.
16
16
  */
17
17
  tag: ValidViewTags,
18
- ...
19
- },
20
- };
21
- declare type DefaultProps = {
18
+ |},
19
+ |};
20
+ declare type DefaultProps = {|
22
21
  tag: $PropertyType<Props, "tag">,
23
- ...
24
- };
22
+ |};
25
23
  /**
26
24
  * View is a building block for constructing other components. `View` roughly
27
25
  * maps to `div`. You can override which tag is used to render the component
@@ -50,5 +48,5 @@ declare type DefaultProps = {
50
48
  */
51
49
  declare export default class View extends React.Component<Props> {
52
50
  static defaultProps: DefaultProps;
53
- render(): React.Element<>;
51
+ render(): React.Node;
54
52
  }
@@ -10,7 +10,7 @@ type Props = {
10
10
  * not server-side rendering, or (when server-side rendering) after
11
11
  * the initial rehydration has finished.
12
12
  */
13
- children: () => React.ReactElement;
13
+ children: () => React.ReactNode;
14
14
  /**
15
15
  * What to render during server-side rendering, or null not to
16
16
  * render anything.
@@ -58,6 +58,6 @@ export default class WithSSRPlaceholder extends React.Component<Props, State> {
58
58
  _isTheRootComponent: boolean;
59
59
  _renderAsRootComponent(): React.ReactNode;
60
60
  _maybeRender(renderState: typeof RenderState[keyof typeof RenderState]): React.ReactNode;
61
- render(): React.ReactElement;
61
+ render(): React.ReactNode;
62
62
  }
63
63
  export {};
@@ -12,13 +12,13 @@ import { RenderState } from "./render-state-context";
12
12
  * We use render functions so that we don't do any work unless we need to.
13
13
  * This avoids rendering but not mounting potentially complex component trees.
14
14
  */
15
- declare type Props = {
15
+ declare type Props = {|
16
16
  /**
17
17
  * The content that is client-only. This is what is rendered when
18
18
  * not server-side rendering, or (when server-side rendering) after
19
19
  * the initial rehydration has finished.
20
20
  */
21
- children: () => React.Element<>,
21
+ children: () => React.Node,
22
22
 
23
23
  /**
24
24
  * What to render during server-side rendering, or null not to
@@ -29,13 +29,11 @@ declare type Props = {
29
29
  * the server-side renderer and the rehydration -- or it defeats
30
30
  * the purpose of using the WithSSRPlaceholder component.
31
31
  */
32
- placeholder: () => React.Element<> | null | void,
33
- ...
34
- };
35
- declare type State = {
32
+ placeholder: () => React.Element<any> | null | void,
33
+ |};
34
+ declare type State = {|
36
35
  mounted: boolean,
37
- ...
38
- };
36
+ |};
39
37
  /**
40
38
  * Defer or change rendering until the component did mount.
41
39
  *
@@ -73,5 +71,5 @@ declare export default class WithSSRPlaceholder
73
71
  _maybeRender(
74
72
  renderState: $ElementType<typeof RenderState, $Keys<typeof RenderState>>
75
73
  ): React.Node;
76
- render(): React.Element<>;
74
+ render(): React.Node;
77
75
  }
@@ -8,16 +8,15 @@
8
8
  import * as React from "react";
9
9
  import type { StyleType } from "./types";
10
10
  declare export default function addStyle<
11
- T: React.ComponentType<any> | $Keys<JSX.IntrinsicElements>
11
+ T: React.FragmentType<any> | $Keys<JSX.IntrinsicElements>
12
12
  >(
13
13
  Component: T,
14
14
  defaultStyle?: StyleType
15
- ): React.FC<
15
+ ): React.StatelessFunctionalComponent<
16
16
  SpreadType<
17
- JSX.LibraryManagedAttributes<T, React.ComponentProps<T>>,
18
- {
17
+ JSX.LibraryManagedAttributes<T, React.ElementProps<T>>,
18
+ {|
19
19
  style?: StyleType,
20
- ...
21
- }
20
+ |}
22
21
  >
23
22
  >;
@@ -0,0 +1,187 @@
1
+ export interface AriaAttributes {
2
+ /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
3
+ "aria-activedescendant"?: string | undefined;
4
+ /** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */
5
+ "aria-atomic"?: boolean | "false" | "true" | undefined;
6
+ /**
7
+ * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
8
+ * presented if they are made.
9
+ */
10
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
11
+ /** Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. */
12
+ "aria-busy"?: boolean | "false" | "true" | undefined;
13
+ /**
14
+ * Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
15
+ * @see aria-pressed @see aria-selected.
16
+ */
17
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
18
+ /**
19
+ * Defines the total number of columns in a table, grid, or treegrid.
20
+ * @see aria-colindex.
21
+ */
22
+ "aria-colcount"?: number | undefined;
23
+ /**
24
+ * Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
25
+ * @see aria-colcount @see aria-colspan.
26
+ */
27
+ "aria-colindex"?: number | undefined;
28
+ /**
29
+ * Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
30
+ * @see aria-colindex @see aria-rowspan.
31
+ */
32
+ "aria-colspan"?: number | undefined;
33
+ /**
34
+ * Identifies the element (or elements) whose contents or presence are controlled by the current element.
35
+ * @see aria-owns.
36
+ */
37
+ "aria-controls"?: string | undefined;
38
+ /** Indicates the element that represents the current item within a container or set of related elements. */
39
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
40
+ /**
41
+ * Identifies the element (or elements) that describes the object.
42
+ * @see aria-labelledby
43
+ */
44
+ "aria-describedby"?: string | undefined;
45
+ /**
46
+ * Identifies the element that provides a detailed, extended description for the object.
47
+ * @see aria-describedby.
48
+ */
49
+ "aria-details"?: string | undefined;
50
+ /**
51
+ * Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
52
+ * @see aria-hidden @see aria-readonly.
53
+ */
54
+ "aria-disabled"?: boolean | "false" | "true" | undefined;
55
+ /**
56
+ * Indicates what functions can be performed when a dragged object is released on the drop target.
57
+ * @deprecated in ARIA 1.1
58
+ */
59
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
60
+ /**
61
+ * Identifies the element that provides an error message for the object.
62
+ * @see aria-invalid @see aria-describedby.
63
+ */
64
+ "aria-errormessage"?: string | undefined;
65
+ /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
66
+ "aria-expanded"?: boolean | "false" | "true" | undefined;
67
+ /**
68
+ * Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
69
+ * allows assistive technology to override the general default of reading in document source order.
70
+ */
71
+ "aria-flowto"?: string | undefined;
72
+ /**
73
+ * Indicates an element's "grabbed" state in a drag-and-drop operation.
74
+ * @deprecated in ARIA 1.1
75
+ */
76
+ "aria-grabbed"?: boolean | "false" | "true" | undefined;
77
+ /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
78
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
79
+ /**
80
+ * Indicates whether the element is exposed to an accessibility API.
81
+ * @see aria-disabled.
82
+ */
83
+ "aria-hidden"?: boolean | "false" | "true" | undefined;
84
+ /**
85
+ * Indicates the entered value does not conform to the format expected by the application.
86
+ * @see aria-errormessage.
87
+ */
88
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
89
+ /** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */
90
+ "aria-keyshortcuts"?: string | undefined;
91
+ /**
92
+ * Defines a string value that labels the current element.
93
+ * @see aria-labelledby.
94
+ */
95
+ "aria-label"?: string | undefined;
96
+ /**
97
+ * Identifies the element (or elements) that labels the current element.
98
+ * @see aria-describedby.
99
+ */
100
+ "aria-labelledby"?: string | undefined;
101
+ /** Defines the hierarchical level of an element within a structure. */
102
+ "aria-level"?: number | undefined;
103
+ /** Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */
104
+ "aria-live"?: "off" | "assertive" | "polite" | undefined;
105
+ /** Indicates whether an element is modal when displayed. */
106
+ "aria-modal"?: boolean | "false" | "true" | undefined;
107
+ /** Indicates whether a text box accepts multiple lines of input or only a single line. */
108
+ "aria-multiline"?: boolean | "false" | "true" | undefined;
109
+ /** Indicates that the user may select more than one item from the current selectable descendants. */
110
+ "aria-multiselectable"?: boolean | "false" | "true" | undefined;
111
+ /** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
112
+ "aria-orientation"?: "horizontal" | "vertical" | undefined;
113
+ /**
114
+ * Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
115
+ * between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
116
+ * @see aria-controls.
117
+ */
118
+ "aria-owns"?: string | undefined;
119
+ /**
120
+ * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
121
+ * A hint could be a sample value or a brief description of the expected format.
122
+ */
123
+ "aria-placeholder"?: string | undefined;
124
+ /**
125
+ * Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
126
+ * @see aria-setsize.
127
+ */
128
+ "aria-posinset"?: number | undefined;
129
+ /**
130
+ * Indicates the current "pressed" state of toggle buttons.
131
+ * @see aria-checked @see aria-selected.
132
+ */
133
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
134
+ /**
135
+ * Indicates that the element is not editable, but is otherwise operable.
136
+ * @see aria-disabled.
137
+ */
138
+ "aria-readonly"?: boolean | "false" | "true" | undefined;
139
+ /**
140
+ * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
141
+ * @see aria-atomic.
142
+ */
143
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
144
+ /** Indicates that user input is required on the element before a form may be submitted. */
145
+ "aria-required"?: boolean | "false" | "true" | undefined;
146
+ /** Defines a human-readable, author-localized description for the role of an element. */
147
+ "aria-roledescription"?: string | undefined;
148
+ /**
149
+ * Defines the total number of rows in a table, grid, or treegrid.
150
+ * @see aria-rowindex.
151
+ */
152
+ "aria-rowcount"?: number | undefined;
153
+ /**
154
+ * Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
155
+ * @see aria-rowcount @see aria-rowspan.
156
+ */
157
+ "aria-rowindex"?: number | undefined;
158
+ /**
159
+ * Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
160
+ * @see aria-rowindex @see aria-colspan.
161
+ */
162
+ "aria-rowspan"?: number | undefined;
163
+ /**
164
+ * Indicates the current "selected" state of various widgets.
165
+ * @see aria-checked @see aria-pressed.
166
+ */
167
+ "aria-selected"?: boolean | "false" | "true" | undefined;
168
+ /**
169
+ * Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
170
+ * @see aria-posinset.
171
+ */
172
+ "aria-setsize"?: number | undefined;
173
+ /** Indicates if items in a table or grid are sorted in ascending or descending order. */
174
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
175
+ /** Defines the maximum allowed value for a range widget. */
176
+ "aria-valuemax"?: number | undefined;
177
+ /** Defines the minimum allowed value for a range widget. */
178
+ "aria-valuemin"?: number | undefined;
179
+ /**
180
+ * Defines the current value for a range widget.
181
+ * @see aria-valuetext.
182
+ */
183
+ "aria-valuenow"?: number | undefined;
184
+ /** Defines the human readable text alternative of aria-valuenow for a range widget. */
185
+ "aria-valuetext"?: string | undefined;
186
+ }
187
+ export type AriaRole = "alert" | "alertdialog" | "application" | "article" | "banner" | "button" | "cell" | "checkbox" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "dialog" | "directory" | "document" | "feed" | "figure" | "form" | "grid" | "gridcell" | "group" | "heading" | "img" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem";