@khanacademy/wonder-blocks-cell 4.1.9 → 4.1.11

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
+ ## 4.1.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [b9e4946]
8
+ - Updated dependencies [b9e4946]
9
+ - @khanacademy/wonder-blocks-tokens@10.0.0
10
+ - @khanacademy/wonder-blocks-typography@3.2.0
11
+ - @khanacademy/wonder-blocks-clickable@7.0.4
12
+ - @khanacademy/wonder-blocks-layout@3.1.10
13
+ - @khanacademy/wonder-blocks-core@12.2.1
14
+
15
+ ## 4.1.10
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [2656fd4]
20
+ - Updated dependencies [6018552]
21
+ - Updated dependencies [7bbf311]
22
+ - Updated dependencies [7f79943]
23
+ - @khanacademy/wonder-blocks-tokens@9.0.0
24
+ - @khanacademy/wonder-blocks-clickable@7.0.3
25
+ - @khanacademy/wonder-blocks-layout@3.1.9
26
+
3
27
  ## 4.1.9
4
28
 
5
29
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -1,351 +1,18 @@
1
- import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
2
- import * as React from 'react';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import 'react';
3
3
  import { LabelMedium, LabelSmall } from '@khanacademy/wonder-blocks-typography';
4
- import _extends from '@babel/runtime/helpers/extends';
5
4
  import { StyleSheet } from 'aphrodite';
6
5
  import Clickable from '@khanacademy/wonder-blocks-clickable';
7
6
  import { View } from '@khanacademy/wonder-blocks-core';
8
7
  import { Strut } from '@khanacademy/wonder-blocks-layout';
9
8
  import { spacing, color, semanticColor, border } from '@khanacademy/wonder-blocks-tokens';
10
9
 
11
- const CellMeasurements = {
12
- cellMinHeight: spacing.xxLarge_48,
13
- cellPadding: {
14
- paddingVertical: spacing.small_12,
15
- paddingHorizontal: spacing.medium_16
16
- },
17
- detailCellPadding: {
18
- paddingVertical: spacing.medium_16,
19
- paddingHorizontal: spacing.medium_16
20
- },
21
- accessoryHorizontalSpacing: spacing.medium_16
22
- };
23
- const getHorizontalRuleStyles = horizontalRule => {
24
- switch (horizontalRule) {
25
- case "inset":
26
- return [styles$2.horizontalRule, styles$2.horizontalRuleInset];
27
- case "full-width":
28
- return styles$2.horizontalRule;
29
- case "none":
30
- return {};
31
- }
32
- };
33
- const styles$2 = StyleSheet.create({
34
- horizontalRule: {
35
- position: "relative",
36
- ":after": {
37
- width: "100%",
38
- content: "''",
39
- position: "absolute",
40
- bottom: 0,
41
- right: 0,
42
- height: spacing.xxxxSmall_2,
43
- boxShadow: `inset 0px -1px 0px ${color.offBlack8}`
44
- }
45
- },
46
- horizontalRuleInset: {
47
- ":after": {
48
- width: `calc(100% - ${CellMeasurements.cellPadding.paddingHorizontal}px)`
49
- }
50
- }
51
- });
10
+ const CellMeasurements={cellMinHeight:spacing.xxLarge_48,cellPadding:{paddingVertical:spacing.small_12,paddingHorizontal:spacing.medium_16},detailCellPadding:{paddingVertical:spacing.medium_16,paddingHorizontal:spacing.medium_16},accessoryHorizontalSpacing:spacing.medium_16};const getHorizontalRuleStyles=horizontalRule=>{switch(horizontalRule){case"inset":return [styles$2.horizontalRule,styles$2.horizontalRuleInset];case"full-width":return styles$2.horizontalRule;case"none":return {}}};const styles$2=StyleSheet.create({horizontalRule:{position:"relative",":after":{width:"100%",content:"''",position:"absolute",bottom:0,right:0,height:spacing.xxxxSmall_2,boxShadow:`inset 0px -1px 0px ${color.offBlack8}`}},horizontalRuleInset:{":after":{width:`calc(100% - ${CellMeasurements.cellPadding.paddingHorizontal}px)`}}});
52
11
 
53
- const LeftAccessory = ({
54
- leftAccessory,
55
- leftAccessoryStyle,
56
- disabled
57
- }) => {
58
- if (!leftAccessory) {
59
- return null;
60
- }
61
- return React.createElement(React.Fragment, null, React.createElement(View, {
62
- style: [styles$1.accessory, disabled && styles$1.accessoryDisabled, _extends({}, leftAccessoryStyle)]
63
- }, leftAccessory), React.createElement(Strut, {
64
- size: CellMeasurements.accessoryHorizontalSpacing
65
- }));
66
- };
67
- const RightAccessory = ({
68
- rightAccessory,
69
- rightAccessoryStyle,
70
- active,
71
- disabled
72
- }) => {
73
- if (!rightAccessory) {
74
- return null;
75
- }
76
- return React.createElement(React.Fragment, null, React.createElement(Strut, {
77
- size: CellMeasurements.accessoryHorizontalSpacing
78
- }), React.createElement(View, {
79
- style: [styles$1.accessory, styles$1.accessoryRight, disabled && styles$1.accessoryDisabled, _extends({}, rightAccessoryStyle), active && styles$1.accessoryActive]
80
- }, rightAccessory));
81
- };
82
- function CellInner(props) {
83
- const {
84
- active,
85
- children,
86
- disabled,
87
- horizontalRule = "inset",
88
- contentStyle = undefined,
89
- leftAccessory = undefined,
90
- leftAccessoryStyle = undefined,
91
- rightAccessory = undefined,
92
- rightAccessoryStyle = undefined,
93
- style,
94
- testId,
95
- innerStyle
96
- } = props;
97
- const horizontalRuleStyles = getHorizontalRuleStyles(horizontalRule);
98
- return React.createElement(View, {
99
- style: [styles$1.innerWrapper, innerStyle, style, horizontalRuleStyles, active && styles$1.activeInnerWrapper],
100
- className: "inner-wrapper"
101
- }, React.createElement(LeftAccessory, {
102
- leftAccessory: leftAccessory,
103
- leftAccessoryStyle: leftAccessoryStyle,
104
- disabled: disabled
105
- }), React.createElement(View, {
106
- style: [styles$1.content, contentStyle],
107
- testId: testId
108
- }, children), React.createElement(RightAccessory, {
109
- rightAccessory: rightAccessory,
110
- rightAccessoryStyle: rightAccessoryStyle,
111
- active: active,
112
- disabled: disabled
113
- }));
114
- }
115
- const CellCore = props => {
116
- const {
117
- active,
118
- disabled,
119
- href,
120
- onClick,
121
- "aria-label": ariaLabel,
122
- "aria-selected": ariaSelected,
123
- "aria-checked": ariaChecked,
124
- target,
125
- role,
126
- rootStyle
127
- } = props;
128
- if (onClick || href) {
129
- return (React.createElement(Clickable, {
130
- disabled: disabled,
131
- onClick: onClick,
132
- href: href,
133
- hideDefaultFocusRing: true,
134
- "aria-label": ariaLabel ? ariaLabel : undefined,
135
- "aria-selected": ariaSelected ? ariaSelected : undefined,
136
- "aria-checked": ariaChecked,
137
- role: role,
138
- target: target,
139
- style: [styles$1.wrapper, styles$1.clickable, rootStyle, active && styles$1.active, disabled && styles$1.disabled],
140
- "aria-current": active ? "true" : undefined
141
- }, () => React.createElement(CellInner, props))
142
- );
143
- }
144
- return React.createElement(View, {
145
- style: [styles$1.wrapper, rootStyle, active && styles$1.active],
146
- "aria-current": active ? "true" : undefined,
147
- role: role
148
- }, React.createElement(CellInner, props));
149
- };
150
- const cellTokens = {
151
- root: {
152
- default: {
153
- background: semanticColor.surface.primary,
154
- foreground: semanticColor.text.primary
155
- },
156
- hover: {
157
- background: color.fadedBlue8
158
- },
159
- press: {
160
- background: color.fadedBlue8,
161
- border: semanticColor.surface.emphasis
162
- },
163
- selected: {
164
- background: color.fadedBlue8,
165
- foreground: color.activeBlue,
166
- border: semanticColor.surface.emphasis
167
- },
168
- focus: {
169
- border: semanticColor.focus.outer
170
- },
171
- disabled: {
172
- foreground: semanticColor.text.disabled,
173
- border: semanticColor.focus.outer
174
- }
175
- },
176
- accessory: {
177
- default: {
178
- foreground: semanticColor.icon.primary
179
- },
180
- selected: {
181
- foreground: semanticColor.icon.action
182
- },
183
- disabled: {
184
- foreground: semanticColor.icon.secondary
185
- }
186
- }
187
- };
188
- const styles$1 = StyleSheet.create({
189
- wrapper: {
190
- background: cellTokens.root.default.background,
191
- color: cellTokens.root.default.foreground,
192
- display: "flex",
193
- minHeight: CellMeasurements.cellMinHeight,
194
- textAlign: "left",
195
- width: "100%"
196
- },
197
- innerWrapper: {
198
- minHeight: CellMeasurements.cellMinHeight,
199
- padding: `${CellMeasurements.cellPadding.paddingVertical}px ${CellMeasurements.cellPadding.paddingHorizontal}px`,
200
- flexDirection: "row",
201
- flex: 1,
202
- borderRadius: "inherit",
203
- overflow: "hidden",
204
- height: "100%",
205
- ":focus-visible": {
206
- padding: `${CellMeasurements.cellPadding.paddingVertical - 2}px ${CellMeasurements.cellPadding.paddingHorizontal - 2}px`
207
- }
208
- },
209
- activeInnerWrapper: {
210
- position: "relative",
211
- ":before": {
212
- content: "''",
213
- position: "absolute",
214
- top: 0,
215
- left: 0,
216
- bottom: 0,
217
- width: border.width.thick,
218
- backgroundColor: cellTokens.root.selected.border
219
- }
220
- },
221
- content: {
222
- alignSelf: "center",
223
- flex: 1,
224
- overflowWrap: "break-word"
225
- },
226
- accessory: {
227
- minWidth: "auto",
228
- alignItems: "center",
229
- alignSelf: "center"
230
- },
231
- accessoryRight: {
232
- color: cellTokens.accessory.default.foreground
233
- },
234
- clickable: {
235
- outline: "none",
236
- [":hover[aria-disabled=true]"]: {
237
- cursor: "not-allowed"
238
- },
239
- ":focus-visible": {
240
- borderRadius: border.radius.radius_040,
241
- overflow: "hidden",
242
- position: "relative"
243
- },
244
- [":focus-visible:after"]: {
245
- content: "''",
246
- position: "absolute",
247
- top: 0,
248
- left: 0,
249
- zIndex: 1,
250
- width: `calc(100% - ${spacing.xxxSmall_4}px)`,
251
- height: `calc(100% - ${spacing.xxxSmall_4}px)`,
252
- border: `${spacing.xxxxSmall_2}px solid ${cellTokens.root.focus.border}`,
253
- borderRadius: border.radius.radius_040
254
- },
255
- [":focus-visible[aria-disabled=true]:after"]: {
256
- borderColor: cellTokens.root.disabled.border
257
- },
258
- [":hover[aria-disabled=false]"]: {
259
- background: cellTokens.root.hover.background
260
- },
261
- [":active[aria-disabled=false]"]: {
262
- background: cellTokens.root.press.background
263
- },
264
- [":active[aria-disabled=false]:not([aria-current=true]) .inner-wrapper"]: {
265
- position: "relative",
266
- ":before": {
267
- content: "''",
268
- position: "absolute",
269
- top: 0,
270
- left: 0,
271
- bottom: 0,
272
- width: border.width.medium,
273
- backgroundColor: semanticColor.surface.emphasis
274
- }
275
- }
276
- },
277
- active: {
278
- background: cellTokens.root.selected.background,
279
- color: cellTokens.root.selected.foreground,
280
- cursor: "default"
281
- },
282
- disabled: {
283
- color: cellTokens.root.disabled.foreground,
284
- ":focus-visible": {
285
- outline: "none"
286
- }
287
- },
288
- accessoryActive: {
289
- color: cellTokens.accessory.selected.foreground
290
- },
291
- accessoryDisabled: {
292
- color: cellTokens.accessory.disabled.foreground,
293
- opacity: 0.32
294
- }
295
- });
12
+ const LeftAccessory=({leftAccessory,leftAccessoryStyle,disabled})=>{if(!leftAccessory){return null}return jsxs(Fragment,{children:[jsx(View,{style:[styles$1.accessory,disabled&&styles$1.accessoryDisabled,{...leftAccessoryStyle}],children:leftAccessory}),jsx(Strut,{size:CellMeasurements.accessoryHorizontalSpacing})]})};const RightAccessory=({rightAccessory,rightAccessoryStyle,active,disabled})=>{if(!rightAccessory){return null}return jsxs(Fragment,{children:[jsx(Strut,{size:CellMeasurements.accessoryHorizontalSpacing}),jsx(View,{style:[styles$1.accessory,styles$1.accessoryRight,disabled&&styles$1.accessoryDisabled,{...rightAccessoryStyle},active&&styles$1.accessoryActive],children:rightAccessory})]})};function CellInner(props){const{active,children,disabled,horizontalRule="inset",contentStyle=undefined,leftAccessory=undefined,leftAccessoryStyle=undefined,rightAccessory=undefined,rightAccessoryStyle=undefined,style,testId,innerStyle}=props;const horizontalRuleStyles=getHorizontalRuleStyles(horizontalRule);return jsxs(View,{style:[styles$1.innerWrapper,innerStyle,style,horizontalRuleStyles,active&&styles$1.activeInnerWrapper],className:"inner-wrapper",children:[jsx(LeftAccessory,{leftAccessory:leftAccessory,leftAccessoryStyle:leftAccessoryStyle,disabled:disabled}),jsx(View,{style:[styles$1.content,contentStyle],testId:testId,children:children}),jsx(RightAccessory,{rightAccessory:rightAccessory,rightAccessoryStyle:rightAccessoryStyle,active:active,disabled:disabled})]})}const CellCore=props=>{const{active,disabled,href,onClick,"aria-label":ariaLabel,"aria-selected":ariaSelected,"aria-checked":ariaChecked,target,role,rootStyle}=props;if(onClick||href){return jsx(Clickable,{disabled:disabled,onClick:onClick,href:href,hideDefaultFocusRing:true,"aria-label":ariaLabel?ariaLabel:undefined,"aria-selected":ariaSelected?ariaSelected:undefined,"aria-checked":ariaChecked,role:role,target:target,style:[styles$1.wrapper,styles$1.clickable,rootStyle,active&&styles$1.active,disabled&&styles$1.disabled],"aria-current":active?"true":undefined,children:()=>jsx(CellInner,{...props})})}return jsx(View,{style:[styles$1.wrapper,rootStyle,active&&styles$1.active],"aria-current":active?"true":undefined,role:role,children:jsx(CellInner,{...props})})};const cellTokens={root:{default:{background:semanticColor.surface.primary,foreground:semanticColor.text.primary},hover:{background:color.fadedBlue8},press:{background:color.fadedBlue8,border:semanticColor.surface.emphasis},selected:{background:color.fadedBlue8,foreground:color.activeBlue,border:semanticColor.surface.emphasis},focus:{border:semanticColor.focus.outer},disabled:{foreground:semanticColor.text.disabled,border:semanticColor.focus.outer}},accessory:{default:{foreground:semanticColor.icon.primary},selected:{foreground:semanticColor.icon.action},disabled:{foreground:semanticColor.icon.secondary}}};const styles$1=StyleSheet.create({wrapper:{background:cellTokens.root.default.background,color:cellTokens.root.default.foreground,display:"flex",minHeight:CellMeasurements.cellMinHeight,textAlign:"left",width:"100%"},innerWrapper:{minHeight:CellMeasurements.cellMinHeight,padding:`${CellMeasurements.cellPadding.paddingVertical}px ${CellMeasurements.cellPadding.paddingHorizontal}px`,flexDirection:"row",flex:1,borderRadius:"inherit",overflow:"hidden",height:"100%",":focus-visible":{padding:`${CellMeasurements.cellPadding.paddingVertical-2}px ${CellMeasurements.cellPadding.paddingHorizontal-2}px`}},activeInnerWrapper:{position:"relative",":before":{content:"''",position:"absolute",top:0,left:0,bottom:0,width:border.width.thick,backgroundColor:cellTokens.root.selected.border}},content:{alignSelf:"center",flex:1,overflowWrap:"break-word"},accessory:{minWidth:"auto",alignItems:"center",alignSelf:"center"},accessoryRight:{color:cellTokens.accessory.default.foreground},clickable:{outline:"none",[":hover[aria-disabled=true]"]:{cursor:"not-allowed"},":focus-visible":{borderRadius:border.radius.radius_040,overflow:"hidden",position:"relative"},[":focus-visible:after"]:{content:"''",position:"absolute",top:0,left:0,zIndex:1,width:`calc(100% - ${spacing.xxxSmall_4}px)`,height:`calc(100% - ${spacing.xxxSmall_4}px)`,border:`${spacing.xxxxSmall_2}px solid ${cellTokens.root.focus.border}`,borderRadius:border.radius.radius_040},[":focus-visible[aria-disabled=true]:after"]:{borderColor:cellTokens.root.disabled.border},[":hover[aria-disabled=false]"]:{background:cellTokens.root.hover.background},[":active[aria-disabled=false]"]:{background:cellTokens.root.press.background},[":active[aria-disabled=false]:not([aria-current=true]) .inner-wrapper"]:{position:"relative",":before":{content:"''",position:"absolute",top:0,left:0,bottom:0,width:border.width.medium,backgroundColor:semanticColor.surface.emphasis}}},active:{background:cellTokens.root.selected.background,color:cellTokens.root.selected.foreground,cursor:"default"},disabled:{color:cellTokens.root.disabled.foreground,":focus-visible":{outline:"none"}},accessoryActive:{color:cellTokens.accessory.selected.foreground},accessoryDisabled:{color:cellTokens.accessory.disabled.foreground,opacity:.32}});
296
13
 
297
- const _excluded$1 = ["title"];
298
- const CompactCell = function CompactCell(props) {
299
- const {
300
- title
301
- } = props,
302
- coreProps = _objectWithoutPropertiesLoose(props, _excluded$1);
303
- return React.createElement(CellCore, coreProps, typeof title === "string" ? React.createElement(LabelMedium, null, title) : title);
304
- };
14
+ const CompactCell=function(props){const{title,...coreProps}=props;return jsx(CellCore,{...coreProps,children:typeof title==="string"?jsx(LabelMedium,{children:title}):title})};
305
15
 
306
- const _excluded = ["title", "subtitle1", "subtitle2"];
307
- const Subtitle = ({
308
- subtitle,
309
- disabled
310
- }) => {
311
- if (!subtitle) {
312
- return null;
313
- }
314
- if (typeof subtitle === "string") {
315
- return React.createElement(LabelSmall, {
316
- style: !disabled && styles.subtitle
317
- }, subtitle);
318
- }
319
- return subtitle;
320
- };
321
- const DetailCell = function DetailCell(props) {
322
- const {
323
- title,
324
- subtitle1,
325
- subtitle2
326
- } = props,
327
- coreProps = _objectWithoutPropertiesLoose(props, _excluded);
328
- return React.createElement(CellCore, _extends({}, coreProps, {
329
- innerStyle: styles.innerWrapper
330
- }), React.createElement(Subtitle, {
331
- subtitle: subtitle1,
332
- disabled: coreProps.disabled
333
- }), subtitle1 && React.createElement(Strut, {
334
- size: spacing.xxxxSmall_2
335
- }), typeof title === "string" ? React.createElement(LabelMedium, null, title) : title, subtitle2 && React.createElement(Strut, {
336
- size: spacing.xxxxSmall_2
337
- }), React.createElement(Subtitle, {
338
- subtitle: subtitle2,
339
- disabled: coreProps.disabled
340
- }));
341
- };
342
- const styles = StyleSheet.create({
343
- subtitle: {
344
- color: semanticColor.text.secondary
345
- },
346
- innerWrapper: {
347
- padding: `${CellMeasurements.detailCellPadding.paddingVertical}px ${CellMeasurements.detailCellPadding.paddingHorizontal}px`
348
- }
349
- });
16
+ const Subtitle=({subtitle,disabled})=>{if(!subtitle){return null}if(typeof subtitle==="string"){return jsx(LabelSmall,{style:!disabled&&styles.subtitle,children:subtitle})}return subtitle};const DetailCell=function(props){const{title,subtitle1,subtitle2,...coreProps}=props;return jsxs(CellCore,{...coreProps,innerStyle:styles.innerWrapper,children:[jsx(Subtitle,{subtitle:subtitle1,disabled:coreProps.disabled}),subtitle1&&jsx(Strut,{size:spacing.xxxxSmall_2}),typeof title==="string"?jsx(LabelMedium,{children:title}):title,subtitle2&&jsx(Strut,{size:spacing.xxxxSmall_2}),jsx(Subtitle,{subtitle:subtitle2,disabled:coreProps.disabled})]})};const styles=StyleSheet.create({subtitle:{color:semanticColor.text.secondary},innerWrapper:{padding:`${CellMeasurements.detailCellPadding.paddingVertical}px ${CellMeasurements.detailCellPadding.paddingHorizontal}px`}});
350
17
 
351
18
  export { CompactCell, DetailCell };
package/dist/index.js CHANGED
@@ -2,10 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
6
- var React = require('react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ require('react');
7
7
  var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
8
- var _extends = require('@babel/runtime/helpers/extends');
9
8
  var aphrodite = require('aphrodite');
10
9
  var Clickable = require('@khanacademy/wonder-blocks-clickable');
11
10
  var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
@@ -14,368 +13,15 @@ var wonderBlocksTokens = require('@khanacademy/wonder-blocks-tokens');
14
13
 
15
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
15
 
17
- function _interopNamespace(e) {
18
- if (e && e.__esModule) return e;
19
- var n = Object.create(null);
20
- if (e) {
21
- Object.keys(e).forEach(function (k) {
22
- if (k !== 'default') {
23
- var d = Object.getOwnPropertyDescriptor(e, k);
24
- Object.defineProperty(n, k, d.get ? d : {
25
- enumerable: true,
26
- get: function () { return e[k]; }
27
- });
28
- }
29
- });
30
- }
31
- n["default"] = e;
32
- return Object.freeze(n);
33
- }
34
-
35
- var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
36
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
37
- var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
38
16
  var Clickable__default = /*#__PURE__*/_interopDefaultLegacy(Clickable);
39
17
 
40
- const CellMeasurements = {
41
- cellMinHeight: wonderBlocksTokens.spacing.xxLarge_48,
42
- cellPadding: {
43
- paddingVertical: wonderBlocksTokens.spacing.small_12,
44
- paddingHorizontal: wonderBlocksTokens.spacing.medium_16
45
- },
46
- detailCellPadding: {
47
- paddingVertical: wonderBlocksTokens.spacing.medium_16,
48
- paddingHorizontal: wonderBlocksTokens.spacing.medium_16
49
- },
50
- accessoryHorizontalSpacing: wonderBlocksTokens.spacing.medium_16
51
- };
52
- const getHorizontalRuleStyles = horizontalRule => {
53
- switch (horizontalRule) {
54
- case "inset":
55
- return [styles$2.horizontalRule, styles$2.horizontalRuleInset];
56
- case "full-width":
57
- return styles$2.horizontalRule;
58
- case "none":
59
- return {};
60
- }
61
- };
62
- const styles$2 = aphrodite.StyleSheet.create({
63
- horizontalRule: {
64
- position: "relative",
65
- ":after": {
66
- width: "100%",
67
- content: "''",
68
- position: "absolute",
69
- bottom: 0,
70
- right: 0,
71
- height: wonderBlocksTokens.spacing.xxxxSmall_2,
72
- boxShadow: `inset 0px -1px 0px ${wonderBlocksTokens.color.offBlack8}`
73
- }
74
- },
75
- horizontalRuleInset: {
76
- ":after": {
77
- width: `calc(100% - ${CellMeasurements.cellPadding.paddingHorizontal}px)`
78
- }
79
- }
80
- });
18
+ const CellMeasurements={cellMinHeight:wonderBlocksTokens.spacing.xxLarge_48,cellPadding:{paddingVertical:wonderBlocksTokens.spacing.small_12,paddingHorizontal:wonderBlocksTokens.spacing.medium_16},detailCellPadding:{paddingVertical:wonderBlocksTokens.spacing.medium_16,paddingHorizontal:wonderBlocksTokens.spacing.medium_16},accessoryHorizontalSpacing:wonderBlocksTokens.spacing.medium_16};const getHorizontalRuleStyles=horizontalRule=>{switch(horizontalRule){case"inset":return [styles$2.horizontalRule,styles$2.horizontalRuleInset];case"full-width":return styles$2.horizontalRule;case"none":return {}}};const styles$2=aphrodite.StyleSheet.create({horizontalRule:{position:"relative",":after":{width:"100%",content:"''",position:"absolute",bottom:0,right:0,height:wonderBlocksTokens.spacing.xxxxSmall_2,boxShadow:`inset 0px -1px 0px ${wonderBlocksTokens.color.offBlack8}`}},horizontalRuleInset:{":after":{width:`calc(100% - ${CellMeasurements.cellPadding.paddingHorizontal}px)`}}});
81
19
 
82
- const LeftAccessory = ({
83
- leftAccessory,
84
- leftAccessoryStyle,
85
- disabled
86
- }) => {
87
- if (!leftAccessory) {
88
- return null;
89
- }
90
- return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksCore.View, {
91
- style: [styles$1.accessory, disabled && styles$1.accessoryDisabled, _extends__default["default"]({}, leftAccessoryStyle)]
92
- }, leftAccessory), React__namespace.createElement(wonderBlocksLayout.Strut, {
93
- size: CellMeasurements.accessoryHorizontalSpacing
94
- }));
95
- };
96
- const RightAccessory = ({
97
- rightAccessory,
98
- rightAccessoryStyle,
99
- active,
100
- disabled
101
- }) => {
102
- if (!rightAccessory) {
103
- return null;
104
- }
105
- return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksLayout.Strut, {
106
- size: CellMeasurements.accessoryHorizontalSpacing
107
- }), React__namespace.createElement(wonderBlocksCore.View, {
108
- style: [styles$1.accessory, styles$1.accessoryRight, disabled && styles$1.accessoryDisabled, _extends__default["default"]({}, rightAccessoryStyle), active && styles$1.accessoryActive]
109
- }, rightAccessory));
110
- };
111
- function CellInner(props) {
112
- const {
113
- active,
114
- children,
115
- disabled,
116
- horizontalRule = "inset",
117
- contentStyle = undefined,
118
- leftAccessory = undefined,
119
- leftAccessoryStyle = undefined,
120
- rightAccessory = undefined,
121
- rightAccessoryStyle = undefined,
122
- style,
123
- testId,
124
- innerStyle
125
- } = props;
126
- const horizontalRuleStyles = getHorizontalRuleStyles(horizontalRule);
127
- return React__namespace.createElement(wonderBlocksCore.View, {
128
- style: [styles$1.innerWrapper, innerStyle, style, horizontalRuleStyles, active && styles$1.activeInnerWrapper],
129
- className: "inner-wrapper"
130
- }, React__namespace.createElement(LeftAccessory, {
131
- leftAccessory: leftAccessory,
132
- leftAccessoryStyle: leftAccessoryStyle,
133
- disabled: disabled
134
- }), React__namespace.createElement(wonderBlocksCore.View, {
135
- style: [styles$1.content, contentStyle],
136
- testId: testId
137
- }, children), React__namespace.createElement(RightAccessory, {
138
- rightAccessory: rightAccessory,
139
- rightAccessoryStyle: rightAccessoryStyle,
140
- active: active,
141
- disabled: disabled
142
- }));
143
- }
144
- const CellCore = props => {
145
- const {
146
- active,
147
- disabled,
148
- href,
149
- onClick,
150
- "aria-label": ariaLabel,
151
- "aria-selected": ariaSelected,
152
- "aria-checked": ariaChecked,
153
- target,
154
- role,
155
- rootStyle
156
- } = props;
157
- if (onClick || href) {
158
- return (React__namespace.createElement(Clickable__default["default"], {
159
- disabled: disabled,
160
- onClick: onClick,
161
- href: href,
162
- hideDefaultFocusRing: true,
163
- "aria-label": ariaLabel ? ariaLabel : undefined,
164
- "aria-selected": ariaSelected ? ariaSelected : undefined,
165
- "aria-checked": ariaChecked,
166
- role: role,
167
- target: target,
168
- style: [styles$1.wrapper, styles$1.clickable, rootStyle, active && styles$1.active, disabled && styles$1.disabled],
169
- "aria-current": active ? "true" : undefined
170
- }, () => React__namespace.createElement(CellInner, props))
171
- );
172
- }
173
- return React__namespace.createElement(wonderBlocksCore.View, {
174
- style: [styles$1.wrapper, rootStyle, active && styles$1.active],
175
- "aria-current": active ? "true" : undefined,
176
- role: role
177
- }, React__namespace.createElement(CellInner, props));
178
- };
179
- const cellTokens = {
180
- root: {
181
- default: {
182
- background: wonderBlocksTokens.semanticColor.surface.primary,
183
- foreground: wonderBlocksTokens.semanticColor.text.primary
184
- },
185
- hover: {
186
- background: wonderBlocksTokens.color.fadedBlue8
187
- },
188
- press: {
189
- background: wonderBlocksTokens.color.fadedBlue8,
190
- border: wonderBlocksTokens.semanticColor.surface.emphasis
191
- },
192
- selected: {
193
- background: wonderBlocksTokens.color.fadedBlue8,
194
- foreground: wonderBlocksTokens.color.activeBlue,
195
- border: wonderBlocksTokens.semanticColor.surface.emphasis
196
- },
197
- focus: {
198
- border: wonderBlocksTokens.semanticColor.focus.outer
199
- },
200
- disabled: {
201
- foreground: wonderBlocksTokens.semanticColor.text.disabled,
202
- border: wonderBlocksTokens.semanticColor.focus.outer
203
- }
204
- },
205
- accessory: {
206
- default: {
207
- foreground: wonderBlocksTokens.semanticColor.icon.primary
208
- },
209
- selected: {
210
- foreground: wonderBlocksTokens.semanticColor.icon.action
211
- },
212
- disabled: {
213
- foreground: wonderBlocksTokens.semanticColor.icon.secondary
214
- }
215
- }
216
- };
217
- const styles$1 = aphrodite.StyleSheet.create({
218
- wrapper: {
219
- background: cellTokens.root.default.background,
220
- color: cellTokens.root.default.foreground,
221
- display: "flex",
222
- minHeight: CellMeasurements.cellMinHeight,
223
- textAlign: "left",
224
- width: "100%"
225
- },
226
- innerWrapper: {
227
- minHeight: CellMeasurements.cellMinHeight,
228
- padding: `${CellMeasurements.cellPadding.paddingVertical}px ${CellMeasurements.cellPadding.paddingHorizontal}px`,
229
- flexDirection: "row",
230
- flex: 1,
231
- borderRadius: "inherit",
232
- overflow: "hidden",
233
- height: "100%",
234
- ":focus-visible": {
235
- padding: `${CellMeasurements.cellPadding.paddingVertical - 2}px ${CellMeasurements.cellPadding.paddingHorizontal - 2}px`
236
- }
237
- },
238
- activeInnerWrapper: {
239
- position: "relative",
240
- ":before": {
241
- content: "''",
242
- position: "absolute",
243
- top: 0,
244
- left: 0,
245
- bottom: 0,
246
- width: wonderBlocksTokens.border.width.thick,
247
- backgroundColor: cellTokens.root.selected.border
248
- }
249
- },
250
- content: {
251
- alignSelf: "center",
252
- flex: 1,
253
- overflowWrap: "break-word"
254
- },
255
- accessory: {
256
- minWidth: "auto",
257
- alignItems: "center",
258
- alignSelf: "center"
259
- },
260
- accessoryRight: {
261
- color: cellTokens.accessory.default.foreground
262
- },
263
- clickable: {
264
- outline: "none",
265
- [":hover[aria-disabled=true]"]: {
266
- cursor: "not-allowed"
267
- },
268
- ":focus-visible": {
269
- borderRadius: wonderBlocksTokens.border.radius.radius_040,
270
- overflow: "hidden",
271
- position: "relative"
272
- },
273
- [":focus-visible:after"]: {
274
- content: "''",
275
- position: "absolute",
276
- top: 0,
277
- left: 0,
278
- zIndex: 1,
279
- width: `calc(100% - ${wonderBlocksTokens.spacing.xxxSmall_4}px)`,
280
- height: `calc(100% - ${wonderBlocksTokens.spacing.xxxSmall_4}px)`,
281
- border: `${wonderBlocksTokens.spacing.xxxxSmall_2}px solid ${cellTokens.root.focus.border}`,
282
- borderRadius: wonderBlocksTokens.border.radius.radius_040
283
- },
284
- [":focus-visible[aria-disabled=true]:after"]: {
285
- borderColor: cellTokens.root.disabled.border
286
- },
287
- [":hover[aria-disabled=false]"]: {
288
- background: cellTokens.root.hover.background
289
- },
290
- [":active[aria-disabled=false]"]: {
291
- background: cellTokens.root.press.background
292
- },
293
- [":active[aria-disabled=false]:not([aria-current=true]) .inner-wrapper"]: {
294
- position: "relative",
295
- ":before": {
296
- content: "''",
297
- position: "absolute",
298
- top: 0,
299
- left: 0,
300
- bottom: 0,
301
- width: wonderBlocksTokens.border.width.medium,
302
- backgroundColor: wonderBlocksTokens.semanticColor.surface.emphasis
303
- }
304
- }
305
- },
306
- active: {
307
- background: cellTokens.root.selected.background,
308
- color: cellTokens.root.selected.foreground,
309
- cursor: "default"
310
- },
311
- disabled: {
312
- color: cellTokens.root.disabled.foreground,
313
- ":focus-visible": {
314
- outline: "none"
315
- }
316
- },
317
- accessoryActive: {
318
- color: cellTokens.accessory.selected.foreground
319
- },
320
- accessoryDisabled: {
321
- color: cellTokens.accessory.disabled.foreground,
322
- opacity: 0.32
323
- }
324
- });
20
+ const LeftAccessory=({leftAccessory,leftAccessoryStyle,disabled})=>{if(!leftAccessory){return null}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wonderBlocksCore.View,{style:[styles$1.accessory,disabled&&styles$1.accessoryDisabled,{...leftAccessoryStyle}],children:leftAccessory}),jsxRuntime.jsx(wonderBlocksLayout.Strut,{size:CellMeasurements.accessoryHorizontalSpacing})]})};const RightAccessory=({rightAccessory,rightAccessoryStyle,active,disabled})=>{if(!rightAccessory){return null}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wonderBlocksLayout.Strut,{size:CellMeasurements.accessoryHorizontalSpacing}),jsxRuntime.jsx(wonderBlocksCore.View,{style:[styles$1.accessory,styles$1.accessoryRight,disabled&&styles$1.accessoryDisabled,{...rightAccessoryStyle},active&&styles$1.accessoryActive],children:rightAccessory})]})};function CellInner(props){const{active,children,disabled,horizontalRule="inset",contentStyle=undefined,leftAccessory=undefined,leftAccessoryStyle=undefined,rightAccessory=undefined,rightAccessoryStyle=undefined,style,testId,innerStyle}=props;const horizontalRuleStyles=getHorizontalRuleStyles(horizontalRule);return jsxRuntime.jsxs(wonderBlocksCore.View,{style:[styles$1.innerWrapper,innerStyle,style,horizontalRuleStyles,active&&styles$1.activeInnerWrapper],className:"inner-wrapper",children:[jsxRuntime.jsx(LeftAccessory,{leftAccessory:leftAccessory,leftAccessoryStyle:leftAccessoryStyle,disabled:disabled}),jsxRuntime.jsx(wonderBlocksCore.View,{style:[styles$1.content,contentStyle],testId:testId,children:children}),jsxRuntime.jsx(RightAccessory,{rightAccessory:rightAccessory,rightAccessoryStyle:rightAccessoryStyle,active:active,disabled:disabled})]})}const CellCore=props=>{const{active,disabled,href,onClick,"aria-label":ariaLabel,"aria-selected":ariaSelected,"aria-checked":ariaChecked,target,role,rootStyle}=props;if(onClick||href){return jsxRuntime.jsx(Clickable__default["default"],{disabled:disabled,onClick:onClick,href:href,hideDefaultFocusRing:true,"aria-label":ariaLabel?ariaLabel:undefined,"aria-selected":ariaSelected?ariaSelected:undefined,"aria-checked":ariaChecked,role:role,target:target,style:[styles$1.wrapper,styles$1.clickable,rootStyle,active&&styles$1.active,disabled&&styles$1.disabled],"aria-current":active?"true":undefined,children:()=>jsxRuntime.jsx(CellInner,{...props})})}return jsxRuntime.jsx(wonderBlocksCore.View,{style:[styles$1.wrapper,rootStyle,active&&styles$1.active],"aria-current":active?"true":undefined,role:role,children:jsxRuntime.jsx(CellInner,{...props})})};const cellTokens={root:{default:{background:wonderBlocksTokens.semanticColor.surface.primary,foreground:wonderBlocksTokens.semanticColor.text.primary},hover:{background:wonderBlocksTokens.color.fadedBlue8},press:{background:wonderBlocksTokens.color.fadedBlue8,border:wonderBlocksTokens.semanticColor.surface.emphasis},selected:{background:wonderBlocksTokens.color.fadedBlue8,foreground:wonderBlocksTokens.color.activeBlue,border:wonderBlocksTokens.semanticColor.surface.emphasis},focus:{border:wonderBlocksTokens.semanticColor.focus.outer},disabled:{foreground:wonderBlocksTokens.semanticColor.text.disabled,border:wonderBlocksTokens.semanticColor.focus.outer}},accessory:{default:{foreground:wonderBlocksTokens.semanticColor.icon.primary},selected:{foreground:wonderBlocksTokens.semanticColor.icon.action},disabled:{foreground:wonderBlocksTokens.semanticColor.icon.secondary}}};const styles$1=aphrodite.StyleSheet.create({wrapper:{background:cellTokens.root.default.background,color:cellTokens.root.default.foreground,display:"flex",minHeight:CellMeasurements.cellMinHeight,textAlign:"left",width:"100%"},innerWrapper:{minHeight:CellMeasurements.cellMinHeight,padding:`${CellMeasurements.cellPadding.paddingVertical}px ${CellMeasurements.cellPadding.paddingHorizontal}px`,flexDirection:"row",flex:1,borderRadius:"inherit",overflow:"hidden",height:"100%",":focus-visible":{padding:`${CellMeasurements.cellPadding.paddingVertical-2}px ${CellMeasurements.cellPadding.paddingHorizontal-2}px`}},activeInnerWrapper:{position:"relative",":before":{content:"''",position:"absolute",top:0,left:0,bottom:0,width:wonderBlocksTokens.border.width.thick,backgroundColor:cellTokens.root.selected.border}},content:{alignSelf:"center",flex:1,overflowWrap:"break-word"},accessory:{minWidth:"auto",alignItems:"center",alignSelf:"center"},accessoryRight:{color:cellTokens.accessory.default.foreground},clickable:{outline:"none",[":hover[aria-disabled=true]"]:{cursor:"not-allowed"},":focus-visible":{borderRadius:wonderBlocksTokens.border.radius.radius_040,overflow:"hidden",position:"relative"},[":focus-visible:after"]:{content:"''",position:"absolute",top:0,left:0,zIndex:1,width:`calc(100% - ${wonderBlocksTokens.spacing.xxxSmall_4}px)`,height:`calc(100% - ${wonderBlocksTokens.spacing.xxxSmall_4}px)`,border:`${wonderBlocksTokens.spacing.xxxxSmall_2}px solid ${cellTokens.root.focus.border}`,borderRadius:wonderBlocksTokens.border.radius.radius_040},[":focus-visible[aria-disabled=true]:after"]:{borderColor:cellTokens.root.disabled.border},[":hover[aria-disabled=false]"]:{background:cellTokens.root.hover.background},[":active[aria-disabled=false]"]:{background:cellTokens.root.press.background},[":active[aria-disabled=false]:not([aria-current=true]) .inner-wrapper"]:{position:"relative",":before":{content:"''",position:"absolute",top:0,left:0,bottom:0,width:wonderBlocksTokens.border.width.medium,backgroundColor:wonderBlocksTokens.semanticColor.surface.emphasis}}},active:{background:cellTokens.root.selected.background,color:cellTokens.root.selected.foreground,cursor:"default"},disabled:{color:cellTokens.root.disabled.foreground,":focus-visible":{outline:"none"}},accessoryActive:{color:cellTokens.accessory.selected.foreground},accessoryDisabled:{color:cellTokens.accessory.disabled.foreground,opacity:.32}});
325
21
 
326
- const _excluded$1 = ["title"];
327
- const CompactCell = function CompactCell(props) {
328
- const {
329
- title
330
- } = props,
331
- coreProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$1);
332
- return React__namespace.createElement(CellCore, coreProps, typeof title === "string" ? React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, title) : title);
333
- };
22
+ const CompactCell=function(props){const{title,...coreProps}=props;return jsxRuntime.jsx(CellCore,{...coreProps,children:typeof title==="string"?jsxRuntime.jsx(wonderBlocksTypography.LabelMedium,{children:title}):title})};
334
23
 
335
- const _excluded = ["title", "subtitle1", "subtitle2"];
336
- const Subtitle = ({
337
- subtitle,
338
- disabled
339
- }) => {
340
- if (!subtitle) {
341
- return null;
342
- }
343
- if (typeof subtitle === "string") {
344
- return React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
345
- style: !disabled && styles.subtitle
346
- }, subtitle);
347
- }
348
- return subtitle;
349
- };
350
- const DetailCell = function DetailCell(props) {
351
- const {
352
- title,
353
- subtitle1,
354
- subtitle2
355
- } = props,
356
- coreProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded);
357
- return React__namespace.createElement(CellCore, _extends__default["default"]({}, coreProps, {
358
- innerStyle: styles.innerWrapper
359
- }), React__namespace.createElement(Subtitle, {
360
- subtitle: subtitle1,
361
- disabled: coreProps.disabled
362
- }), subtitle1 && React__namespace.createElement(wonderBlocksLayout.Strut, {
363
- size: wonderBlocksTokens.spacing.xxxxSmall_2
364
- }), typeof title === "string" ? React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, title) : title, subtitle2 && React__namespace.createElement(wonderBlocksLayout.Strut, {
365
- size: wonderBlocksTokens.spacing.xxxxSmall_2
366
- }), React__namespace.createElement(Subtitle, {
367
- subtitle: subtitle2,
368
- disabled: coreProps.disabled
369
- }));
370
- };
371
- const styles = aphrodite.StyleSheet.create({
372
- subtitle: {
373
- color: wonderBlocksTokens.semanticColor.text.secondary
374
- },
375
- innerWrapper: {
376
- padding: `${CellMeasurements.detailCellPadding.paddingVertical}px ${CellMeasurements.detailCellPadding.paddingHorizontal}px`
377
- }
378
- });
24
+ const Subtitle=({subtitle,disabled})=>{if(!subtitle){return null}if(typeof subtitle==="string"){return jsxRuntime.jsx(wonderBlocksTypography.LabelSmall,{style:!disabled&&styles.subtitle,children:subtitle})}return subtitle};const DetailCell=function(props){const{title,subtitle1,subtitle2,...coreProps}=props;return jsxRuntime.jsxs(CellCore,{...coreProps,innerStyle:styles.innerWrapper,children:[jsxRuntime.jsx(Subtitle,{subtitle:subtitle1,disabled:coreProps.disabled}),subtitle1&&jsxRuntime.jsx(wonderBlocksLayout.Strut,{size:wonderBlocksTokens.spacing.xxxxSmall_2}),typeof title==="string"?jsxRuntime.jsx(wonderBlocksTypography.LabelMedium,{children:title}):title,subtitle2&&jsxRuntime.jsx(wonderBlocksLayout.Strut,{size:wonderBlocksTokens.spacing.xxxxSmall_2}),jsxRuntime.jsx(Subtitle,{subtitle:subtitle2,disabled:coreProps.disabled})]})};const styles=aphrodite.StyleSheet.create({subtitle:{color:wonderBlocksTokens.semanticColor.text.secondary},innerWrapper:{padding:`${CellMeasurements.detailCellPadding.paddingVertical}px ${CellMeasurements.detailCellPadding.paddingHorizontal}px`}});
379
25
 
380
26
  exports.CompactCell = CompactCell;
381
27
  exports.DetailCell = DetailCell;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-cell",
3
- "version": "4.1.9",
3
+ "version": "4.1.11",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -10,19 +10,18 @@
10
10
  "module": "dist/es/index.js",
11
11
  "types": "dist/index.d.ts",
12
12
  "dependencies": {
13
- "@babel/runtime": "^7.24.5",
14
- "@khanacademy/wonder-blocks-clickable": "7.0.2",
13
+ "@khanacademy/wonder-blocks-clickable": "7.0.4",
15
14
  "@khanacademy/wonder-blocks-core": "12.2.1",
16
- "@khanacademy/wonder-blocks-layout": "3.1.8",
17
- "@khanacademy/wonder-blocks-tokens": "8.0.0",
18
- "@khanacademy/wonder-blocks-typography": "3.1.3"
15
+ "@khanacademy/wonder-blocks-layout": "3.1.10",
16
+ "@khanacademy/wonder-blocks-tokens": "10.0.0",
17
+ "@khanacademy/wonder-blocks-typography": "3.2.0"
19
18
  },
20
19
  "peerDependencies": {
21
20
  "aphrodite": "^1.2.5",
22
21
  "react": "18.2.0"
23
22
  },
24
23
  "devDependencies": {
25
- "@khanacademy/wb-dev-build-settings": "2.1.1"
24
+ "@khanacademy/wb-dev-build-settings": "3.0.0"
26
25
  },
27
26
  "author": "",
28
27
  "license": "MIT",