@khanacademy/wonder-blocks-layout 1.4.16 → 1.4.18

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/media-layout-context.d.ts +45 -0
  3. package/dist/components/media-layout-context.js.flow +55 -0
  4. package/dist/components/media-layout.d.ts +65 -0
  5. package/dist/components/media-layout.js.flow +75 -0
  6. package/dist/components/spring.d.ts +14 -0
  7. package/dist/components/spring.js.flow +21 -0
  8. package/dist/components/strut.d.ts +15 -0
  9. package/dist/components/strut.js.flow +22 -0
  10. package/dist/es/index.js +82 -64
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.js +97 -80
  13. package/dist/index.js.flow +23 -2
  14. package/dist/util/specs.d.ts +5 -0
  15. package/dist/util/specs.js.flow +12 -0
  16. package/dist/util/test-util.d.ts +26 -0
  17. package/dist/util/test-util.js.flow +40 -0
  18. package/dist/util/types.d.ts +20 -0
  19. package/dist/util/types.js.flow +42 -0
  20. package/dist/util/util.d.ts +12 -0
  21. package/dist/util/util.js.flow +22 -0
  22. package/package.json +5 -5
  23. package/src/components/__tests__/{media-layout-context.test.js → media-layout-context.test.tsx} +18 -11
  24. package/src/components/__tests__/{media-layout.test.js → media-layout.test.tsx} +33 -24
  25. package/src/components/{media-layout-context.js → media-layout-context.ts} +7 -10
  26. package/src/components/{media-layout.js → media-layout.tsx} +42 -34
  27. package/src/components/{spring.js → spring.tsx} +4 -5
  28. package/src/components/{strut.js → strut.tsx} +6 -7
  29. package/src/{index.js → index.ts} +0 -1
  30. package/src/util/{specs.js → specs.ts} +0 -2
  31. package/src/util/{test-util.test.js → test-util.test.ts} +2 -3
  32. package/src/util/{test-util.js → test-util.ts} +11 -10
  33. package/src/util/{types.js → types.ts} +12 -14
  34. package/src/util/{util.test.js → util.test.ts} +0 -4
  35. package/src/util/{util.js → util.ts} +0 -1
  36. package/tsconfig.json +12 -0
  37. package/tsconfig.tsbuildinfo +1 -0
  38. package/src/components/__docs__/media-layout.stories.js +0 -257
  39. package/src/components/__docs__/spring.stories.js +0 -101
  40. package/src/components/__docs__/strut.stories.js +0 -124
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @khanacademy/wonder-blocks-layout
2
2
 
3
+ ## 1.4.18
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [779b031d]
8
+ - @khanacademy/wonder-blocks-core@4.9.0
9
+
10
+ ## 1.4.17
11
+
12
+ ### Patch Changes
13
+
14
+ - d816af08: Update build and test configs use TypeScript
15
+ - 3891f544: Update babel config to include plugins that Storybook needed
16
+ - 0d28bb1c: Configured TypeScript
17
+ - 3d05f764: Fix HOCs and other type errors
18
+ - c2ec4902: Update eslint configuration, fix lint
19
+ - 2983c05b: Include 'types' field in package.json
20
+ - 77ff6a66: Generate Flow types from TypeScript types
21
+ - ec8d4b7f: Fix miscellaneous TypeScript errors
22
+ - Updated dependencies [d816af08]
23
+ - Updated dependencies [3891f544]
24
+ - Updated dependencies [0d28bb1c]
25
+ - Updated dependencies [873f4a14]
26
+ - Updated dependencies [3d05f764]
27
+ - Updated dependencies [c2ec4902]
28
+ - Updated dependencies [2983c05b]
29
+ - Updated dependencies [77ff6a66]
30
+ - Updated dependencies [ec8d4b7f]
31
+ - @khanacademy/wonder-blocks-core@4.8.0
32
+ - @khanacademy/wonder-blocks-spacing@3.0.6
33
+
3
34
  ## 1.4.16
4
35
 
5
36
  ### Patch Changes
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+ import type { MediaSize, MediaSpec } from "../util/types";
3
+ export type Context = {
4
+ /**
5
+ * Force the MediaLayout to be a particular size (ignoring the actual
6
+ * dimensions of the viewport).
7
+ */
8
+ overrideSize?: MediaSize;
9
+ /**
10
+ * Set the size of the MediaLayout to be rendered when doing SSR
11
+ * (Server-Side Rendering) of the component. Defaults to "large".
12
+ */
13
+ ssrSize: MediaSize;
14
+ /**
15
+ * If you wish to use a different set of layout sizes you can specify them as
16
+ * part of the `mediaSpec` property. The Core package exports a couple of the
17
+ * most commonly used ones:
18
+ *
19
+ * **Default Layout Spec (`MEDIA_DEFAULT_SPEC`)**
20
+ *
21
+ * | Size | Columns | Gutter | Margin | Breakpoint |
22
+ * | ------ | ------- | ------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------- |
23
+ * | small | 4 | 16px | 16px | `max-width: 767px` |
24
+ * | medium | 8 | 32px | 24px | `min-width: 768px and max-width: 1023px` |
25
+ * | large | 12 | 32px | 24px | `min-width: 1024px` (maximum content width: `1120px`, after which the margins will continue to expand and content remain centered) |
26
+ *
27
+ * Additionally, the following layout size specs are also available:
28
+ *
29
+ * **Internal Tools (`MEDIA_INTERNAL_SPEC`)**
30
+ *
31
+ * | Size | Columns | Gutter | Margin | Breakpoint |
32
+ * | ----- | ------- | ------ | ------ | -------------------------------------------- |
33
+ * | large | 12 | 32px | 16px | `min-width: 1px` (No maximum content width.) |
34
+ *
35
+ * **12-Column Modal (`MEDIA_MODAL_SPEC`)**
36
+ *
37
+ * | Size | Columns | Gutter | Margin | Breakpoint |
38
+ * | ----- | ------- | ------ | ------ | ---------------------------------------------- |
39
+ * | small | 4 | 16px | 16px | `max-width: 767px` |
40
+ * | large | 12 | 32px | 64px | `min-width: 768px` (No maximum content width.) |
41
+ */
42
+ mediaSpec: MediaSpec;
43
+ };
44
+ declare const _default: React.Context<Context>;
45
+ export default _default;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Flowtype definitions for media-layout-context
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import * as React from "react";
9
+ import type { MediaSize, MediaSpec } from "../util/types";
10
+ export type Context = {
11
+ /**
12
+ * Force the MediaLayout to be a particular size (ignoring the actual
13
+ * dimensions of the viewport).
14
+ */
15
+ overrideSize?: MediaSize,
16
+
17
+ /**
18
+ * Set the size of the MediaLayout to be rendered when doing SSR
19
+ * (Server-Side Rendering) of the component. Defaults to "large".
20
+ */
21
+ ssrSize: MediaSize,
22
+
23
+ /**
24
+ * If you wish to use a different set of layout sizes you can specify them as
25
+ * part of the `mediaSpec` property. The Core package exports a couple of the
26
+ * most commonly used ones:
27
+ *
28
+ * **Default Layout Spec (`MEDIA_DEFAULT_SPEC`)**
29
+ *
30
+ * | Size | Columns | Gutter | Margin | Breakpoint |
31
+ * | ------ | ------- | ------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------- |
32
+ * | small | 4 | 16px | 16px | `max-width: 767px` |
33
+ * | medium | 8 | 32px | 24px | `min-width: 768px and max-width: 1023px` |
34
+ * | large | 12 | 32px | 24px | `min-width: 1024px` (maximum content width: `1120px`, after which the margins will continue to expand and content remain centered) |
35
+ *
36
+ * Additionally, the following layout size specs are also available:
37
+ *
38
+ * **Internal Tools (`MEDIA_INTERNAL_SPEC`)**
39
+ *
40
+ * | Size | Columns | Gutter | Margin | Breakpoint |
41
+ * | ----- | ------- | ------ | ------ | -------------------------------------------- |
42
+ * | large | 12 | 32px | 16px | `min-width: 1px` (No maximum content width.) |
43
+ *
44
+ * **12-Column Modal (`MEDIA_MODAL_SPEC`)**
45
+ *
46
+ * | Size | Columns | Gutter | Margin | Breakpoint |
47
+ * | ----- | ------- | ------ | ------ | ---------------------------------------------- |
48
+ * | small | 4 | 16px | 16px | `max-width: 767px` |
49
+ * | large | 12 | 32px | 64px | `min-width: 768px` (No maximum content width.) |
50
+ */
51
+ mediaSpec: MediaSpec,
52
+ ...
53
+ };
54
+ declare var _default: React.Context<Context>;
55
+ declare export default typeof _default;
@@ -0,0 +1,65 @@
1
+ import * as React from "react";
2
+ import type { StyleDeclaration } from "aphrodite";
3
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
4
+ import type { MediaSize, MediaSpec } from "../util/types";
5
+ export type MockStyleSheet = Record<string, StyleType>;
6
+ type Props = {
7
+ /**
8
+ * The contents to display. Alternatively, a function can be specified
9
+ * that takes three arguments and should return some nodes to display.
10
+ *
11
+ * - mediaSize: The current size of the viewport (small/medium/large)
12
+ * - mediaSpec: The current spec being used to manage the selection of
13
+ * the mediaSize.
14
+ * - styles: An Aphrodite stylesheet representing the current
15
+ * stylesheet for this mediaSize (as specified in the
16
+ * styleSheets prop).
17
+ */
18
+ children: (arg1: {
19
+ mediaSize: MediaSize;
20
+ mediaSpec: MediaSpec;
21
+ styles: MockStyleSheet;
22
+ }) => React.ReactElement;
23
+ /**
24
+ * Aphrodite stylesheets to pass through to the styles prop. The
25
+ * stylesheets to render is based on the media size. "all" is always
26
+ * rendered.
27
+ */
28
+ styleSheets?: {
29
+ all?: StyleDeclaration;
30
+ mdOrLarger?: StyleDeclaration;
31
+ mdOrSmaller?: StyleDeclaration;
32
+ small?: StyleDeclaration;
33
+ medium?: StyleDeclaration;
34
+ large?: StyleDeclaration;
35
+ };
36
+ };
37
+ /**
38
+ * ***NOTE: The MediaLayout component is being deprecated. Do not use this!!***
39
+ *
40
+ * MediaLayout is a container component that accepts a `styleSheets` object,
41
+ * whose keys are media sizes. It listens for changes to the current media
42
+ * size and passes the current `mediaSize`, `mediaSpec`, and `styles` to
43
+ * `children`, which is a render function taking those three values as an
44
+ * object.
45
+ *
46
+ * Valid keys for the `styleSheets` object are (in order of precedence):
47
+ * - `small`, `medium`, `large`
48
+ * - `mdOrSmaller`, `mdOrLarger`
49
+ * - `all`
50
+ *
51
+ * `MediaLayout` will merge style rules from multiple styles that match the
52
+ * current media query, e.g. `"(min-width: 1024px)"`.
53
+ *
54
+ * The `mediaSpec` is an object with one or more of the following keys:
55
+ * `small`, `medium`, or `large`. Each value contains the following data:
56
+ * - `query: string` e.g. "(min-width: 1024px)"
57
+ * - `totalColumns: number`
58
+ * - `gutterWidth: number`
59
+ * - `marginWidth: number`
60
+ * - `maxWidth: number`
61
+ */
62
+ export default class MediaLayout extends React.Component<Props> {
63
+ render(): React.ReactElement;
64
+ }
65
+ export {};
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Flowtype definitions for media-layout
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import * as React from "react";
9
+ import type { StyleDeclaration } from "aphrodite";
10
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
11
+ import type { MediaSize, MediaSpec } from "../util/types";
12
+ export type MockStyleSheet = { [key: string]: StyleType, ... };
13
+ declare type Props = {
14
+ /**
15
+ * The contents to display. Alternatively, a function can be specified
16
+ * that takes three arguments and should return some nodes to display.
17
+ *
18
+ * - mediaSize: The current size of the viewport (small/medium/large)
19
+ * - mediaSpec: The current spec being used to manage the selection of
20
+ * the mediaSize.
21
+ * - styles: An Aphrodite stylesheet representing the current
22
+ * stylesheet for this mediaSize (as specified in the
23
+ * styleSheets prop).
24
+ */
25
+ children: (arg1: {
26
+ mediaSize: MediaSize,
27
+ mediaSpec: MediaSpec,
28
+ styles: MockStyleSheet,
29
+ ...
30
+ }) => React.Element<>,
31
+
32
+ /**
33
+ * Aphrodite stylesheets to pass through to the styles prop. The
34
+ * stylesheets to render is based on the media size. "all" is always
35
+ * rendered.
36
+ */
37
+ styleSheets?: {
38
+ all?: StyleDeclaration,
39
+ mdOrLarger?: StyleDeclaration,
40
+ mdOrSmaller?: StyleDeclaration,
41
+ small?: StyleDeclaration,
42
+ medium?: StyleDeclaration,
43
+ large?: StyleDeclaration,
44
+ ...
45
+ },
46
+ ...
47
+ };
48
+ /**
49
+ * ***NOTE: The MediaLayout component is being deprecated. Do not use this!!***
50
+ *
51
+ * MediaLayout is a container component that accepts a `styleSheets` object,
52
+ * whose keys are media sizes. It listens for changes to the current media
53
+ * size and passes the current `mediaSize`, `mediaSpec`, and `styles` to
54
+ * `children`, which is a render function taking those three values as an
55
+ * object.
56
+ *
57
+ * Valid keys for the `styleSheets` object are (in order of precedence):
58
+ * - `small`, `medium`, `large`
59
+ * - `mdOrSmaller`, `mdOrLarger`
60
+ * - `all`
61
+ *
62
+ * `MediaLayout` will merge style rules from multiple styles that match the
63
+ * current media query, e.g. `"(min-width: 1024px)"`.
64
+ *
65
+ * The `mediaSpec` is an object with one or more of the following keys:
66
+ * `small`, `medium`, or `large`. Each value contains the following data:
67
+ * - `query: string` e.g. "(min-width: 1024px)"
68
+ * - `totalColumns: number`
69
+ * - `gutterWidth: number`
70
+ * - `marginWidth: number`
71
+ * - `maxWidth: number`
72
+ */
73
+ declare export default class MediaLayout extends React.Component<Props> {
74
+ render(): React.Element<>;
75
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
3
+ type Props = {
4
+ style?: StyleType;
5
+ };
6
+ /**
7
+ * Expands to fill space between sibling components.
8
+ *
9
+ * Assumes parent is a View.
10
+ */
11
+ export default class Spring extends React.Component<Props> {
12
+ render(): React.ReactElement;
13
+ }
14
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Flowtype definitions for spring
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import * as React from "react";
9
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
10
+ declare type Props = {
11
+ style?: StyleType,
12
+ ...
13
+ };
14
+ /**
15
+ * Expands to fill space between sibling components.
16
+ *
17
+ * Assumes parent is a View.
18
+ */
19
+ declare export default class Spring extends React.Component<Props> {
20
+ render(): React.Element<>;
21
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
3
+ type Props = {
4
+ size: number;
5
+ style?: StyleType;
6
+ };
7
+ /**
8
+ * A component for inserting fixed space between components.
9
+ *
10
+ * Assumes parent is a View.
11
+ */
12
+ export default class Strut extends React.Component<Props> {
13
+ render(): React.ReactElement;
14
+ }
15
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Flowtype definitions for strut
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import * as React from "react";
9
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
10
+ declare type Props = {
11
+ size: number,
12
+ style?: StyleType,
13
+ ...
14
+ };
15
+ /**
16
+ * A component for inserting fixed space between components.
17
+ *
18
+ * Assumes parent is a View.
19
+ */
20
+ declare export default class Strut extends React.Component<Props> {
21
+ render(): React.Element<>;
22
+ }
package/dist/es/index.js CHANGED
@@ -1,9 +1,37 @@
1
- import _extends from '@babel/runtime/helpers/extends';
2
1
  import * as React from 'react';
3
2
  import Spacing from '@khanacademy/wonder-blocks-spacing';
4
3
  import { StyleSheet } from 'aphrodite';
5
4
  import { View } from '@khanacademy/wonder-blocks-core';
6
5
 
6
+ function _extends() {
7
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
8
+ for (var i = 1; i < arguments.length; i++) {
9
+ var source = arguments[i];
10
+ for (var key in source) {
11
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
12
+ target[key] = source[key];
13
+ }
14
+ }
15
+ }
16
+ return target;
17
+ };
18
+ return _extends.apply(this, arguments);
19
+ }
20
+
21
+ function _setPrototypeOf(o, p) {
22
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
23
+ o.__proto__ = p;
24
+ return o;
25
+ };
26
+ return _setPrototypeOf(o, p);
27
+ }
28
+
29
+ function _inheritsLoose(subClass, superClass) {
30
+ subClass.prototype = Object.create(superClass.prototype);
31
+ subClass.prototype.constructor = subClass;
32
+ _setPrototypeOf(subClass, superClass);
33
+ }
34
+
7
35
  const VALID_MEDIA_SIZES = ["small", "medium", "large"];
8
36
  const mediaDefaultSpecLargeMarginWidth = Spacing.large_24;
9
37
  const MEDIA_DEFAULT_SPEC = {
@@ -59,26 +87,26 @@ var MediaLayoutContext = React.createContext(defaultContext);
59
87
  const queries = [].concat(Object.values(MEDIA_DEFAULT_SPEC).map(spec => spec.query), Object.values(MEDIA_INTERNAL_SPEC).map(spec => spec.query), Object.values(MEDIA_MODAL_SPEC).map(spec => spec.query));
60
88
  const mediaQueryLists = {};
61
89
  const DEFAULT_SIZE = "large";
62
-
63
- class MediaLayoutInternal extends React.Component {
64
- constructor(props) {
65
- super(props);
66
- this.state = {
90
+ let MediaLayoutInternal = function (_React$Component) {
91
+ _inheritsLoose(MediaLayoutInternal, _React$Component);
92
+ function MediaLayoutInternal(props) {
93
+ var _this;
94
+ _this = _React$Component.call(this, props) || this;
95
+ _this.cleanupThunks = void 0;
96
+ _this.state = {
67
97
  size: undefined
68
98
  };
69
- this.cleanupThunks = [];
99
+ _this.cleanupThunks = [];
100
+ return _this;
70
101
  }
71
-
72
- componentDidMount() {
102
+ var _proto = MediaLayoutInternal.prototype;
103
+ _proto.componentDidMount = function componentDidMount() {
73
104
  const entries = Object.entries(this.props.mediaSpec);
74
-
75
105
  for (const [size, spec] of entries) {
76
106
  const mql = mediaQueryLists[spec.query];
77
-
78
107
  if (!mql) {
79
108
  continue;
80
109
  }
81
-
82
110
  const listener = e => {
83
111
  if (e.matches) {
84
112
  this.setState({
@@ -86,81 +114,64 @@ class MediaLayoutInternal extends React.Component {
86
114
  });
87
115
  }
88
116
  };
89
-
90
117
  mql.addListener(listener);
91
118
  this.cleanupThunks.push(() => mql.removeListener(listener));
92
119
  }
93
- }
94
-
95
- componentWillUnmount() {
120
+ };
121
+ _proto.componentWillUnmount = function componentWillUnmount() {
96
122
  this.cleanupThunks.forEach(cleaup => cleaup());
97
- }
98
-
99
- getCurrentSize(spec) {
123
+ };
124
+ _proto.getCurrentSize = function getCurrentSize(spec) {
100
125
  if (this.state.size) {
101
126
  return this.state.size;
102
127
  } else {
103
128
  const entries = Object.entries(this.props.mediaSpec);
104
-
105
129
  for (const [size, _spec] of entries) {
106
130
  const mql = mediaQueryLists[_spec.query];
107
-
108
131
  if (mql.matches) {
109
132
  return size;
110
133
  }
111
134
  }
112
135
  }
113
-
114
136
  return DEFAULT_SIZE;
115
- }
116
-
117
- isServerSide() {
137
+ };
138
+ _proto.isServerSide = function isServerSide() {
118
139
  return typeof window === "undefined" || !window.matchMedia;
119
- }
120
-
121
- getMockStyleSheet(mediaSize) {
140
+ };
141
+ _proto.getMockStyleSheet = function getMockStyleSheet(mediaSize) {
122
142
  const {
123
143
  styleSheets
124
144
  } = this.props;
125
145
  const mockStyleSheet = {};
126
-
127
146
  if (!styleSheets) {
128
147
  return mockStyleSheet;
129
148
  }
130
-
131
149
  for (const styleSize of Object.keys(styleSheets)) {
132
150
  const styleSheet = styleSheets[styleSize];
133
-
134
151
  if (!styleSheet) {
135
152
  continue;
136
153
  }
137
-
138
154
  for (const name of Object.keys(styleSheet)) {
139
155
  if (Object.prototype.hasOwnProperty.call(mockStyleSheet, name)) {
140
156
  continue;
141
157
  }
142
-
143
158
  mockStyleSheet[name] = [styleSheets.all && styleSheets.all[name], mediaSize === "small" && [styleSheets.mdOrSmaller && styleSheets.mdOrSmaller[name], styleSheets.small && styleSheets.small[name]], mediaSize === "medium" && [styleSheets.mdOrSmaller && styleSheets.mdOrSmaller[name], styleSheets.mdOrLarger && styleSheets.mdOrLarger[name], styleSheets.medium && styleSheets.medium[name]], mediaSize === "large" && [styleSheets.mdOrLarger && styleSheets.mdOrLarger[name], styleSheets.large && styleSheets.large[name]]];
144
159
  }
145
160
  }
146
-
147
161
  return mockStyleSheet;
148
- }
149
-
150
- render() {
162
+ };
163
+ _proto.render = function render() {
151
164
  const {
152
165
  children,
153
166
  mediaSpec,
154
167
  ssrSize,
155
168
  overrideSize
156
169
  } = this.props;
157
-
158
170
  if (!this.isServerSide()) {
159
171
  for (const query of queries.filter(query => !mediaQueryLists[query])) {
160
172
  mediaQueryLists[query] = window.matchMedia(query);
161
173
  }
162
174
  }
163
-
164
175
  const mediaSize = overrideSize || this.isServerSide() && ssrSize || this.getCurrentSize(mediaSpec);
165
176
  const styles = this.getMockStyleSheet(mediaSize);
166
177
  return children({
@@ -168,12 +179,16 @@ class MediaLayoutInternal extends React.Component {
168
179
  mediaSpec,
169
180
  styles
170
181
  });
182
+ };
183
+ return MediaLayoutInternal;
184
+ }(React.Component);
185
+ let MediaLayout = function (_React$Component2) {
186
+ _inheritsLoose(MediaLayout, _React$Component2);
187
+ function MediaLayout() {
188
+ return _React$Component2.apply(this, arguments) || this;
171
189
  }
172
-
173
- }
174
-
175
- class MediaLayout extends React.Component {
176
- render() {
190
+ var _proto2 = MediaLayout.prototype;
191
+ _proto2.render = function render() {
177
192
  return React.createElement(MediaLayoutContext.Consumer, null, ({
178
193
  overrideSize,
179
194
  ssrSize,
@@ -183,12 +198,17 @@ class MediaLayout extends React.Component {
183
198
  ssrSize: ssrSize,
184
199
  mediaSpec: mediaSpec
185
200
  })));
186
- }
187
-
188
- }
201
+ };
202
+ return MediaLayout;
203
+ }(React.Component);
189
204
 
190
- class Spring extends React.Component {
191
- render() {
205
+ let Spring = function (_React$Component) {
206
+ _inheritsLoose(Spring, _React$Component);
207
+ function Spring() {
208
+ return _React$Component.apply(this, arguments) || this;
209
+ }
210
+ var _proto = Spring.prototype;
211
+ _proto.render = function render() {
192
212
  const {
193
213
  style
194
214
  } = this.props;
@@ -196,17 +216,22 @@ class Spring extends React.Component {
196
216
  "aria-hidden": "true",
197
217
  style: [styles.grow, style]
198
218
  });
199
- }
200
-
201
- }
219
+ };
220
+ return Spring;
221
+ }(React.Component);
202
222
  const styles = StyleSheet.create({
203
223
  grow: {
204
224
  flexGrow: 1
205
225
  }
206
226
  });
207
227
 
208
- class Strut extends React.Component {
209
- render() {
228
+ let Strut = function (_React$Component) {
229
+ _inheritsLoose(Strut, _React$Component);
230
+ function Strut() {
231
+ return _React$Component.apply(this, arguments) || this;
232
+ }
233
+ var _proto = Strut.prototype;
234
+ _proto.render = function render() {
210
235
  const {
211
236
  size,
212
237
  style
@@ -215,10 +240,9 @@ class Strut extends React.Component {
215
240
  "aria-hidden": "true",
216
241
  style: [strutStyle(size), style]
217
242
  });
218
- }
219
-
220
- }
221
-
243
+ };
244
+ return Strut;
245
+ }(React.Component);
222
246
  const strutStyle = size => {
223
247
  return {
224
248
  width: size,
@@ -234,22 +258,16 @@ const queryMatchesSize = (mediaQuery, mediaSize) => {
234
258
  switch (mediaQuery) {
235
259
  case "all":
236
260
  return true;
237
-
238
261
  case "small":
239
262
  return mediaSize === "small";
240
-
241
263
  case "mdOrSmaller":
242
264
  return mediaSize === "medium" || mediaSize === "small";
243
-
244
265
  case "medium":
245
266
  return mediaSize === "medium";
246
-
247
267
  case "mdOrLarger":
248
268
  return mediaSize === "medium" || mediaSize === "large";
249
-
250
269
  case "large":
251
270
  return mediaSize === "large";
252
-
253
271
  default:
254
272
  throw new Error(`Unsupported mediaSize: ${mediaSize}`);
255
273
  }
@@ -0,0 +1,10 @@
1
+ import type { MediaQuery, MediaSize, MediaSpec } from "./util/types";
2
+ import type { Context } from "./components/media-layout-context";
3
+ import type { MockStyleSheet } from "./components/media-layout";
4
+ export { default as MediaLayout } from "./components/media-layout";
5
+ export { default as MediaLayoutContext } from "./components/media-layout-context";
6
+ export { default as Spring } from "./components/spring";
7
+ export { default as Strut } from "./components/strut";
8
+ export * from "./util/specs";
9
+ export { queryMatchesSize } from "./util/util";
10
+ export type { MediaQuery, MediaSize, MediaSpec, MockStyleSheet, Context as MediaLayoutContextValue, };