@khanacademy/wonder-blocks-cell 2.2.15 → 2.2.17
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 +38 -0
- package/dist/components/compact-cell.d.ts +22 -0
- package/dist/components/compact-cell.js.flow +30 -0
- package/dist/components/detail-cell.d.ts +39 -0
- package/dist/components/detail-cell.js.flow +51 -0
- package/dist/components/internal/cell-core.d.ts +26 -0
- package/dist/components/internal/cell-core.js.flow +38 -0
- package/dist/components/internal/common.d.ts +30 -0
- package/dist/components/internal/common.js.flow +45 -0
- package/dist/es/index.js +40 -32
- package/dist/index.d.ts +3 -0
- package/dist/index.js +57 -51
- package/dist/index.js.flow +10 -2
- package/dist/util/types.d.ts +122 -0
- package/dist/util/types.js.flow +148 -0
- package/package.json +9 -9
- package/src/components/__tests__/{compact-cell.test.js → compact-cell.test.tsx} +0 -1
- package/src/components/__tests__/{detail-cell.test.js → detail-cell.test.tsx} +0 -1
- package/src/components/{compact-cell.js → compact-cell.tsx} +2 -3
- package/src/components/{detail-cell.js → detail-cell.tsx} +17 -15
- package/src/components/internal/__tests__/{cell-core.test.js → cell-core.test.tsx} +0 -1
- package/src/components/internal/__tests__/{common.test.js → common.test.ts} +0 -2
- package/src/components/internal/{cell-core.js → cell-core.tsx} +27 -26
- package/src/components/internal/{common.js → common.ts} +1 -2
- package/src/{index.js → index.ts} +0 -1
- package/src/util/{types.js → types.ts} +25 -39
- package/tsconfig.json +17 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/components/__docs__/compact-cell.argtypes.js +0 -189
- package/src/components/__docs__/compact-cell.stories.js +0 -303
- package/src/components/__docs__/detail-cell.argtypes.js +0 -28
- package/src/components/__docs__/detail-cell.stories.js +0 -208
package/dist/index.js
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
|
|
8
|
-
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
7
|
var aphrodite = require('aphrodite');
|
|
10
8
|
var Clickable = require('@khanacademy/wonder-blocks-clickable');
|
|
11
9
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
@@ -16,30 +14,56 @@ var Spacing = require('@khanacademy/wonder-blocks-spacing');
|
|
|
16
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
15
|
|
|
18
16
|
function _interopNamespace(e) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
}
|
|
17
|
+
if (e && e.__esModule) return e;
|
|
18
|
+
var n = Object.create(null);
|
|
19
|
+
if (e) {
|
|
20
|
+
Object.keys(e).forEach(function (k) {
|
|
21
|
+
if (k !== 'default') {
|
|
22
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return e[k]; }
|
|
30
26
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
n["default"] = e;
|
|
31
|
+
return Object.freeze(n);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
|
|
37
34
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
38
|
-
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
39
35
|
var Clickable__default = /*#__PURE__*/_interopDefaultLegacy(Clickable);
|
|
40
36
|
var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
|
|
41
37
|
var Spacing__default = /*#__PURE__*/_interopDefaultLegacy(Spacing);
|
|
42
38
|
|
|
39
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
40
|
+
if (source == null) return {};
|
|
41
|
+
var target = {};
|
|
42
|
+
var sourceKeys = Object.keys(source);
|
|
43
|
+
var key, i;
|
|
44
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
45
|
+
key = sourceKeys[i];
|
|
46
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
47
|
+
target[key] = source[key];
|
|
48
|
+
}
|
|
49
|
+
return target;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _extends() {
|
|
53
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
54
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
55
|
+
var source = arguments[i];
|
|
56
|
+
for (var key in source) {
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
58
|
+
target[key] = source[key];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return target;
|
|
63
|
+
};
|
|
64
|
+
return _extends.apply(this, arguments);
|
|
65
|
+
}
|
|
66
|
+
|
|
43
67
|
const CellMeasurements = {
|
|
44
68
|
cellMinHeight: Spacing__default["default"].xxLarge_48,
|
|
45
69
|
cellPadding: {
|
|
@@ -56,10 +80,8 @@ const getHorizontalRuleStyles = horizontalRule => {
|
|
|
56
80
|
switch (horizontalRule) {
|
|
57
81
|
case "inset":
|
|
58
82
|
return [styles$2.horizontalRule, styles$2.horizontalRuleInset];
|
|
59
|
-
|
|
60
83
|
case "full-width":
|
|
61
84
|
return styles$2.horizontalRule;
|
|
62
|
-
|
|
63
85
|
case "none":
|
|
64
86
|
return {};
|
|
65
87
|
}
|
|
@@ -92,14 +114,12 @@ const LeftAccessory = ({
|
|
|
92
114
|
if (!leftAccessory) {
|
|
93
115
|
return null;
|
|
94
116
|
}
|
|
95
|
-
|
|
96
117
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksCore.View, {
|
|
97
|
-
style: [styles$1.accessory, disabled && styles$1.accessoryDisabled,
|
|
118
|
+
style: [styles$1.accessory, disabled && styles$1.accessoryDisabled, _extends({}, leftAccessoryStyle)]
|
|
98
119
|
}, leftAccessory), React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
99
120
|
size: CellMeasurements.accessoryHorizontalSpacing
|
|
100
121
|
}));
|
|
101
122
|
};
|
|
102
|
-
|
|
103
123
|
const RightAccessory = ({
|
|
104
124
|
rightAccessory,
|
|
105
125
|
rightAccessoryStyle,
|
|
@@ -109,14 +129,12 @@ const RightAccessory = ({
|
|
|
109
129
|
if (!rightAccessory) {
|
|
110
130
|
return null;
|
|
111
131
|
}
|
|
112
|
-
|
|
113
132
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
114
133
|
size: CellMeasurements.accessoryHorizontalSpacing
|
|
115
134
|
}), React__namespace.createElement(wonderBlocksCore.View, {
|
|
116
|
-
style: [styles$1.accessory, styles$1.accessoryRight, disabled && styles$1.accessoryDisabled,
|
|
135
|
+
style: [styles$1.accessory, styles$1.accessoryRight, disabled && styles$1.accessoryDisabled, _extends({}, rightAccessoryStyle), active && styles$1.accessoryActive]
|
|
117
136
|
}, rightAccessory));
|
|
118
137
|
};
|
|
119
|
-
|
|
120
138
|
const CellCore = props => {
|
|
121
139
|
const {
|
|
122
140
|
active,
|
|
@@ -135,7 +153,6 @@ const CellCore = props => {
|
|
|
135
153
|
innerStyle,
|
|
136
154
|
target
|
|
137
155
|
} = props;
|
|
138
|
-
|
|
139
156
|
const renderCell = eventState => {
|
|
140
157
|
const horizontalRuleStyles = getHorizontalRuleStyles(horizontalRule);
|
|
141
158
|
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
@@ -157,7 +174,6 @@ const CellCore = props => {
|
|
|
157
174
|
disabled: disabled
|
|
158
175
|
})));
|
|
159
176
|
};
|
|
160
|
-
|
|
161
177
|
if (onClick || href) {
|
|
162
178
|
return React__namespace.createElement(Clickable__default["default"], {
|
|
163
179
|
disabled: disabled,
|
|
@@ -168,10 +184,8 @@ const CellCore = props => {
|
|
|
168
184
|
target: target
|
|
169
185
|
}, eventState => renderCell(eventState));
|
|
170
186
|
}
|
|
171
|
-
|
|
172
187
|
return renderCell();
|
|
173
188
|
};
|
|
174
|
-
|
|
175
189
|
const styles$1 = aphrodite.StyleSheet.create({
|
|
176
190
|
wrapper: {
|
|
177
191
|
background: Color__default["default"].white,
|
|
@@ -235,18 +249,15 @@ const styles$1 = aphrodite.StyleSheet.create({
|
|
|
235
249
|
});
|
|
236
250
|
|
|
237
251
|
const _excluded$1 = ["title"];
|
|
238
|
-
|
|
239
|
-
function CompactCell(props) {
|
|
252
|
+
const CompactCell = function CompactCell(props) {
|
|
240
253
|
const {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
254
|
+
title
|
|
255
|
+
} = props,
|
|
256
|
+
coreProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
245
257
|
return React__namespace.createElement(CellCore, coreProps, typeof title === "string" ? React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, title) : title);
|
|
246
|
-
}
|
|
258
|
+
};
|
|
247
259
|
|
|
248
260
|
const _excluded = ["title", "subtitle1", "subtitle2"];
|
|
249
|
-
|
|
250
261
|
const Subtitle = ({
|
|
251
262
|
subtitle,
|
|
252
263
|
disabled
|
|
@@ -254,25 +265,21 @@ const Subtitle = ({
|
|
|
254
265
|
if (!subtitle) {
|
|
255
266
|
return null;
|
|
256
267
|
}
|
|
257
|
-
|
|
258
268
|
if (typeof subtitle === "string") {
|
|
259
269
|
return React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
|
|
260
270
|
style: !disabled && styles.subtitle
|
|
261
271
|
}, subtitle);
|
|
262
272
|
}
|
|
263
|
-
|
|
264
273
|
return subtitle;
|
|
265
274
|
};
|
|
266
|
-
|
|
267
|
-
function DetailCell(props) {
|
|
275
|
+
const DetailCell = function DetailCell(props) {
|
|
268
276
|
const {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return React__namespace.createElement(CellCore, _extends__default["default"]({}, coreProps, {
|
|
277
|
+
title,
|
|
278
|
+
subtitle1,
|
|
279
|
+
subtitle2
|
|
280
|
+
} = props,
|
|
281
|
+
coreProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
282
|
+
return React__namespace.createElement(CellCore, _extends({}, coreProps, {
|
|
276
283
|
innerStyle: styles.innerWrapper
|
|
277
284
|
}), React__namespace.createElement(Subtitle, {
|
|
278
285
|
subtitle: subtitle1,
|
|
@@ -285,8 +292,7 @@ function DetailCell(props) {
|
|
|
285
292
|
subtitle: subtitle2,
|
|
286
293
|
disabled: coreProps.disabled
|
|
287
294
|
}));
|
|
288
|
-
}
|
|
289
|
-
|
|
295
|
+
};
|
|
290
296
|
const styles = aphrodite.StyleSheet.create({
|
|
291
297
|
subtitle: {
|
|
292
298
|
color: Color__default["default"].offBlack64
|
package/dist/index.js.flow
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for index
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import CompactCell from "./components/compact-cell";
|
|
9
|
+
import DetailCell from "./components/detail-cell";
|
|
10
|
+
declare export { CompactCell, DetailCell };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
import type { Typography } from "@khanacademy/wonder-blocks-typography";
|
|
4
|
+
/**
|
|
5
|
+
* A set of values that can be used to configure the horizontal rule appearance.
|
|
6
|
+
*/
|
|
7
|
+
export type HorizontalRuleVariant = "full-width" | "inset" | "none";
|
|
8
|
+
/**
|
|
9
|
+
* An element or component that represents an accessory within a cell.
|
|
10
|
+
*/
|
|
11
|
+
type Accessory = React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* A subset of CSS Properties to allow overriding some of the default styles set
|
|
14
|
+
* on the accessory wrapper (loosely based on StyleType).
|
|
15
|
+
*/
|
|
16
|
+
export type AccessoryStyle = {
|
|
17
|
+
/**
|
|
18
|
+
* A subset of valid Spacing values.
|
|
19
|
+
*/
|
|
20
|
+
minWidth?: 16 | 24 | 32 | 48;
|
|
21
|
+
/**
|
|
22
|
+
* To vertically align the accessory.
|
|
23
|
+
*/
|
|
24
|
+
alignSelf?: "flex-start" | "flex-end" | "center";
|
|
25
|
+
/**
|
|
26
|
+
* To horizontally align the accessory.
|
|
27
|
+
*/
|
|
28
|
+
alignItems?: "flex-start" | "flex-end" | "center";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A union that allows using plain text or WB Typography elements.
|
|
32
|
+
*/
|
|
33
|
+
export type TypographyText = string | React.ReactElement<React.ComponentProps<Typography>>;
|
|
34
|
+
/**
|
|
35
|
+
* Common properties for all cells.
|
|
36
|
+
*/
|
|
37
|
+
export type CellProps = {
|
|
38
|
+
/**
|
|
39
|
+
* The title / main content of the cell. You can either provide a string or
|
|
40
|
+
* a Typography component. If a string is provided, typography defaults to
|
|
41
|
+
* LabelLarge.
|
|
42
|
+
*/
|
|
43
|
+
title: TypographyText;
|
|
44
|
+
/**
|
|
45
|
+
* If provided, this adds a left accessory to the cell. Left
|
|
46
|
+
* Accessories can be defined using WB components such as Icon,
|
|
47
|
+
* IconButton, or it can even be used for a custom node/component if
|
|
48
|
+
* needed. What ever is passed in will occupy the "LeftAccessory” area
|
|
49
|
+
* of the Cell.
|
|
50
|
+
*/
|
|
51
|
+
leftAccessory?: Accessory;
|
|
52
|
+
/**
|
|
53
|
+
* Optional custom styles applied to the leftAccessory wrapper. For
|
|
54
|
+
* example, it can be used to set a custom minWidth or a custom
|
|
55
|
+
* alignment.
|
|
56
|
+
*
|
|
57
|
+
* NOTE: leftAccessoryStyle can only be used if leftAccessory is set.
|
|
58
|
+
*/
|
|
59
|
+
leftAccessoryStyle?: AccessoryStyle;
|
|
60
|
+
/**
|
|
61
|
+
* If provided, this adds a right accessory to the cell. Right
|
|
62
|
+
* Accessories can be defined using WB components such as Icon,
|
|
63
|
+
* IconButton, or it can even be used for a custom node/component if
|
|
64
|
+
* needed. What ever is passed in will occupy the “RightAccessory”
|
|
65
|
+
* area of the Cell.
|
|
66
|
+
*/
|
|
67
|
+
rightAccessory?: Accessory;
|
|
68
|
+
/**
|
|
69
|
+
* Optional custom styles applied to the rightAccessory wrapper. For
|
|
70
|
+
* example, it can be used to set a custom minWidth or a custom
|
|
71
|
+
* alignment.
|
|
72
|
+
*
|
|
73
|
+
* NOTE: rightAccessoryStyle can only be used if rightAccessory is
|
|
74
|
+
* set.
|
|
75
|
+
*/
|
|
76
|
+
rightAccessoryStyle?: AccessoryStyle;
|
|
77
|
+
/**
|
|
78
|
+
* Adds a horizontal rule at the bottom of the cell that can be used to
|
|
79
|
+
* separate cells within groups such as lists. Defaults to `inset`.
|
|
80
|
+
*/
|
|
81
|
+
horizontalRule?: HorizontalRuleVariant;
|
|
82
|
+
/**
|
|
83
|
+
* Optional custom styles applied to the cell container.
|
|
84
|
+
*/
|
|
85
|
+
style?: StyleType;
|
|
86
|
+
/**
|
|
87
|
+
* Optional test ID for e2e testing.
|
|
88
|
+
*/
|
|
89
|
+
testId?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Called when the cell is clicked.
|
|
92
|
+
*
|
|
93
|
+
* If not provided, the Cell can’t be hovered and/or pressed (highlighted on
|
|
94
|
+
* hover).
|
|
95
|
+
*/
|
|
96
|
+
onClick?: (e: React.SyntheticEvent) => unknown;
|
|
97
|
+
/**
|
|
98
|
+
* Whether the cell is active (or currently selected).
|
|
99
|
+
*/
|
|
100
|
+
active?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the cell is disabled.
|
|
103
|
+
*/
|
|
104
|
+
disabled?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Used to announce the cell's content to screen readers.
|
|
107
|
+
*/
|
|
108
|
+
["aria-label"]?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Optinal href which Cell should direct to, uses client-side routing
|
|
111
|
+
* by default if react-router is present.
|
|
112
|
+
*/
|
|
113
|
+
href?: string;
|
|
114
|
+
/**
|
|
115
|
+
* A target destination window for a link to open in. Should only be used
|
|
116
|
+
* when `href` is specified.
|
|
117
|
+
*
|
|
118
|
+
* TODO(WB-1262): only allow this prop when `href` is also set.t
|
|
119
|
+
*/
|
|
120
|
+
target?: "_blank";
|
|
121
|
+
};
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for types
|
|
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
|
+
import type { Typography } from "@khanacademy/wonder-blocks-typography";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A set of values that can be used to configure the horizontal rule appearance.
|
|
14
|
+
*/
|
|
15
|
+
export type HorizontalRuleVariant = "full-width" | "inset" | "none";
|
|
16
|
+
/**
|
|
17
|
+
* An element or component that represents an accessory within a cell.
|
|
18
|
+
*/
|
|
19
|
+
declare type Accessory = React.Node;
|
|
20
|
+
/**
|
|
21
|
+
* A subset of CSS Properties to allow overriding some of the default styles set
|
|
22
|
+
* on the accessory wrapper (loosely based on StyleType).
|
|
23
|
+
*/
|
|
24
|
+
export type AccessoryStyle = {
|
|
25
|
+
/**
|
|
26
|
+
* A subset of valid Spacing values.
|
|
27
|
+
*/
|
|
28
|
+
minWidth?: 16 | 24 | 32 | 48,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* To vertically align the accessory.
|
|
32
|
+
*/
|
|
33
|
+
alignSelf?: "flex-start" | "flex-end" | "center",
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* To horizontally align the accessory.
|
|
37
|
+
*/
|
|
38
|
+
alignItems?: "flex-start" | "flex-end" | "center",
|
|
39
|
+
...
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A union that allows using plain text or WB Typography elements.
|
|
43
|
+
*/
|
|
44
|
+
export type TypographyText =
|
|
45
|
+
| string
|
|
46
|
+
| React.Element<React.ComponentProps<Typography>>;
|
|
47
|
+
/**
|
|
48
|
+
* Common properties for all cells.
|
|
49
|
+
*/
|
|
50
|
+
export type CellProps = {
|
|
51
|
+
/**
|
|
52
|
+
* The title / main content of the cell. You can either provide a string or
|
|
53
|
+
* a Typography component. If a string is provided, typography defaults to
|
|
54
|
+
* LabelLarge.
|
|
55
|
+
*/
|
|
56
|
+
title: TypographyText,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* If provided, this adds a left accessory to the cell. Left
|
|
60
|
+
* Accessories can be defined using WB components such as Icon,
|
|
61
|
+
* IconButton, or it can even be used for a custom node/component if
|
|
62
|
+
* needed. What ever is passed in will occupy the "LeftAccessory” area
|
|
63
|
+
* of the Cell.
|
|
64
|
+
*/
|
|
65
|
+
leftAccessory?: Accessory,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Optional custom styles applied to the leftAccessory wrapper. For
|
|
69
|
+
* example, it can be used to set a custom minWidth or a custom
|
|
70
|
+
* alignment.
|
|
71
|
+
*
|
|
72
|
+
* NOTE: leftAccessoryStyle can only be used if leftAccessory is set.
|
|
73
|
+
*/
|
|
74
|
+
leftAccessoryStyle?: AccessoryStyle,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* If provided, this adds a right accessory to the cell. Right
|
|
78
|
+
* Accessories can be defined using WB components such as Icon,
|
|
79
|
+
* IconButton, or it can even be used for a custom node/component if
|
|
80
|
+
* needed. What ever is passed in will occupy the “RightAccessory”
|
|
81
|
+
* area of the Cell.
|
|
82
|
+
*/
|
|
83
|
+
rightAccessory?: Accessory,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Optional custom styles applied to the rightAccessory wrapper. For
|
|
87
|
+
* example, it can be used to set a custom minWidth or a custom
|
|
88
|
+
* alignment.
|
|
89
|
+
*
|
|
90
|
+
* NOTE: rightAccessoryStyle can only be used if rightAccessory is
|
|
91
|
+
* set.
|
|
92
|
+
*/
|
|
93
|
+
rightAccessoryStyle?: AccessoryStyle,
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Adds a horizontal rule at the bottom of the cell that can be used to
|
|
97
|
+
* separate cells within groups such as lists. Defaults to `inset`.
|
|
98
|
+
*/
|
|
99
|
+
horizontalRule?: HorizontalRuleVariant,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Optional custom styles applied to the cell container.
|
|
103
|
+
*/
|
|
104
|
+
style?: StyleType,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Optional test ID for e2e testing.
|
|
108
|
+
*/
|
|
109
|
+
testId?: string,
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Called when the cell is clicked.
|
|
113
|
+
*
|
|
114
|
+
* If not provided, the Cell can’t be hovered and/or pressed (highlighted on
|
|
115
|
+
* hover).
|
|
116
|
+
*/
|
|
117
|
+
onClick?: (e: React.SyntheticEvent<>) => mixed,
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether the cell is active (or currently selected).
|
|
121
|
+
*/
|
|
122
|
+
active?: boolean,
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Whether the cell is disabled.
|
|
126
|
+
*/
|
|
127
|
+
disabled?: boolean,
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Used to announce the cell's content to screen readers.
|
|
131
|
+
*/
|
|
132
|
+
"aria-label": string | void,
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Optinal href which Cell should direct to, uses client-side routing
|
|
136
|
+
* by default if react-router is present.
|
|
137
|
+
*/
|
|
138
|
+
href?: string,
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A target destination window for a link to open in. Should only be used
|
|
142
|
+
* when `href` is specified.
|
|
143
|
+
*
|
|
144
|
+
* TODO(WB-1262): only allow this prop when `href` is also set.t
|
|
145
|
+
*/
|
|
146
|
+
target?: "_blank",
|
|
147
|
+
...
|
|
148
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-cell",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.17",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -8,25 +8,25 @@
|
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"module": "dist/es/index.js",
|
|
11
|
-
"
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime": "^7.18.6",
|
|
17
|
-
"@khanacademy/wonder-blocks-clickable": "^2.4.
|
|
18
|
-
"@khanacademy/wonder-blocks-color": "^1.2.
|
|
19
|
-
"@khanacademy/wonder-blocks-core": "^4.
|
|
20
|
-
"@khanacademy/wonder-blocks-layout": "^1.4.
|
|
21
|
-
"@khanacademy/wonder-blocks-spacing": "^3.0.
|
|
22
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
17
|
+
"@khanacademy/wonder-blocks-clickable": "^2.4.7",
|
|
18
|
+
"@khanacademy/wonder-blocks-color": "^1.2.2",
|
|
19
|
+
"@khanacademy/wonder-blocks-core": "^4.9.0",
|
|
20
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.18",
|
|
21
|
+
"@khanacademy/wonder-blocks-spacing": "^3.0.6",
|
|
22
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.40"
|
|
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.7.
|
|
29
|
+
"wb-dev-build-settings": "^0.7.3"
|
|
30
30
|
},
|
|
31
31
|
"author": "",
|
|
32
32
|
"license": "MIT"
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
|
|
4
3
|
import {LabelMedium} from "@khanacademy/wonder-blocks-typography";
|
|
@@ -25,7 +24,7 @@ import type {CellProps} from "../util/types";
|
|
|
25
24
|
* />
|
|
26
25
|
* ```
|
|
27
26
|
*/
|
|
28
|
-
|
|
27
|
+
const CompactCell: React.FC<CellProps> = function (props): React.ReactElement {
|
|
29
28
|
const {title, ...coreProps} = props;
|
|
30
29
|
|
|
31
30
|
return (
|
|
@@ -37,6 +36,6 @@ function CompactCell(props: CellProps): React.Node {
|
|
|
37
36
|
)}
|
|
38
37
|
</CellCore>
|
|
39
38
|
);
|
|
40
|
-
}
|
|
39
|
+
};
|
|
41
40
|
|
|
42
41
|
export default CompactCell;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import {StyleSheet} from "aphrodite";
|
|
4
3
|
|
|
@@ -12,17 +11,21 @@ import {CellMeasurements} from "./internal/common";
|
|
|
12
11
|
|
|
13
12
|
import type {CellProps, TypographyText} from "../util/types";
|
|
14
13
|
|
|
15
|
-
type SubtitleProps = {
|
|
16
|
-
subtitle?: TypographyText
|
|
14
|
+
type SubtitleProps = {
|
|
15
|
+
subtitle?: TypographyText;
|
|
17
16
|
/**
|
|
18
17
|
* If true, the subtitle will use the alpha color defined in the parent
|
|
19
18
|
* component/element.
|
|
20
19
|
*/
|
|
21
|
-
disabled?: boolean
|
|
22
|
-
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
};
|
|
23
22
|
|
|
24
|
-
const Subtitle
|
|
23
|
+
const Subtitle: React.FC<SubtitleProps> = ({
|
|
24
|
+
subtitle,
|
|
25
|
+
disabled,
|
|
26
|
+
}): React.ReactElement => {
|
|
25
27
|
if (!subtitle) {
|
|
28
|
+
// @ts-expect-error [FEI-5019] - TS2322 - Type 'null' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
|
|
26
29
|
return null;
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -37,23 +40,20 @@ const Subtitle = ({subtitle, disabled}: SubtitleProps): React.Node => {
|
|
|
37
40
|
return subtitle;
|
|
38
41
|
};
|
|
39
42
|
|
|
40
|
-
type DetailCellProps = {
|
|
41
|
-
...CellProps,
|
|
42
|
-
|
|
43
|
+
type DetailCellProps = CellProps & {
|
|
43
44
|
/**
|
|
44
45
|
* You can either provide a string or a custom node Typography element (or
|
|
45
46
|
* nothing at all). Both a string or a custom node Typography element will
|
|
46
47
|
* occupy the “Subtitle1” area of the Cell.
|
|
47
48
|
*/
|
|
48
|
-
subtitle1?: TypographyText
|
|
49
|
-
|
|
49
|
+
subtitle1?: TypographyText;
|
|
50
50
|
/**
|
|
51
51
|
* You can either provide a string or a custom node Typography element (or
|
|
52
52
|
* nothing at all). Both a string or a custom node Typography element will
|
|
53
53
|
* occupy the “Subtitle2” area of the Cell.
|
|
54
54
|
*/
|
|
55
|
-
subtitle2?: TypographyText
|
|
56
|
-
|
|
55
|
+
subtitle2?: TypographyText;
|
|
56
|
+
};
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* This is a variant of CompactCell that allows adding subtitles, before and
|
|
@@ -76,7 +76,9 @@ type DetailCellProps = {|
|
|
|
76
76
|
* />
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
const DetailCell: React.FC<DetailCellProps> = function (
|
|
80
|
+
props,
|
|
81
|
+
): React.ReactElement {
|
|
80
82
|
const {title, subtitle1, subtitle2, ...coreProps} = props;
|
|
81
83
|
|
|
82
84
|
return (
|
|
@@ -93,7 +95,7 @@ function DetailCell(props: DetailCellProps): React.Node {
|
|
|
93
95
|
<Subtitle subtitle={subtitle2} disabled={coreProps.disabled} />
|
|
94
96
|
</CellCore>
|
|
95
97
|
);
|
|
96
|
-
}
|
|
98
|
+
};
|
|
97
99
|
|
|
98
100
|
const styles = StyleSheet.create({
|
|
99
101
|
subtitle: {
|