@khanacademy/wonder-blocks-core 12.1.1 → 12.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @khanacademy/wonder-blocks-core
2
2
 
3
+ ## 12.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ed26d66: Enables View to accept all tag names
8
+
3
9
  ## 12.1.1
4
10
 
5
11
  ### Patch Changes
@@ -1,11 +1,10 @@
1
1
  import * as React from "react";
2
2
  import type { TextViewSharedProps } from "../util/types";
3
- type ValidViewTags = "div" | "article" | "aside" | "nav" | "section";
4
3
  type Props = TextViewSharedProps & {
5
4
  /**
6
5
  * The HTML tag to render.
7
6
  */
8
- tag?: ValidViewTags;
7
+ tag?: keyof JSX.IntrinsicElements;
9
8
  };
10
9
  /**
11
10
  * View is a building block for constructing other components. `View` roughly
package/dist/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _extends from '@babel/runtime/helpers/extends';
2
2
  import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
3
3
  import * as React from 'react';
4
- import { useId, useEffect as useEffect$1, useContext as useContext$1 } from 'react';
4
+ import { useMemo, useId, useEffect as useEffect$1, useContext as useContext$1 } from 'react';
5
5
  import { StyleSheet, css } from 'aphrodite';
6
6
 
7
7
  function flatten(list) {
@@ -135,11 +135,6 @@ const styles = StyleSheet.create({
135
135
  minWidth: 0
136
136
  }
137
137
  });
138
- const StyledDiv = addStyle("div", styles.default);
139
- const StyledArticle = addStyle("article", styles.default);
140
- const StyledAside = addStyle("aside", styles.default);
141
- const StyledNav = addStyle("nav", styles.default);
142
- const StyledSection = addStyle("section", styles.default);
143
138
  const View = React.forwardRef(function View(props, ref) {
144
139
  const {
145
140
  testId,
@@ -149,30 +144,10 @@ const View = React.forwardRef(function View(props, ref) {
149
144
  const commonProps = _extends({}, restProps, {
150
145
  "data-testid": testId
151
146
  });
152
- switch (tag) {
153
- case "article":
154
- return React.createElement(StyledArticle, _extends({}, commonProps, {
155
- ref: ref
156
- }));
157
- case "aside":
158
- return React.createElement(StyledAside, _extends({}, commonProps, {
159
- ref: ref
160
- }));
161
- case "nav":
162
- return React.createElement(StyledNav, _extends({}, commonProps, {
163
- ref: ref
164
- }));
165
- case "section":
166
- return React.createElement(StyledSection, _extends({}, commonProps, {
167
- ref: ref
168
- }));
169
- case "div":
170
- return React.createElement(StyledDiv, _extends({}, commonProps, {
171
- ref: ref
172
- }));
173
- default:
174
- throw Error(`${tag} is not an allowed value for the 'tag' prop`);
175
- }
147
+ const StyledTag = useMemo(() => addStyle(tag, styles.default), [tag]);
148
+ return React.createElement(StyledTag, _extends({}, commonProps, {
149
+ ref: ref
150
+ }));
176
151
  });
177
152
 
178
153
  let RenderState = function (RenderState) {
package/dist/index.js CHANGED
@@ -162,11 +162,6 @@ const styles = aphrodite.StyleSheet.create({
162
162
  minWidth: 0
163
163
  }
164
164
  });
165
- const StyledDiv = addStyle("div", styles.default);
166
- const StyledArticle = addStyle("article", styles.default);
167
- const StyledAside = addStyle("aside", styles.default);
168
- const StyledNav = addStyle("nav", styles.default);
169
- const StyledSection = addStyle("section", styles.default);
170
165
  const View = React__namespace.forwardRef(function View(props, ref) {
171
166
  const {
172
167
  testId,
@@ -176,30 +171,10 @@ const View = React__namespace.forwardRef(function View(props, ref) {
176
171
  const commonProps = _extends__default["default"]({}, restProps, {
177
172
  "data-testid": testId
178
173
  });
179
- switch (tag) {
180
- case "article":
181
- return React__namespace.createElement(StyledArticle, _extends__default["default"]({}, commonProps, {
182
- ref: ref
183
- }));
184
- case "aside":
185
- return React__namespace.createElement(StyledAside, _extends__default["default"]({}, commonProps, {
186
- ref: ref
187
- }));
188
- case "nav":
189
- return React__namespace.createElement(StyledNav, _extends__default["default"]({}, commonProps, {
190
- ref: ref
191
- }));
192
- case "section":
193
- return React__namespace.createElement(StyledSection, _extends__default["default"]({}, commonProps, {
194
- ref: ref
195
- }));
196
- case "div":
197
- return React__namespace.createElement(StyledDiv, _extends__default["default"]({}, commonProps, {
198
- ref: ref
199
- }));
200
- default:
201
- throw Error(`${tag} is not an allowed value for the 'tag' prop`);
202
- }
174
+ const StyledTag = React.useMemo(() => addStyle(tag, styles.default), [tag]);
175
+ return React__namespace.createElement(StyledTag, _extends__default["default"]({}, commonProps, {
176
+ ref: ref
177
+ }));
203
178
  });
204
179
 
205
180
  let RenderState = function (RenderState) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-core",
3
- "version": "12.1.1",
3
+ "version": "12.2.0",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "@khanacademy/wb-dev-build-settings": "2.1.1",
24
- "@khanacademy/wonder-blocks-testing-core": "2.1.1"
24
+ "@khanacademy/wonder-blocks-testing-core": "2.2.0"
25
25
  },
26
26
  "author": "",
27
27
  "license": "MIT",