@khanacademy/wonder-blocks-cell 2.2.12 → 2.2.14
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 +19 -0
- package/dist/index.js +300 -0
- package/dist/index.js.flow +2 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-cell
|
|
2
2
|
|
|
3
|
+
## 2.2.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [496119f2]
|
|
8
|
+
- @khanacademy/wonder-blocks-clickable@2.4.4
|
|
9
|
+
- @khanacademy/wonder-blocks-core@4.6.2
|
|
10
|
+
- @khanacademy/wonder-blocks-layout@1.4.15
|
|
11
|
+
- @khanacademy/wonder-blocks-typography@1.1.37
|
|
12
|
+
|
|
13
|
+
## 2.2.13
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- @khanacademy/wonder-blocks-clickable@2.4.3
|
|
18
|
+
- @khanacademy/wonder-blocks-core@4.6.1
|
|
19
|
+
- @khanacademy/wonder-blocks-layout@1.4.14
|
|
20
|
+
- @khanacademy/wonder-blocks-typography@1.1.36
|
|
21
|
+
|
|
3
22
|
## 2.2.12
|
|
4
23
|
|
|
5
24
|
### 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;
|
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.14",
|
|
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.
|
|
17
|
+
"@khanacademy/wonder-blocks-clickable": "^2.4.4",
|
|
18
18
|
"@khanacademy/wonder-blocks-color": "^1.2.0",
|
|
19
|
-
"@khanacademy/wonder-blocks-core": "^4.6.
|
|
20
|
-
"@khanacademy/wonder-blocks-layout": "^1.4.
|
|
19
|
+
"@khanacademy/wonder-blocks-core": "^4.6.2",
|
|
20
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.15",
|
|
21
21
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
22
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
22
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.37"
|
|
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.
|
|
29
|
+
"wb-dev-build-settings": "^0.7.0"
|
|
30
30
|
},
|
|
31
31
|
"author": "",
|
|
32
32
|
"license": "MIT"
|