@khanacademy/wonder-blocks-cell 2.2.13 → 2.2.15

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,29 @@
1
1
  # @khanacademy/wonder-blocks-cell
2
2
 
3
+ ## 2.2.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 91cb727c: Remove file extensions from imports
8
+ - Updated dependencies [91cb727c]
9
+ - Updated dependencies [91cb727c]
10
+ - Updated dependencies [91cb727c]
11
+ - @khanacademy/wonder-blocks-clickable@2.4.5
12
+ - @khanacademy/wonder-blocks-color@1.2.1
13
+ - @khanacademy/wonder-blocks-core@4.7.0
14
+ - @khanacademy/wonder-blocks-layout@1.4.16
15
+ - @khanacademy/wonder-blocks-typography@1.1.38
16
+
17
+ ## 2.2.14
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [496119f2]
22
+ - @khanacademy/wonder-blocks-clickable@2.4.4
23
+ - @khanacademy/wonder-blocks-core@4.6.2
24
+ - @khanacademy/wonder-blocks-layout@1.4.15
25
+ - @khanacademy/wonder-blocks-typography@1.1.37
26
+
3
27
  ## 2.2.13
4
28
 
5
29
  ### Patch Changes
package/dist/index.js ADDED
@@ -0,0 +1,300 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
6
+ var React = require('react');
7
+ var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
8
+ var _extends = require('@babel/runtime/helpers/extends');
9
+ var aphrodite = require('aphrodite');
10
+ var Clickable = require('@khanacademy/wonder-blocks-clickable');
11
+ var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
12
+ var Color = require('@khanacademy/wonder-blocks-color');
13
+ var wonderBlocksLayout = require('@khanacademy/wonder-blocks-layout');
14
+ var Spacing = require('@khanacademy/wonder-blocks-spacing');
15
+
16
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
+
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n["default"] = e;
33
+ return Object.freeze(n);
34
+ }
35
+
36
+ var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
37
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
38
+ var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
39
+ var Clickable__default = /*#__PURE__*/_interopDefaultLegacy(Clickable);
40
+ var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
41
+ var Spacing__default = /*#__PURE__*/_interopDefaultLegacy(Spacing);
42
+
43
+ const CellMeasurements = {
44
+ cellMinHeight: Spacing__default["default"].xxLarge_48,
45
+ cellPadding: {
46
+ paddingVertical: Spacing__default["default"].small_12,
47
+ paddingHorizontal: Spacing__default["default"].medium_16
48
+ },
49
+ detailCellPadding: {
50
+ paddingVertical: Spacing__default["default"].medium_16,
51
+ paddingHorizontal: Spacing__default["default"].medium_16
52
+ },
53
+ accessoryHorizontalSpacing: Spacing__default["default"].medium_16
54
+ };
55
+ const getHorizontalRuleStyles = horizontalRule => {
56
+ switch (horizontalRule) {
57
+ case "inset":
58
+ return [styles$2.horizontalRule, styles$2.horizontalRuleInset];
59
+
60
+ case "full-width":
61
+ return styles$2.horizontalRule;
62
+
63
+ case "none":
64
+ return {};
65
+ }
66
+ };
67
+ const styles$2 = aphrodite.StyleSheet.create({
68
+ horizontalRule: {
69
+ position: "relative",
70
+ ":after": {
71
+ width: "100%",
72
+ content: "''",
73
+ position: "absolute",
74
+ bottom: 0,
75
+ right: 0,
76
+ height: Spacing__default["default"].xxxxSmall_2,
77
+ boxShadow: `inset 0px -1px 0px ${Color__default["default"].offBlack8}`
78
+ }
79
+ },
80
+ horizontalRuleInset: {
81
+ ":after": {
82
+ width: `calc(100% - ${CellMeasurements.cellPadding.paddingHorizontal}px)`
83
+ }
84
+ }
85
+ });
86
+
87
+ const LeftAccessory = ({
88
+ leftAccessory,
89
+ leftAccessoryStyle,
90
+ disabled
91
+ }) => {
92
+ if (!leftAccessory) {
93
+ return null;
94
+ }
95
+
96
+ return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksCore.View, {
97
+ style: [styles$1.accessory, disabled && styles$1.accessoryDisabled, _extends__default["default"]({}, leftAccessoryStyle)]
98
+ }, leftAccessory), React__namespace.createElement(wonderBlocksLayout.Strut, {
99
+ size: CellMeasurements.accessoryHorizontalSpacing
100
+ }));
101
+ };
102
+
103
+ const RightAccessory = ({
104
+ rightAccessory,
105
+ rightAccessoryStyle,
106
+ active,
107
+ disabled
108
+ }) => {
109
+ if (!rightAccessory) {
110
+ return null;
111
+ }
112
+
113
+ return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksLayout.Strut, {
114
+ size: CellMeasurements.accessoryHorizontalSpacing
115
+ }), React__namespace.createElement(wonderBlocksCore.View, {
116
+ style: [styles$1.accessory, styles$1.accessoryRight, disabled && styles$1.accessoryDisabled, _extends__default["default"]({}, rightAccessoryStyle), active && styles$1.accessoryActive]
117
+ }, rightAccessory));
118
+ };
119
+
120
+ const CellCore = props => {
121
+ const {
122
+ active,
123
+ children,
124
+ disabled,
125
+ href,
126
+ horizontalRule = "inset",
127
+ leftAccessory = undefined,
128
+ leftAccessoryStyle = undefined,
129
+ onClick,
130
+ rightAccessory = undefined,
131
+ rightAccessoryStyle = undefined,
132
+ style,
133
+ testId,
134
+ "aria-label": ariaLabel,
135
+ innerStyle,
136
+ target
137
+ } = props;
138
+
139
+ const renderCell = eventState => {
140
+ const horizontalRuleStyles = getHorizontalRuleStyles(horizontalRule);
141
+ return React__namespace.createElement(wonderBlocksCore.View, {
142
+ style: [styles$1.wrapper, (eventState == null ? void 0 : eventState.focused) && styles$1.focused],
143
+ "aria-current": active ? "true" : undefined
144
+ }, React__namespace.createElement(wonderBlocksCore.View, {
145
+ style: [styles$1.innerWrapper, innerStyle, style, horizontalRuleStyles, disabled && styles$1.disabled, active && styles$1.active, !disabled && (eventState == null ? void 0 : eventState.hovered) && styles$1.hovered, active && (eventState == null ? void 0 : eventState.hovered) && styles$1.activeHovered, !disabled && (eventState == null ? void 0 : eventState.pressed) && styles$1.pressed, !disabled && active && (eventState == null ? void 0 : eventState.pressed) && styles$1.activePressed]
146
+ }, React__namespace.createElement(LeftAccessory, {
147
+ leftAccessory: leftAccessory,
148
+ leftAccessoryStyle: leftAccessoryStyle,
149
+ disabled: disabled
150
+ }), React__namespace.createElement(wonderBlocksCore.View, {
151
+ style: styles$1.content,
152
+ testId: testId
153
+ }, children), React__namespace.createElement(RightAccessory, {
154
+ rightAccessory: rightAccessory,
155
+ rightAccessoryStyle: rightAccessoryStyle,
156
+ active: active,
157
+ disabled: disabled
158
+ })));
159
+ };
160
+
161
+ if (onClick || href) {
162
+ return React__namespace.createElement(Clickable__default["default"], {
163
+ disabled: disabled,
164
+ onClick: onClick,
165
+ href: href,
166
+ hideDefaultFocusRing: true,
167
+ "aria-label": ariaLabel ? ariaLabel : undefined,
168
+ target: target
169
+ }, eventState => renderCell(eventState));
170
+ }
171
+
172
+ return renderCell();
173
+ };
174
+
175
+ const styles$1 = aphrodite.StyleSheet.create({
176
+ wrapper: {
177
+ background: Color__default["default"].white,
178
+ color: Color__default["default"].offBlack,
179
+ minHeight: CellMeasurements.cellMinHeight,
180
+ textAlign: "left"
181
+ },
182
+ innerWrapper: {
183
+ padding: `${CellMeasurements.cellPadding.paddingVertical}px ${CellMeasurements.cellPadding.paddingHorizontal}px`,
184
+ flexDirection: "row",
185
+ flex: 1
186
+ },
187
+ content: {
188
+ alignSelf: "center",
189
+ flex: 1,
190
+ overflowWrap: "break-word"
191
+ },
192
+ accessory: {
193
+ minWidth: "auto",
194
+ alignItems: "center",
195
+ alignSelf: "center"
196
+ },
197
+ accessoryRight: {
198
+ color: Color__default["default"].offBlack64
199
+ },
200
+ hovered: {
201
+ background: Color__default["default"].offBlack8
202
+ },
203
+ focused: {
204
+ borderRadius: Spacing__default["default"].xxxSmall_4,
205
+ outline: `solid ${Spacing__default["default"].xxxxSmall_2}px ${Color__default["default"].blue}`,
206
+ outlineOffset: -Spacing__default["default"].xxxxSmall_2,
207
+ overflow: "hidden"
208
+ },
209
+ pressed: {
210
+ background: Color__default["default"].offBlack16
211
+ },
212
+ active: {
213
+ background: Color.fade(Color__default["default"].blue, 0.08),
214
+ color: Color__default["default"].blue
215
+ },
216
+ activeHovered: {
217
+ background: Color.fade(Color__default["default"].blue, 0.16)
218
+ },
219
+ activePressed: {
220
+ background: Color.fade(Color__default["default"].blue, 0.24)
221
+ },
222
+ disabled: {
223
+ color: Color__default["default"].offBlack32,
224
+ ":hover": {
225
+ cursor: "not-allowed"
226
+ }
227
+ },
228
+ accessoryActive: {
229
+ color: Color__default["default"].blue
230
+ },
231
+ accessoryDisabled: {
232
+ color: Color__default["default"].offBlack,
233
+ opacity: 0.32
234
+ }
235
+ });
236
+
237
+ const _excluded$1 = ["title"];
238
+
239
+ function CompactCell(props) {
240
+ const {
241
+ title
242
+ } = props,
243
+ coreProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$1);
244
+
245
+ return React__namespace.createElement(CellCore, coreProps, typeof title === "string" ? React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, title) : title);
246
+ }
247
+
248
+ const _excluded = ["title", "subtitle1", "subtitle2"];
249
+
250
+ const Subtitle = ({
251
+ subtitle,
252
+ disabled
253
+ }) => {
254
+ if (!subtitle) {
255
+ return null;
256
+ }
257
+
258
+ if (typeof subtitle === "string") {
259
+ return React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
260
+ style: !disabled && styles.subtitle
261
+ }, subtitle);
262
+ }
263
+
264
+ return subtitle;
265
+ };
266
+
267
+ function DetailCell(props) {
268
+ const {
269
+ title,
270
+ subtitle1,
271
+ subtitle2
272
+ } = props,
273
+ coreProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded);
274
+
275
+ return React__namespace.createElement(CellCore, _extends__default["default"]({}, coreProps, {
276
+ innerStyle: styles.innerWrapper
277
+ }), React__namespace.createElement(Subtitle, {
278
+ subtitle: subtitle1,
279
+ disabled: coreProps.disabled
280
+ }), subtitle1 && React__namespace.createElement(wonderBlocksLayout.Strut, {
281
+ size: Spacing__default["default"].xxxxSmall_2
282
+ }), typeof title === "string" ? React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, title) : title, subtitle2 && React__namespace.createElement(wonderBlocksLayout.Strut, {
283
+ size: Spacing__default["default"].xxxxSmall_2
284
+ }), React__namespace.createElement(Subtitle, {
285
+ subtitle: subtitle2,
286
+ disabled: coreProps.disabled
287
+ }));
288
+ }
289
+
290
+ const styles = aphrodite.StyleSheet.create({
291
+ subtitle: {
292
+ color: Color__default["default"].offBlack64
293
+ },
294
+ innerWrapper: {
295
+ padding: `${CellMeasurements.detailCellPadding.paddingVertical}px ${CellMeasurements.detailCellPadding.paddingHorizontal}px`
296
+ }
297
+ });
298
+
299
+ exports.CompactCell = CompactCell;
300
+ exports.DetailCell = DetailCell;
@@ -1,2 +1,2 @@
1
1
  // @flow
2
- export * from "../src/index.js";
2
+ export * from "../src/index";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-cell",
3
- "version": "2.2.13",
3
+ "version": "2.2.15",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,19 +14,19 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime": "^7.18.6",
17
- "@khanacademy/wonder-blocks-clickable": "^2.4.3",
18
- "@khanacademy/wonder-blocks-color": "^1.2.0",
19
- "@khanacademy/wonder-blocks-core": "^4.6.1",
20
- "@khanacademy/wonder-blocks-layout": "^1.4.14",
17
+ "@khanacademy/wonder-blocks-clickable": "^2.4.5",
18
+ "@khanacademy/wonder-blocks-color": "^1.2.1",
19
+ "@khanacademy/wonder-blocks-core": "^4.7.0",
20
+ "@khanacademy/wonder-blocks-layout": "^1.4.16",
21
21
  "@khanacademy/wonder-blocks-spacing": "^3.0.5",
22
- "@khanacademy/wonder-blocks-typography": "^1.1.36"
22
+ "@khanacademy/wonder-blocks-typography": "^1.1.38"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "aphrodite": "^1.2.5",
26
26
  "react": "16.14.0"
27
27
  },
28
28
  "devDependencies": {
29
- "wb-dev-build-settings": "^0.6.0"
29
+ "wb-dev-build-settings": "^0.7.1"
30
30
  },
31
31
  "author": "",
32
32
  "license": "MIT"
@@ -12,13 +12,11 @@ import type {StoryComponentType} from "@storybook/react";
12
12
 
13
13
  import type {IconAsset} from "@khanacademy/wonder-blocks-icon";
14
14
 
15
- import ComponentInfo from "../../../../../.storybook/components/component-info.js";
15
+ import ComponentInfo from "../../../../../.storybook/components/component-info";
16
16
  import {name, version} from "../../../package.json";
17
- import CompactCellArgTypes, {
18
- AccessoryMappings,
19
- } from "./compact-cell.argtypes.js";
17
+ import CompactCellArgTypes, {AccessoryMappings} from "./compact-cell.argtypes";
20
18
 
21
- import CompactCell from "../compact-cell.js";
19
+ import CompactCell from "../compact-cell";
22
20
 
23
21
  export default {
24
22
  title: "Cell / CompactCell",
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- import CompactCellArgTypes from "./compact-cell.argtypes.js";
2
+ import CompactCellArgTypes from "./compact-cell.argtypes";
3
3
 
4
4
  export default {
5
5
  ...CompactCellArgTypes,
@@ -10,11 +10,11 @@ import Icon, {icons} from "@khanacademy/wonder-blocks-icon";
10
10
 
11
11
  import type {StoryComponentType} from "@storybook/react";
12
12
 
13
- import ComponentInfo from "../../../../../.storybook/components/component-info.js";
13
+ import ComponentInfo from "../../../../../.storybook/components/component-info";
14
14
  import {name, version} from "../../../package.json";
15
- import DetailCellArgTypes from "./detail-cell.argtypes.js";
15
+ import DetailCellArgTypes from "./detail-cell.argtypes";
16
16
 
17
- import DetailCell from "../detail-cell.js";
17
+ import DetailCell from "../detail-cell";
18
18
 
19
19
  export default {
20
20
  title: "Cell / DetailCell",
@@ -5,7 +5,7 @@ import {render, screen} from "@testing-library/react";
5
5
  import Icon, {icons} from "@khanacademy/wonder-blocks-icon";
6
6
  import {HeadingMedium} from "@khanacademy/wonder-blocks-typography";
7
7
 
8
- import CompactCell from "../compact-cell.js";
8
+ import CompactCell from "../compact-cell";
9
9
 
10
10
  describe("CompactCell", () => {
11
11
  it("should render the default CompactCell component", () => {
@@ -4,7 +4,7 @@ import {render, screen} from "@testing-library/react";
4
4
 
5
5
  import {HeadingMedium} from "@khanacademy/wonder-blocks-typography";
6
6
 
7
- import DetailCell from "../detail-cell.js";
7
+ import DetailCell from "../detail-cell";
8
8
 
9
9
  describe("DetailCell", () => {
10
10
  it("should render the default DetailCell component", () => {
@@ -3,9 +3,9 @@ import * as React from "react";
3
3
 
4
4
  import {LabelMedium} from "@khanacademy/wonder-blocks-typography";
5
5
 
6
- import CellCore from "./internal/cell-core.js";
6
+ import CellCore from "./internal/cell-core";
7
7
 
8
- import type {CellProps} from "../util/types.js";
8
+ import type {CellProps} from "../util/types";
9
9
 
10
10
  /**
11
11
  * `CompactCell` is the simplest form of the Cell. It is a compacted-height Cell
@@ -7,10 +7,10 @@ import {Strut} from "@khanacademy/wonder-blocks-layout";
7
7
  import Spacing from "@khanacademy/wonder-blocks-spacing";
8
8
  import {LabelSmall, LabelMedium} from "@khanacademy/wonder-blocks-typography";
9
9
 
10
- import CellCore from "./internal/cell-core.js";
11
- import {CellMeasurements} from "./internal/common.js";
10
+ import CellCore from "./internal/cell-core";
11
+ import {CellMeasurements} from "./internal/common";
12
12
 
13
- import type {CellProps, TypographyText} from "../util/types.js";
13
+ import type {CellProps, TypographyText} from "../util/types";
14
14
 
15
15
  type SubtitleProps = {|
16
16
  subtitle?: TypographyText,
@@ -2,7 +2,7 @@
2
2
  import * as React from "react";
3
3
  import {render, screen} from "@testing-library/react";
4
4
 
5
- import CellCore from "../cell-core.js";
5
+ import CellCore from "../cell-core";
6
6
 
7
7
  describe("CellCore", () => {
8
8
  it("should render the CellCore component", () => {
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
 
3
- import {getHorizontalRuleStyles} from "../common.js";
3
+ import {getHorizontalRuleStyles} from "../common";
4
4
 
5
5
  describe("getHorizontalRuleStyles", () => {
6
6
  it("should get 'inset' styles as an array", () => {
@@ -11,9 +11,9 @@ import {Strut} from "@khanacademy/wonder-blocks-layout";
11
11
  import Spacing from "@khanacademy/wonder-blocks-spacing";
12
12
 
13
13
  import type {ClickableState} from "@khanacademy/wonder-blocks-clickable";
14
- import {CellMeasurements, getHorizontalRuleStyles} from "./common.js";
14
+ import {CellMeasurements, getHorizontalRuleStyles} from "./common";
15
15
 
16
- import type {CellProps, TypographyText} from "../../util/types.js";
16
+ import type {CellProps, TypographyText} from "../../util/types";
17
17
 
18
18
  type LeftAccessoryProps = {|
19
19
  leftAccessory?: CellProps["leftAccessory"],
@@ -5,7 +5,7 @@ import Color from "@khanacademy/wonder-blocks-color";
5
5
  import Spacing from "@khanacademy/wonder-blocks-spacing";
6
6
 
7
7
  import type {StyleType} from "@khanacademy/wonder-blocks-core";
8
- import type {HorizontalRuleVariant} from "../../util/types.js";
8
+ import type {HorizontalRuleVariant} from "../../util/types";
9
9
 
10
10
  export const CellMeasurements = {
11
11
  cellMinHeight: Spacing.xxLarge_48,
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- import CompactCell from "./components/compact-cell.js";
3
- import DetailCell from "./components/detail-cell.js";
2
+ import CompactCell from "./components/compact-cell";
3
+ import DetailCell from "./components/detail-cell";
4
4
 
5
5
  export {CompactCell, DetailCell};