@khanacademy/wonder-blocks-dropdown 2.5.2 → 2.6.3
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 +48 -0
- package/dist/es/index.js +185 -183
- package/dist/index.js +5 -3
- package/package.json +12 -13
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +25 -22
- package/src/components/__tests__/action-item.test.js +30 -8
- package/src/components/__tests__/action-menu.test.js +1 -0
- package/src/components/__tests__/dropdown-core-virtualized.test.js +1 -0
- package/src/components/__tests__/dropdown-core.test.js +1 -0
- package/src/components/__tests__/multi-select.test.js +1 -0
- package/src/components/__tests__/search-text-input.test.js +1 -0
- package/src/components/action-item.js +8 -0
- package/src/components/action-menu.stories.js +48 -0
- package/src/components/multi-select.stories.js +3 -3
- package/src/components/option-item.js +1 -1
- package/src/components/select-opener.js +2 -2
- package/LICENSE +0 -21
- package/src/components/__tests__/__snapshots__/action-item.test.js.snap +0 -63
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { StyleSheet, css } from 'aphrodite';
|
|
4
4
|
import { Link } from 'react-router-dom';
|
|
5
5
|
import { __RouterContext } from 'react-router';
|
|
@@ -57,13 +57,13 @@ const defaultLabels = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
const {
|
|
60
|
-
blue,
|
|
61
|
-
white,
|
|
62
|
-
offBlack,
|
|
63
|
-
offBlack32
|
|
60
|
+
blue: blue$3,
|
|
61
|
+
white: white$4,
|
|
62
|
+
offBlack: offBlack$3,
|
|
63
|
+
offBlack32: offBlack32$4
|
|
64
64
|
} = Color;
|
|
65
65
|
const StyledAnchor = addStyle("a");
|
|
66
|
-
const StyledButton = addStyle("button");
|
|
66
|
+
const StyledButton$2 = addStyle("button");
|
|
67
67
|
const StyledLink = addStyle(Link);
|
|
68
68
|
/**
|
|
69
69
|
* The action item trigger actions, such as navigating to a different page or
|
|
@@ -71,7 +71,7 @@ const StyledLink = addStyle(Link);
|
|
|
71
71
|
* ActionMenu.
|
|
72
72
|
*/
|
|
73
73
|
|
|
74
|
-
class ActionItem extends Component {
|
|
74
|
+
class ActionItem extends React.Component {
|
|
75
75
|
static isClassOf(instance) {
|
|
76
76
|
return instance && instance.type && instance.type.__IS_ACTION_ITEM__;
|
|
77
77
|
}
|
|
@@ -84,13 +84,14 @@ class ActionItem extends Component {
|
|
|
84
84
|
target,
|
|
85
85
|
indent,
|
|
86
86
|
label,
|
|
87
|
+
lang,
|
|
87
88
|
onClick,
|
|
88
89
|
role,
|
|
89
90
|
style,
|
|
90
91
|
testId
|
|
91
92
|
} = this.props;
|
|
92
93
|
const ClickableBehavior = getClickableBehavior(href, skipClientNav, router);
|
|
93
|
-
return /*#__PURE__*/createElement(ClickableBehavior, {
|
|
94
|
+
return /*#__PURE__*/React.createElement(ClickableBehavior, {
|
|
94
95
|
disabled: disabled,
|
|
95
96
|
onClick: onClick,
|
|
96
97
|
href: href,
|
|
@@ -102,7 +103,7 @@ class ActionItem extends Component {
|
|
|
102
103
|
hovered,
|
|
103
104
|
focused
|
|
104
105
|
} = state;
|
|
105
|
-
const defaultStyle = [styles.shared, disabled && styles.disabled, !disabled && (pressed ? styles.active : (hovered || focused) && styles.focus), // pass optional styles from react-window (if applies)
|
|
106
|
+
const defaultStyle = [styles$9.shared, disabled && styles$9.disabled, !disabled && (pressed ? styles$9.active : (hovered || focused) && styles$9.focus), // pass optional styles from react-window (if applies)
|
|
106
107
|
style];
|
|
107
108
|
|
|
108
109
|
const props = _extends({
|
|
@@ -112,19 +113,20 @@ class ActionItem extends Component {
|
|
|
112
113
|
style: [defaultStyle]
|
|
113
114
|
}, childrenProps);
|
|
114
115
|
|
|
115
|
-
const children = /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(LabelMedium, {
|
|
116
|
-
|
|
116
|
+
const children = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelMedium, {
|
|
117
|
+
lang: lang,
|
|
118
|
+
style: [indent && styles$9.indent, styles$9.label]
|
|
117
119
|
}, label));
|
|
118
120
|
|
|
119
121
|
if (href && !disabled) {
|
|
120
|
-
return router && !skipClientNav && isClientSideUrl(href) ? /*#__PURE__*/createElement(StyledLink, _extends({}, props, {
|
|
122
|
+
return router && !skipClientNav && isClientSideUrl(href) ? /*#__PURE__*/React.createElement(StyledLink, _extends({}, props, {
|
|
121
123
|
to: href
|
|
122
|
-
}), children) : /*#__PURE__*/createElement(StyledAnchor, _extends({}, props, {
|
|
124
|
+
}), children) : /*#__PURE__*/React.createElement(StyledAnchor, _extends({}, props, {
|
|
123
125
|
href: href,
|
|
124
126
|
target: target
|
|
125
127
|
}), children);
|
|
126
128
|
} else {
|
|
127
|
-
return /*#__PURE__*/createElement(StyledButton, _extends({
|
|
129
|
+
return /*#__PURE__*/React.createElement(StyledButton$2, _extends({
|
|
128
130
|
type: "button"
|
|
129
131
|
}, props, {
|
|
130
132
|
disabled: disabled
|
|
@@ -134,7 +136,7 @@ class ActionItem extends Component {
|
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
render() {
|
|
137
|
-
return /*#__PURE__*/createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
|
|
139
|
+
return /*#__PURE__*/React.createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
}
|
|
@@ -144,10 +146,10 @@ ActionItem.defaultProps = {
|
|
|
144
146
|
role: "menuitem"
|
|
145
147
|
};
|
|
146
148
|
ActionItem.__IS_ACTION_ITEM__ = true;
|
|
147
|
-
const styles = StyleSheet.create({
|
|
149
|
+
const styles$9 = StyleSheet.create({
|
|
148
150
|
shared: {
|
|
149
|
-
background: white,
|
|
150
|
-
color: offBlack,
|
|
151
|
+
background: white$4,
|
|
152
|
+
color: offBlack$3,
|
|
151
153
|
textDecoration: "none",
|
|
152
154
|
border: "none",
|
|
153
155
|
outline: "none",
|
|
@@ -171,25 +173,25 @@ const styles = StyleSheet.create({
|
|
|
171
173
|
},
|
|
172
174
|
// hover and focus states
|
|
173
175
|
focus: {
|
|
174
|
-
color: white,
|
|
175
|
-
background: blue
|
|
176
|
+
color: white$4,
|
|
177
|
+
background: blue$3
|
|
176
178
|
},
|
|
177
179
|
// active and pressed states
|
|
178
180
|
active: {
|
|
179
|
-
color: mix(fade(blue, 0.32), white),
|
|
180
|
-
background: mix(offBlack32, blue)
|
|
181
|
+
color: mix(fade(blue$3, 0.32), white$4),
|
|
182
|
+
background: mix(offBlack32$4, blue$3)
|
|
181
183
|
},
|
|
182
184
|
// disabled state
|
|
183
185
|
disabled: {
|
|
184
|
-
color: offBlack32,
|
|
186
|
+
color: offBlack32$4,
|
|
185
187
|
cursor: "default"
|
|
186
188
|
}
|
|
187
189
|
});
|
|
188
190
|
|
|
189
191
|
const {
|
|
190
|
-
offBlack: offBlack$
|
|
191
|
-
offBlack32: offBlack32$
|
|
192
|
-
white: white$
|
|
192
|
+
offBlack: offBlack$2,
|
|
193
|
+
offBlack32: offBlack32$3,
|
|
194
|
+
white: white$3
|
|
193
195
|
} = Color;
|
|
194
196
|
/**
|
|
195
197
|
* Props describing the state of the OptionItem, shared by the checkbox
|
|
@@ -207,14 +209,14 @@ function Check(props) {
|
|
|
207
209
|
hovered,
|
|
208
210
|
focused
|
|
209
211
|
} = props;
|
|
210
|
-
return /*#__PURE__*/createElement(Icon, {
|
|
212
|
+
return /*#__PURE__*/React.createElement(Icon, {
|
|
211
213
|
icon: icons.check,
|
|
212
214
|
size: "small",
|
|
213
|
-
color: disabled ? offBlack32$
|
|
214
|
-
style: [styles$
|
|
215
|
+
color: disabled ? offBlack32$3 : pressed || hovered || focused ? white$3 : offBlack$2,
|
|
216
|
+
style: [styles$8.bounds, !selected && styles$8.hide]
|
|
215
217
|
});
|
|
216
218
|
}
|
|
217
|
-
const styles$
|
|
219
|
+
const styles$8 = StyleSheet.create({
|
|
218
220
|
bounds: {
|
|
219
221
|
// Semantically, this are the constants for a small-sized icon
|
|
220
222
|
minHeight: 16,
|
|
@@ -233,9 +235,9 @@ const checkboxCheck = {
|
|
|
233
235
|
small: "M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z"
|
|
234
236
|
};
|
|
235
237
|
const {
|
|
236
|
-
blue: blue$
|
|
238
|
+
blue: blue$2,
|
|
237
239
|
white: white$2,
|
|
238
|
-
offBlack16,
|
|
240
|
+
offBlack16: offBlack16$1,
|
|
239
241
|
offBlack32: offBlack32$2,
|
|
240
242
|
offBlack50,
|
|
241
243
|
offWhite
|
|
@@ -256,22 +258,22 @@ function Checkbox(props) {
|
|
|
256
258
|
hovered,
|
|
257
259
|
focused
|
|
258
260
|
} = props;
|
|
259
|
-
const activeBlue = mix(offBlack32$2, blue$
|
|
261
|
+
const activeBlue = mix(offBlack32$2, blue$2);
|
|
260
262
|
const clickInteraction = pressed || hovered || focused;
|
|
261
|
-
const bgColor = disabled ? offWhite : selected && !clickInteraction ? blue$
|
|
262
|
-
const checkColor = disabled ? offBlack32$2 : clickInteraction ? pressed ? activeBlue : blue$
|
|
263
|
-
return /*#__PURE__*/createElement(View, {
|
|
264
|
-
style: [styles$
|
|
263
|
+
const bgColor = disabled ? offWhite : selected && !clickInteraction ? blue$2 : white$2;
|
|
264
|
+
const checkColor = disabled ? offBlack32$2 : clickInteraction ? pressed ? activeBlue : blue$2 : white$2;
|
|
265
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
266
|
+
style: [styles$7.checkbox, (clickInteraction || selected && !disabled) && styles$7.noBorder, disabled && styles$7.disabledCheckbox, {
|
|
265
267
|
backgroundColor: bgColor
|
|
266
268
|
}]
|
|
267
|
-
}, selected && /*#__PURE__*/createElement(Icon, {
|
|
269
|
+
}, selected && /*#__PURE__*/React.createElement(Icon, {
|
|
268
270
|
icon: checkboxCheck,
|
|
269
271
|
size: "small",
|
|
270
272
|
color: checkColor,
|
|
271
|
-
style: [disabled && selected && styles$
|
|
273
|
+
style: [disabled && selected && styles$7.disabledCheckFormatting]
|
|
272
274
|
}));
|
|
273
275
|
}
|
|
274
|
-
const styles$
|
|
276
|
+
const styles$7 = StyleSheet.create({
|
|
275
277
|
checkbox: {
|
|
276
278
|
// Semantically, this are the constants for a small-sized icon
|
|
277
279
|
minHeight: 16,
|
|
@@ -285,7 +287,7 @@ const styles$2 = StyleSheet.create({
|
|
|
285
287
|
borderWidth: 0
|
|
286
288
|
},
|
|
287
289
|
disabledCheckbox: {
|
|
288
|
-
borderColor: offBlack16,
|
|
290
|
+
borderColor: offBlack16$1,
|
|
289
291
|
backgroundColor: offWhite
|
|
290
292
|
},
|
|
291
293
|
// The border of 1px on the selected, disabled checkbox pushes the check out
|
|
@@ -297,14 +299,14 @@ const styles$2 = StyleSheet.create({
|
|
|
297
299
|
}
|
|
298
300
|
});
|
|
299
301
|
|
|
300
|
-
const _excluded = ["disabled", "label", "role", "selected", "testId", "style", "value", "onClick", "onToggle", "variant"];
|
|
302
|
+
const _excluded$6 = ["disabled", "label", "role", "selected", "testId", "style", "value", "onClick", "onToggle", "variant"];
|
|
301
303
|
|
|
302
304
|
/**
|
|
303
305
|
* For option items that can be selected in a dropdown, selection denoted either
|
|
304
306
|
* with a check ✔️ or a checkbox ☑️. Use as children in SingleSelect or
|
|
305
307
|
* MultiSelect.
|
|
306
308
|
*/
|
|
307
|
-
class OptionItem extends Component {
|
|
309
|
+
class OptionItem extends React.Component {
|
|
308
310
|
constructor(...args) {
|
|
309
311
|
super(...args);
|
|
310
312
|
|
|
@@ -344,11 +346,11 @@ class OptionItem extends Component {
|
|
|
344
346
|
testId,
|
|
345
347
|
style
|
|
346
348
|
} = _this$props,
|
|
347
|
-
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
349
|
+
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$6);
|
|
348
350
|
|
|
349
351
|
const ClickableBehavior = getClickableBehavior();
|
|
350
352
|
const CheckComponent = this.getCheckComponent();
|
|
351
|
-
return /*#__PURE__*/createElement(ClickableBehavior, {
|
|
353
|
+
return /*#__PURE__*/React.createElement(ClickableBehavior, {
|
|
352
354
|
disabled: disabled,
|
|
353
355
|
onClick: this.handleClick,
|
|
354
356
|
role: role
|
|
@@ -358,21 +360,21 @@ class OptionItem extends Component {
|
|
|
358
360
|
hovered,
|
|
359
361
|
focused
|
|
360
362
|
} = state;
|
|
361
|
-
const defaultStyle = [styles$
|
|
363
|
+
const defaultStyle = [styles$6.itemContainer, pressed ? styles$6.active : (hovered || focused) && styles$6.focus, disabled && styles$6.disabled, // pass optional styles from react-window (if applies)
|
|
362
364
|
style];
|
|
363
|
-
return /*#__PURE__*/createElement(View, _extends({}, sharedProps, {
|
|
365
|
+
return /*#__PURE__*/React.createElement(View, _extends({}, sharedProps, {
|
|
364
366
|
testId: testId,
|
|
365
367
|
style: defaultStyle,
|
|
366
368
|
"aria-selected": selected ? "true" : "false",
|
|
367
369
|
role: role
|
|
368
|
-
}, childrenProps), /*#__PURE__*/createElement(CheckComponent, {
|
|
370
|
+
}, childrenProps), /*#__PURE__*/React.createElement(CheckComponent, {
|
|
369
371
|
disabled: disabled,
|
|
370
372
|
selected: selected,
|
|
371
373
|
pressed: pressed,
|
|
372
374
|
hovered: hovered,
|
|
373
375
|
focused: focused
|
|
374
|
-
}), /*#__PURE__*/createElement(LabelMedium, {
|
|
375
|
-
style: styles$
|
|
376
|
+
}), /*#__PURE__*/React.createElement(LabelMedium, {
|
|
377
|
+
style: styles$6.label
|
|
376
378
|
}, label));
|
|
377
379
|
});
|
|
378
380
|
}
|
|
@@ -386,16 +388,16 @@ OptionItem.defaultProps = {
|
|
|
386
388
|
};
|
|
387
389
|
OptionItem.__IS_OPTION_ITEM__ = true;
|
|
388
390
|
const {
|
|
389
|
-
blue: blue$
|
|
390
|
-
white: white$
|
|
391
|
-
offBlack: offBlack$
|
|
392
|
-
offBlack32: offBlack32$
|
|
391
|
+
blue: blue$1,
|
|
392
|
+
white: white$1,
|
|
393
|
+
offBlack: offBlack$1,
|
|
394
|
+
offBlack32: offBlack32$1
|
|
393
395
|
} = Color;
|
|
394
|
-
const styles$
|
|
396
|
+
const styles$6 = StyleSheet.create({
|
|
395
397
|
itemContainer: {
|
|
396
398
|
flexDirection: "row",
|
|
397
|
-
|
|
398
|
-
color: offBlack$
|
|
399
|
+
background: white$1,
|
|
400
|
+
color: offBlack$1,
|
|
399
401
|
alignItems: "center",
|
|
400
402
|
height: DROPDOWN_ITEM_HEIGHT,
|
|
401
403
|
minHeight: DROPDOWN_ITEM_HEIGHT,
|
|
@@ -407,16 +409,16 @@ const styles$3 = StyleSheet.create({
|
|
|
407
409
|
cursor: "default"
|
|
408
410
|
},
|
|
409
411
|
focus: {
|
|
410
|
-
color: white$
|
|
411
|
-
background: blue$
|
|
412
|
+
color: white$1,
|
|
413
|
+
background: blue$1
|
|
412
414
|
},
|
|
413
415
|
active: {
|
|
414
|
-
color: mix(fade(blue$
|
|
415
|
-
background: mix(offBlack32$
|
|
416
|
+
color: mix(fade(blue$1, 0.32), white$1),
|
|
417
|
+
background: mix(offBlack32$1, blue$1)
|
|
416
418
|
},
|
|
417
419
|
disabled: {
|
|
418
|
-
color: offBlack32$
|
|
419
|
-
background: white$
|
|
420
|
+
color: offBlack32$1,
|
|
421
|
+
background: white$1
|
|
420
422
|
},
|
|
421
423
|
label: {
|
|
422
424
|
whiteSpace: "nowrap",
|
|
@@ -436,7 +438,7 @@ const styles$3 = StyleSheet.create({
|
|
|
436
438
|
/**
|
|
437
439
|
* A separator used in a dropdown menu.
|
|
438
440
|
*/
|
|
439
|
-
class SeparatorItem extends Component {
|
|
441
|
+
class SeparatorItem extends React.Component {
|
|
440
442
|
static isClassOf(instance) {
|
|
441
443
|
return instance && instance.type && instance.type.__IS_SEPARATOR_ITEM__;
|
|
442
444
|
}
|
|
@@ -445,8 +447,8 @@ class SeparatorItem extends Component {
|
|
|
445
447
|
return (
|
|
446
448
|
/*#__PURE__*/
|
|
447
449
|
// pass optional styles from react-window (if applies)
|
|
448
|
-
createElement(View, {
|
|
449
|
-
style: [styles$
|
|
450
|
+
React.createElement(View, {
|
|
451
|
+
style: [styles$5.separator, this.props.style],
|
|
450
452
|
"aria-hidden": "true"
|
|
451
453
|
})
|
|
452
454
|
);
|
|
@@ -454,7 +456,7 @@ class SeparatorItem extends Component {
|
|
|
454
456
|
|
|
455
457
|
}
|
|
456
458
|
SeparatorItem.__IS_SEPARATOR_ITEM__ = true;
|
|
457
|
-
const styles$
|
|
459
|
+
const styles$5 = StyleSheet.create({
|
|
458
460
|
separator: {
|
|
459
461
|
boxShadow: `0 -1px ${Color.offBlack16}`,
|
|
460
462
|
height: 1,
|
|
@@ -464,7 +466,7 @@ const styles$4 = StyleSheet.create({
|
|
|
464
466
|
}
|
|
465
467
|
});
|
|
466
468
|
|
|
467
|
-
class DropdownOpener extends Component {
|
|
469
|
+
class DropdownOpener extends React.Component {
|
|
468
470
|
constructor(...args) {
|
|
469
471
|
super(...args);
|
|
470
472
|
|
|
@@ -484,7 +486,7 @@ class DropdownOpener extends Component {
|
|
|
484
486
|
}));
|
|
485
487
|
const childrenProps = renderedChildren.props;
|
|
486
488
|
const childrenTestId = this.getTestIdFromProps(childrenProps);
|
|
487
|
-
return /*#__PURE__*/cloneElement(renderedChildren, _extends({}, clickableChildrenProps, {
|
|
489
|
+
return /*#__PURE__*/React.cloneElement(renderedChildren, _extends({}, clickableChildrenProps, {
|
|
488
490
|
disabled,
|
|
489
491
|
onClick: childrenProps.onClick ? e => {
|
|
490
492
|
// This is done to avoid overriding a
|
|
@@ -500,7 +502,7 @@ class DropdownOpener extends Component {
|
|
|
500
502
|
}
|
|
501
503
|
|
|
502
504
|
render() {
|
|
503
|
-
return /*#__PURE__*/createElement(ClickableBehavior, {
|
|
505
|
+
return /*#__PURE__*/React.createElement(ClickableBehavior, {
|
|
504
506
|
onClick: this.props.onClick,
|
|
505
507
|
disabled: this.props.disabled
|
|
506
508
|
}, (eventState, handlers) => this.renderAnchorChildren(eventState, handlers));
|
|
@@ -517,7 +519,7 @@ DropdownOpener.defaultProps = {
|
|
|
517
519
|
* (ActionItem, OptionItem, SeparatorItem) with custom styles to let
|
|
518
520
|
* react-window make its own calculations.
|
|
519
521
|
*/
|
|
520
|
-
class DropdownVirtualizedItem extends Component {
|
|
522
|
+
class DropdownVirtualizedItem extends React.Component {
|
|
521
523
|
render() {
|
|
522
524
|
const {
|
|
523
525
|
data,
|
|
@@ -529,7 +531,7 @@ class DropdownVirtualizedItem extends Component {
|
|
|
529
531
|
if (SeparatorItem.isClassOf(item.component)) {
|
|
530
532
|
// add react-window style to the separator to preserve the correct
|
|
531
533
|
// position
|
|
532
|
-
return /*#__PURE__*/cloneElement(item.component, {
|
|
534
|
+
return /*#__PURE__*/React.cloneElement(item.component, {
|
|
533
535
|
style
|
|
534
536
|
});
|
|
535
537
|
} else {
|
|
@@ -540,7 +542,7 @@ class DropdownVirtualizedItem extends Component {
|
|
|
540
542
|
role,
|
|
541
543
|
ref
|
|
542
544
|
} = item;
|
|
543
|
-
return /*#__PURE__*/cloneElement(component, _extends({
|
|
545
|
+
return /*#__PURE__*/React.cloneElement(component, _extends({
|
|
544
546
|
style
|
|
545
547
|
}, populatedProps, {
|
|
546
548
|
key: index,
|
|
@@ -553,7 +555,7 @@ class DropdownVirtualizedItem extends Component {
|
|
|
553
555
|
|
|
554
556
|
}
|
|
555
557
|
|
|
556
|
-
class SearchTextInput extends Component {
|
|
558
|
+
class SearchTextInput extends React.Component {
|
|
557
559
|
constructor(...args) {
|
|
558
560
|
super(...args);
|
|
559
561
|
this.state = {
|
|
@@ -617,11 +619,11 @@ class SearchTextInput extends Component {
|
|
|
617
619
|
} = this.state.labels;
|
|
618
620
|
|
|
619
621
|
if (searchText.length > 0) {
|
|
620
|
-
return /*#__PURE__*/createElement(IconButton, {
|
|
622
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
621
623
|
icon: icons.dismiss,
|
|
622
624
|
kind: "tertiary",
|
|
623
625
|
onClick: this.handleDismiss,
|
|
624
|
-
style: styles$
|
|
626
|
+
style: styles$4.dismissIcon,
|
|
625
627
|
"aria-label": clearSearch
|
|
626
628
|
});
|
|
627
629
|
}
|
|
@@ -640,16 +642,16 @@ class SearchTextInput extends Component {
|
|
|
640
642
|
const {
|
|
641
643
|
filter
|
|
642
644
|
} = this.state.labels;
|
|
643
|
-
return /*#__PURE__*/createElement(View, {
|
|
645
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
644
646
|
onClick: onClick,
|
|
645
|
-
style: [styles$
|
|
646
|
-
}, /*#__PURE__*/createElement(Icon, {
|
|
647
|
+
style: [styles$4.inputContainer, this.state.focused && styles$4.focused, style]
|
|
648
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
647
649
|
icon: icons.search,
|
|
648
650
|
size: "medium",
|
|
649
651
|
color: Color.offBlack64,
|
|
650
|
-
style: styles$
|
|
652
|
+
style: styles$4.searchIcon,
|
|
651
653
|
"aria-hidden": "true"
|
|
652
|
-
}), /*#__PURE__*/createElement("input", {
|
|
654
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
653
655
|
type: "text",
|
|
654
656
|
onChange: this.handleChange,
|
|
655
657
|
onFocus: this.handleFocus,
|
|
@@ -657,7 +659,7 @@ class SearchTextInput extends Component {
|
|
|
657
659
|
ref: itemRef,
|
|
658
660
|
placeholder: filter,
|
|
659
661
|
value: searchText,
|
|
660
|
-
className: css(styles$
|
|
662
|
+
className: css(styles$4.inputStyleReset, styles$a.LabelMedium),
|
|
661
663
|
"data-test-id": testId
|
|
662
664
|
}), this.maybeRenderDismissIconButton());
|
|
663
665
|
}
|
|
@@ -670,7 +672,7 @@ SearchTextInput.defaultProps = {
|
|
|
670
672
|
}
|
|
671
673
|
};
|
|
672
674
|
SearchTextInput.__IS_SEARCH_TEXT_INPUT__ = true;
|
|
673
|
-
const styles$
|
|
675
|
+
const styles$4 = StyleSheet.create({
|
|
674
676
|
inputContainer: {
|
|
675
677
|
flexDirection: "row",
|
|
676
678
|
border: `1px solid ${Color.offBlack16}`,
|
|
@@ -722,7 +724,7 @@ const MAX_VISIBLE_ITEMS = 9;
|
|
|
722
724
|
* dynamically calculates the item height depending on the type
|
|
723
725
|
*/
|
|
724
726
|
|
|
725
|
-
class DropdownCoreVirtualized extends Component {
|
|
727
|
+
class DropdownCoreVirtualized extends React.Component {
|
|
726
728
|
constructor(...args) {
|
|
727
729
|
super(...args);
|
|
728
730
|
this.state = {
|
|
@@ -839,7 +841,7 @@ class DropdownCoreVirtualized extends Component {
|
|
|
839
841
|
const allComponents = data.map(e => e.component); // 1. get the children opaque data structure to sort each item by its
|
|
840
842
|
// label length
|
|
841
843
|
|
|
842
|
-
const longestItems = Children.toArray(allComponents).filter(Boolean).sort((a, b) => {
|
|
844
|
+
const longestItems = React.Children.toArray(allComponents).filter(Boolean).sort((a, b) => {
|
|
843
845
|
// 2. only sort elements that contain a `label` prop
|
|
844
846
|
if (b.props.label && a.props.label) {
|
|
845
847
|
return b.props.label.length - a.props.label.length;
|
|
@@ -851,7 +853,7 @@ class DropdownCoreVirtualized extends Component {
|
|
|
851
853
|
.slice(0, MAX_VISIBLE_ITEMS); // Append longest items to calculate the container width.
|
|
852
854
|
// We need to hide these sorted elements to avoid any FOUC.
|
|
853
855
|
|
|
854
|
-
return longestItems.map(item => /*#__PURE__*/cloneElement(item, {
|
|
856
|
+
return longestItems.map(item => /*#__PURE__*/React.cloneElement(item, {
|
|
855
857
|
style: {
|
|
856
858
|
visibility: "hidden"
|
|
857
859
|
}
|
|
@@ -871,7 +873,7 @@ class DropdownCoreVirtualized extends Component {
|
|
|
871
873
|
/*#__PURE__*/
|
|
872
874
|
// react-window has some issues for typing lists when passing refs
|
|
873
875
|
// $FlowIgnore
|
|
874
|
-
createElement(VariableSizeList // react-window doesn't accept maybe numbers. It wants numbers
|
|
876
|
+
React.createElement(VariableSizeList // react-window doesn't accept maybe numbers. It wants numbers
|
|
875
877
|
// or strings.
|
|
876
878
|
// $FlowFixMe
|
|
877
879
|
, {
|
|
@@ -907,14 +909,14 @@ class DropdownCoreVirtualized extends Component {
|
|
|
907
909
|
|
|
908
910
|
var DropdownCoreVirtualized$1 = withActionScheduler(DropdownCoreVirtualized);
|
|
909
911
|
|
|
910
|
-
const _excluded$
|
|
912
|
+
const _excluded$5 = ["pointerEvents"];
|
|
911
913
|
|
|
912
914
|
/**
|
|
913
915
|
* A core dropdown component that takes an opener and children to display as
|
|
914
916
|
* part of the dropdown menu. Renders the dropdown as a portal to avoid clipping
|
|
915
917
|
* in overflow: auto containers.
|
|
916
918
|
*/
|
|
917
|
-
class DropdownCore extends Component {
|
|
919
|
+
class DropdownCore extends React.Component {
|
|
918
920
|
// Keeps track of the index of the focused item, out of a list of focusable items
|
|
919
921
|
// Keeps track of the index of the focused item in the context of all the
|
|
920
922
|
// items contained by this menu, whether focusable or not, used for figuring
|
|
@@ -947,7 +949,7 @@ class DropdownCore extends Component {
|
|
|
947
949
|
|
|
948
950
|
for (let i = 0; i < props.items.length; i++) {
|
|
949
951
|
if (props.items[i].focusable) {
|
|
950
|
-
const ref = /*#__PURE__*/createRef();
|
|
952
|
+
const ref = /*#__PURE__*/React.createRef();
|
|
951
953
|
itemRefs.push({
|
|
952
954
|
ref,
|
|
953
955
|
originalIndex: i
|
|
@@ -1099,7 +1101,7 @@ class DropdownCore extends Component {
|
|
|
1099
1101
|
noResults: defaultLabels.noResults
|
|
1100
1102
|
}, props.labels)
|
|
1101
1103
|
};
|
|
1102
|
-
this.listRef = /*#__PURE__*/createRef();
|
|
1104
|
+
this.listRef = /*#__PURE__*/React.createRef();
|
|
1103
1105
|
}
|
|
1104
1106
|
|
|
1105
1107
|
componentDidMount() {
|
|
@@ -1313,8 +1315,8 @@ class DropdownCore extends Component {
|
|
|
1313
1315
|
const numResults = items.length - includeSearchCount;
|
|
1314
1316
|
|
|
1315
1317
|
if (numResults === 0) {
|
|
1316
|
-
return /*#__PURE__*/createElement(LabelMedium, {
|
|
1317
|
-
style: styles$
|
|
1318
|
+
return /*#__PURE__*/React.createElement(LabelMedium, {
|
|
1319
|
+
style: styles$3.noResult,
|
|
1318
1320
|
testId: "dropdown-core-no-results"
|
|
1319
1321
|
}, noResults);
|
|
1320
1322
|
}
|
|
@@ -1382,15 +1384,15 @@ class DropdownCore extends Component {
|
|
|
1382
1384
|
const minDropdownWidth = openerStyle ? openerStyle.getPropertyValue("width") : 0; // preprocess items data to pass it to the renderer
|
|
1383
1385
|
|
|
1384
1386
|
const itemsList = this.parseItemsList();
|
|
1385
|
-
return /*#__PURE__*/createElement(View // Stop propagation to prevent the mouseup listener on the
|
|
1387
|
+
return /*#__PURE__*/React.createElement(View // Stop propagation to prevent the mouseup listener on the
|
|
1386
1388
|
// document from closing the menu.
|
|
1387
1389
|
, {
|
|
1388
1390
|
onMouseUp: this.handleDropdownMouseUp,
|
|
1389
1391
|
role: this.props.role,
|
|
1390
|
-
style: [styles$
|
|
1392
|
+
style: [styles$3.dropdown, light && styles$3.light, isReferenceHidden && styles$3.hidden, {
|
|
1391
1393
|
minWidth: minDropdownWidth
|
|
1392
1394
|
}, dropdownStyle]
|
|
1393
|
-
}, /*#__PURE__*/createElement(DropdownCoreVirtualized$1, {
|
|
1395
|
+
}, /*#__PURE__*/React.createElement(DropdownCoreVirtualized$1, {
|
|
1394
1396
|
data: itemsList,
|
|
1395
1397
|
listRef: this.listRef
|
|
1396
1398
|
}), this.maybeRenderNoResults());
|
|
@@ -1408,7 +1410,7 @@ class DropdownCore extends Component {
|
|
|
1408
1410
|
const modalHost = maybeGetPortalMountedModalHostElement(openerElement) || document.querySelector("body");
|
|
1409
1411
|
|
|
1410
1412
|
if (modalHost) {
|
|
1411
|
-
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/createElement(Popper, {
|
|
1413
|
+
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(Popper, {
|
|
1412
1414
|
innerRef: node => {
|
|
1413
1415
|
if (node) {
|
|
1414
1416
|
this.popperElement = node;
|
|
@@ -1439,9 +1441,9 @@ class DropdownCore extends Component {
|
|
|
1439
1441
|
}) => {
|
|
1440
1442
|
// For some reason react-popper includes `pointerEvents: "none"`
|
|
1441
1443
|
// in the `style` it passes to us, but only when running the tests.
|
|
1442
|
-
const restStyle = _objectWithoutPropertiesLoose(style, _excluded$
|
|
1444
|
+
const restStyle = _objectWithoutPropertiesLoose(style, _excluded$5);
|
|
1443
1445
|
|
|
1444
|
-
return /*#__PURE__*/createElement("div", {
|
|
1446
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1445
1447
|
ref: ref,
|
|
1446
1448
|
style: restStyle,
|
|
1447
1449
|
"data-placement": placement
|
|
@@ -1459,10 +1461,10 @@ class DropdownCore extends Component {
|
|
|
1459
1461
|
style,
|
|
1460
1462
|
className
|
|
1461
1463
|
} = this.props;
|
|
1462
|
-
return /*#__PURE__*/createElement(View, {
|
|
1464
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
1463
1465
|
onKeyDown: this.handleKeyDown,
|
|
1464
1466
|
onKeyUp: this.handleKeyUp,
|
|
1465
|
-
style: [styles$
|
|
1467
|
+
style: [styles$3.menuWrapper, style],
|
|
1466
1468
|
className: className
|
|
1467
1469
|
}, opener, open && this.renderDropdown());
|
|
1468
1470
|
}
|
|
@@ -1476,7 +1478,7 @@ DropdownCore.defaultProps = {
|
|
|
1476
1478
|
},
|
|
1477
1479
|
light: false
|
|
1478
1480
|
};
|
|
1479
|
-
const styles$
|
|
1481
|
+
const styles$3 = StyleSheet.create({
|
|
1480
1482
|
menuWrapper: {
|
|
1481
1483
|
width: "fit-content"
|
|
1482
1484
|
},
|
|
@@ -1505,7 +1507,7 @@ const styles$6 = StyleSheet.create({
|
|
|
1505
1507
|
});
|
|
1506
1508
|
var DropdownCore$1 = withActionScheduler(DropdownCore);
|
|
1507
1509
|
|
|
1508
|
-
const _excluded$
|
|
1510
|
+
const _excluded$4 = ["children", "disabled", "focused", "hovered", "pressed", "waiting", "testId", "opened", "aria-label"];
|
|
1509
1511
|
const StyledButton$1 = addStyle("button");
|
|
1510
1512
|
/**
|
|
1511
1513
|
* Although this component shares a lot with ButtonCore there are a couple
|
|
@@ -1514,7 +1516,7 @@ const StyledButton$1 = addStyle("button");
|
|
|
1514
1516
|
* - the down caret icon is smaller that the one that would be used by ButtonCore
|
|
1515
1517
|
*/
|
|
1516
1518
|
|
|
1517
|
-
class ActionMenuOpenerCore extends Component {
|
|
1519
|
+
class ActionMenuOpenerCore extends React.Component {
|
|
1518
1520
|
render() {
|
|
1519
1521
|
const _this$props = this.props,
|
|
1520
1522
|
{
|
|
@@ -1527,18 +1529,18 @@ class ActionMenuOpenerCore extends Component {
|
|
|
1527
1529
|
opened,
|
|
1528
1530
|
"aria-label": ariaLabel
|
|
1529
1531
|
} = _this$props,
|
|
1530
|
-
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded$
|
|
1532
|
+
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded$4);
|
|
1531
1533
|
|
|
1532
1534
|
const buttonColor = SemanticColor.controlDefault;
|
|
1533
1535
|
|
|
1534
|
-
const buttonStyles = _generateStyles(buttonColor);
|
|
1536
|
+
const buttonStyles = _generateStyles$1(buttonColor);
|
|
1535
1537
|
|
|
1536
1538
|
const disabled = disabledProp;
|
|
1537
1539
|
const defaultStyle = [sharedStyles.shared, disabled && sharedStyles.disabled, buttonStyles.default, disabled && buttonStyles.disabled, !disabled && pressed && buttonStyles.active];
|
|
1538
|
-
const label = /*#__PURE__*/createElement(LabelLarge, {
|
|
1540
|
+
const label = /*#__PURE__*/React.createElement(LabelLarge, {
|
|
1539
1541
|
style: sharedStyles.text
|
|
1540
1542
|
}, children);
|
|
1541
|
-
return /*#__PURE__*/createElement(StyledButton$1, _extends({
|
|
1543
|
+
return /*#__PURE__*/React.createElement(StyledButton$1, _extends({
|
|
1542
1544
|
"aria-expanded": opened ? "true" : "false",
|
|
1543
1545
|
"aria-haspopup": "menu",
|
|
1544
1546
|
"aria-label": ariaLabel,
|
|
@@ -1547,11 +1549,11 @@ class ActionMenuOpenerCore extends Component {
|
|
|
1547
1549
|
type: "button"
|
|
1548
1550
|
}, restProps, {
|
|
1549
1551
|
"data-test-id": testId
|
|
1550
|
-
}), /*#__PURE__*/createElement(View, {
|
|
1552
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
1551
1553
|
style: !disabled && (hovered || focused) && buttonStyles.focus
|
|
1552
|
-
}, label), /*#__PURE__*/createElement(Strut, {
|
|
1554
|
+
}, label), /*#__PURE__*/React.createElement(Strut, {
|
|
1553
1555
|
size: Spacing.xxxSmall_4
|
|
1554
|
-
}), /*#__PURE__*/createElement(Icon, {
|
|
1556
|
+
}), /*#__PURE__*/React.createElement(Icon, {
|
|
1555
1557
|
size: "small",
|
|
1556
1558
|
color: "currentColor",
|
|
1557
1559
|
icon: icons.caretDown
|
|
@@ -1605,13 +1607,13 @@ const sharedStyles = StyleSheet.create({
|
|
|
1605
1607
|
position: "absolute"
|
|
1606
1608
|
}
|
|
1607
1609
|
});
|
|
1608
|
-
const styles$
|
|
1610
|
+
const styles$2 = {};
|
|
1609
1611
|
|
|
1610
|
-
const _generateStyles = color => {
|
|
1612
|
+
const _generateStyles$1 = color => {
|
|
1611
1613
|
const buttonType = color;
|
|
1612
1614
|
|
|
1613
|
-
if (styles$
|
|
1614
|
-
return styles$
|
|
1615
|
+
if (styles$2[buttonType]) {
|
|
1616
|
+
return styles$2[buttonType];
|
|
1615
1617
|
}
|
|
1616
1618
|
|
|
1617
1619
|
const {
|
|
@@ -1644,8 +1646,8 @@ const _generateStyles = color => {
|
|
|
1644
1646
|
cursor: "default"
|
|
1645
1647
|
}
|
|
1646
1648
|
};
|
|
1647
|
-
styles$
|
|
1648
|
-
return styles$
|
|
1649
|
+
styles$2[buttonType] = StyleSheet.create(newStyles);
|
|
1650
|
+
return styles$2[buttonType];
|
|
1649
1651
|
};
|
|
1650
1652
|
|
|
1651
1653
|
const _excluded$3 = ["text"];
|
|
@@ -1653,7 +1655,7 @@ const _excluded$3 = ["text"];
|
|
|
1653
1655
|
/**
|
|
1654
1656
|
* A menu that consists of various types of items.
|
|
1655
1657
|
*/
|
|
1656
|
-
class ActionMenu extends Component {
|
|
1658
|
+
class ActionMenu extends React.Component {
|
|
1657
1659
|
constructor(...args) {
|
|
1658
1660
|
super(...args);
|
|
1659
1661
|
this.state = {
|
|
@@ -1725,7 +1727,7 @@ class ActionMenu extends Component {
|
|
|
1725
1727
|
children,
|
|
1726
1728
|
selectedValues
|
|
1727
1729
|
} = this.props;
|
|
1728
|
-
const allChildren = Children.toArray(children).filter(Boolean); // verify if there's at least one OptionItem element to indent the
|
|
1730
|
+
const allChildren = React.Children.toArray(children).filter(Boolean); // verify if there's at least one OptionItem element to indent the
|
|
1729
1731
|
// possible Action items
|
|
1730
1732
|
|
|
1731
1733
|
const isOptionItemIncluded = allChildren.some(item => OptionItem.isClassOf(item));
|
|
@@ -1771,7 +1773,7 @@ class ActionMenu extends Component {
|
|
|
1771
1773
|
const {
|
|
1772
1774
|
opened
|
|
1773
1775
|
} = this.state;
|
|
1774
|
-
return /*#__PURE__*/createElement(DropdownOpener, {
|
|
1776
|
+
return /*#__PURE__*/React.createElement(DropdownOpener, {
|
|
1775
1777
|
onClick: this.handleClick,
|
|
1776
1778
|
disabled: numItems === 0 || disabled,
|
|
1777
1779
|
text: menuText,
|
|
@@ -1780,7 +1782,7 @@ class ActionMenu extends Component {
|
|
|
1780
1782
|
}, opener ? opener : openerProps => {
|
|
1781
1783
|
const eventState = _objectWithoutPropertiesLoose(openerProps, _excluded$3);
|
|
1782
1784
|
|
|
1783
|
-
return /*#__PURE__*/createElement(ActionMenuOpenerCore, _extends({}, eventState, {
|
|
1785
|
+
return /*#__PURE__*/React.createElement(ActionMenuOpenerCore, _extends({}, eventState, {
|
|
1784
1786
|
disabled: disabled,
|
|
1785
1787
|
opened: !!opened,
|
|
1786
1788
|
testId: testId
|
|
@@ -1797,7 +1799,7 @@ class ActionMenu extends Component {
|
|
|
1797
1799
|
} = this.props;
|
|
1798
1800
|
const items = this.getMenuItems();
|
|
1799
1801
|
const dropdownOpener = this.renderOpener(items.length);
|
|
1800
|
-
return /*#__PURE__*/createElement(DropdownCore$1, {
|
|
1802
|
+
return /*#__PURE__*/React.createElement(DropdownCore$1, {
|
|
1801
1803
|
role: "menu",
|
|
1802
1804
|
style: style,
|
|
1803
1805
|
className: className,
|
|
@@ -1807,7 +1809,7 @@ class ActionMenu extends Component {
|
|
|
1807
1809
|
items: items,
|
|
1808
1810
|
openerElement: this.openerElement,
|
|
1809
1811
|
onOpenChanged: this.handleOpenChanged,
|
|
1810
|
-
dropdownStyle: [styles$
|
|
1812
|
+
dropdownStyle: [styles$1.menuTopSpace, dropdownStyle]
|
|
1811
1813
|
});
|
|
1812
1814
|
}
|
|
1813
1815
|
|
|
@@ -1816,7 +1818,7 @@ ActionMenu.defaultProps = {
|
|
|
1816
1818
|
alignment: "left",
|
|
1817
1819
|
disabled: false
|
|
1818
1820
|
};
|
|
1819
|
-
const styles$
|
|
1821
|
+
const styles$1 = StyleSheet.create({
|
|
1820
1822
|
caret: {
|
|
1821
1823
|
marginLeft: 4
|
|
1822
1824
|
},
|
|
@@ -1833,22 +1835,22 @@ const styles$8 = StyleSheet.create({
|
|
|
1833
1835
|
}
|
|
1834
1836
|
});
|
|
1835
1837
|
|
|
1836
|
-
const _excluded$
|
|
1837
|
-
const StyledButton
|
|
1838
|
+
const _excluded$2 = ["children", "disabled", "id", "isPlaceholder", "light", "open", "testId", "onOpenChanged"];
|
|
1839
|
+
const StyledButton = addStyle("button");
|
|
1838
1840
|
const {
|
|
1839
|
-
blue
|
|
1840
|
-
white
|
|
1841
|
+
blue,
|
|
1842
|
+
white,
|
|
1841
1843
|
white50,
|
|
1842
|
-
offBlack
|
|
1843
|
-
offBlack16
|
|
1844
|
-
offBlack32
|
|
1844
|
+
offBlack,
|
|
1845
|
+
offBlack16,
|
|
1846
|
+
offBlack32,
|
|
1845
1847
|
offBlack64
|
|
1846
1848
|
} = Color;
|
|
1847
1849
|
|
|
1848
1850
|
/**
|
|
1849
1851
|
* An opener that opens select boxes.
|
|
1850
1852
|
*/
|
|
1851
|
-
class SelectOpener extends Component {
|
|
1853
|
+
class SelectOpener extends React.Component {
|
|
1852
1854
|
constructor(...args) {
|
|
1853
1855
|
super(...args);
|
|
1854
1856
|
|
|
@@ -1871,14 +1873,14 @@ class SelectOpener extends Component {
|
|
|
1871
1873
|
open,
|
|
1872
1874
|
testId
|
|
1873
1875
|
} = _this$props,
|
|
1874
|
-
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$
|
|
1876
|
+
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$2);
|
|
1875
1877
|
|
|
1876
1878
|
const ClickableBehavior = getClickableBehavior(router);
|
|
1877
|
-
return /*#__PURE__*/createElement(ClickableBehavior, {
|
|
1879
|
+
return /*#__PURE__*/React.createElement(ClickableBehavior, {
|
|
1878
1880
|
disabled: disabled,
|
|
1879
1881
|
onClick: this.handleClick
|
|
1880
1882
|
}, (state, childrenProps) => {
|
|
1881
|
-
const stateStyles = _generateStyles
|
|
1883
|
+
const stateStyles = _generateStyles(light, isPlaceholder);
|
|
1882
1884
|
|
|
1883
1885
|
const {
|
|
1884
1886
|
hovered,
|
|
@@ -1887,9 +1889,9 @@ class SelectOpener extends Component {
|
|
|
1887
1889
|
} = state; // The icon colors are kind of fickle. This is just logic
|
|
1888
1890
|
// based on the zeplin design.
|
|
1889
1891
|
|
|
1890
|
-
const iconColor = light ? disabled || pressed ? "currentColor" : white
|
|
1891
|
-
const style = [styles
|
|
1892
|
-
return /*#__PURE__*/createElement(StyledButton
|
|
1892
|
+
const iconColor = light ? disabled || pressed ? "currentColor" : white : disabled ? offBlack32 : offBlack64;
|
|
1893
|
+
const style = [styles.shared, stateStyles.default, disabled && stateStyles.disabled, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus)];
|
|
1894
|
+
return /*#__PURE__*/React.createElement(StyledButton, _extends({}, sharedProps, {
|
|
1893
1895
|
"aria-expanded": open ? "true" : "false",
|
|
1894
1896
|
"aria-haspopup": "listbox",
|
|
1895
1897
|
"data-test-id": testId,
|
|
@@ -1897,20 +1899,20 @@ class SelectOpener extends Component {
|
|
|
1897
1899
|
id: id,
|
|
1898
1900
|
style: style,
|
|
1899
1901
|
type: "button"
|
|
1900
|
-
}, childrenProps), /*#__PURE__*/createElement(LabelMedium, {
|
|
1901
|
-
style: styles
|
|
1902
|
-
}, children), /*#__PURE__*/createElement(Icon, {
|
|
1902
|
+
}, childrenProps), /*#__PURE__*/React.createElement(LabelMedium, {
|
|
1903
|
+
style: styles.text
|
|
1904
|
+
}, children), /*#__PURE__*/React.createElement(Icon, {
|
|
1903
1905
|
icon: icons.caretDown,
|
|
1904
1906
|
color: iconColor,
|
|
1905
1907
|
size: "small",
|
|
1906
|
-
style: styles
|
|
1908
|
+
style: styles.caret,
|
|
1907
1909
|
"aria-hidden": "true"
|
|
1908
1910
|
}));
|
|
1909
1911
|
});
|
|
1910
1912
|
}
|
|
1911
1913
|
|
|
1912
1914
|
render() {
|
|
1913
|
-
return /*#__PURE__*/createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
|
|
1915
|
+
return /*#__PURE__*/React.createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
|
|
1914
1916
|
}
|
|
1915
1917
|
|
|
1916
1918
|
}
|
|
@@ -1920,14 +1922,14 @@ SelectOpener.defaultProps = {
|
|
|
1920
1922
|
isPlaceholder: false
|
|
1921
1923
|
};
|
|
1922
1924
|
const buttonRadius = 4;
|
|
1923
|
-
const styles
|
|
1925
|
+
const styles = StyleSheet.create({
|
|
1924
1926
|
// TODO: Dedupe with Button styles
|
|
1925
1927
|
shared: {
|
|
1926
1928
|
position: "relative",
|
|
1927
1929
|
display: "inline-flex",
|
|
1928
1930
|
alignItems: "center",
|
|
1929
1931
|
justifyContent: "space-between",
|
|
1930
|
-
color: offBlack
|
|
1932
|
+
color: offBlack,
|
|
1931
1933
|
height: DROPDOWN_ITEM_HEIGHT,
|
|
1932
1934
|
// This asymmetry arises from the Icon on the right side, which has
|
|
1933
1935
|
// extra padding built in. To have the component look more balanced,
|
|
@@ -1963,7 +1965,7 @@ const adjustedPaddingLeft = 16 - 1;
|
|
|
1963
1965
|
const adjustedPaddingRight = 12 - 1;
|
|
1964
1966
|
const stateStyles = {};
|
|
1965
1967
|
|
|
1966
|
-
const _generateStyles
|
|
1968
|
+
const _generateStyles = (light, placeholder) => {
|
|
1967
1969
|
// "hash" the parameters
|
|
1968
1970
|
const styleKey = `${String(light)}-${String(placeholder)}`;
|
|
1969
1971
|
|
|
@@ -1976,13 +1978,13 @@ const _generateStyles$1 = (light, placeholder) => {
|
|
|
1976
1978
|
if (light) {
|
|
1977
1979
|
newStyles = {
|
|
1978
1980
|
default: {
|
|
1979
|
-
|
|
1980
|
-
color: placeholder ? white50 : white
|
|
1981
|
+
background: "transparent",
|
|
1982
|
+
color: placeholder ? white50 : white,
|
|
1981
1983
|
borderColor: white50,
|
|
1982
1984
|
borderWidth: 1
|
|
1983
1985
|
},
|
|
1984
1986
|
focus: {
|
|
1985
|
-
borderColor: white
|
|
1987
|
+
borderColor: white,
|
|
1986
1988
|
borderWidth: 2,
|
|
1987
1989
|
paddingLeft: adjustedPaddingLeft,
|
|
1988
1990
|
paddingRight: adjustedPaddingRight
|
|
@@ -1990,41 +1992,41 @@ const _generateStyles$1 = (light, placeholder) => {
|
|
|
1990
1992
|
active: {
|
|
1991
1993
|
paddingLeft: adjustedPaddingLeft,
|
|
1992
1994
|
paddingRight: adjustedPaddingRight,
|
|
1993
|
-
borderColor: mix(fade(blue
|
|
1995
|
+
borderColor: mix(fade(blue, 0.32), white),
|
|
1994
1996
|
borderWidth: 2,
|
|
1995
|
-
color: placeholder ? mix(fade(white
|
|
1996
|
-
backgroundColor: mix(offBlack32
|
|
1997
|
+
color: placeholder ? mix(fade(white, 0.32), blue) : mix(fade(blue, 0.32), white),
|
|
1998
|
+
backgroundColor: mix(offBlack32, blue)
|
|
1997
1999
|
},
|
|
1998
2000
|
disabled: {
|
|
1999
|
-
borderColor: mix(fade(white
|
|
2000
|
-
color: mix(fade(white
|
|
2001
|
+
borderColor: mix(fade(white, 0.32), blue),
|
|
2002
|
+
color: mix(fade(white, 0.32), blue),
|
|
2001
2003
|
cursor: "auto"
|
|
2002
2004
|
}
|
|
2003
2005
|
};
|
|
2004
2006
|
} else {
|
|
2005
2007
|
newStyles = {
|
|
2006
2008
|
default: {
|
|
2007
|
-
|
|
2008
|
-
borderColor: offBlack16
|
|
2009
|
+
background: white,
|
|
2010
|
+
borderColor: offBlack16,
|
|
2009
2011
|
borderWidth: 1,
|
|
2010
|
-
color: placeholder ? offBlack64 : offBlack
|
|
2012
|
+
color: placeholder ? offBlack64 : offBlack
|
|
2011
2013
|
},
|
|
2012
2014
|
focus: {
|
|
2013
|
-
borderColor: blue
|
|
2015
|
+
borderColor: blue,
|
|
2014
2016
|
borderWidth: 2,
|
|
2015
2017
|
paddingLeft: adjustedPaddingLeft,
|
|
2016
2018
|
paddingRight: adjustedPaddingRight
|
|
2017
2019
|
},
|
|
2018
2020
|
active: {
|
|
2019
|
-
background: mix(fade(blue
|
|
2020
|
-
borderColor: mix(offBlack32
|
|
2021
|
+
background: mix(fade(blue, 0.32), white),
|
|
2022
|
+
borderColor: mix(offBlack32, blue),
|
|
2021
2023
|
borderWidth: 2,
|
|
2022
2024
|
paddingLeft: adjustedPaddingLeft,
|
|
2023
2025
|
paddingRight: adjustedPaddingRight
|
|
2024
2026
|
},
|
|
2025
2027
|
disabled: {
|
|
2026
2028
|
backgroundColor: "transparent",
|
|
2027
|
-
borderColor: offBlack16
|
|
2029
|
+
borderColor: offBlack16,
|
|
2028
2030
|
color: offBlack64,
|
|
2029
2031
|
cursor: "auto"
|
|
2030
2032
|
}
|
|
@@ -2035,7 +2037,7 @@ const _generateStyles$1 = (light, placeholder) => {
|
|
|
2035
2037
|
return stateStyles[styleKey];
|
|
2036
2038
|
};
|
|
2037
2039
|
|
|
2038
|
-
const _excluded$
|
|
2040
|
+
const _excluded$1 = ["children", "disabled", "id", "light", "opener", "placeholder", "selectedValue", "testId", "alignment", "dropdownStyle", "isFilterable", "onChange", "onToggle", "opened", "style", "className"];
|
|
2039
2041
|
|
|
2040
2042
|
/**
|
|
2041
2043
|
* The single select allows the selection of one item. Clients are responsible
|
|
@@ -2050,7 +2052,7 @@ const _excluded$5 = ["children", "disabled", "id", "light", "opener", "placehold
|
|
|
2050
2052
|
* hundreds of items without performance problems.
|
|
2051
2053
|
*
|
|
2052
2054
|
*/
|
|
2053
|
-
class SingleSelect extends Component {
|
|
2055
|
+
class SingleSelect extends React.Component {
|
|
2054
2056
|
constructor(props) {
|
|
2055
2057
|
super(props);
|
|
2056
2058
|
|
|
@@ -2183,7 +2185,7 @@ class SingleSelect extends Component {
|
|
|
2183
2185
|
}
|
|
2184
2186
|
|
|
2185
2187
|
return {
|
|
2186
|
-
component: /*#__PURE__*/createElement(SearchTextInput, {
|
|
2188
|
+
component: /*#__PURE__*/React.createElement(SearchTextInput, {
|
|
2187
2189
|
key: "search-text-input",
|
|
2188
2190
|
onChange: this.handleSearchTextChanged,
|
|
2189
2191
|
searchText: this.state.searchText,
|
|
@@ -2209,18 +2211,18 @@ class SingleSelect extends Component {
|
|
|
2209
2211
|
selectedValue,
|
|
2210
2212
|
testId
|
|
2211
2213
|
} = _this$props,
|
|
2212
|
-
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$
|
|
2214
|
+
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
|
|
2213
2215
|
|
|
2214
|
-
const selectedItem = Children.toArray(children).find(option => option.props.value === selectedValue); // If nothing is selected, or if the selectedValue doesn't match any
|
|
2216
|
+
const selectedItem = React.Children.toArray(children).find(option => option.props.value === selectedValue); // If nothing is selected, or if the selectedValue doesn't match any
|
|
2215
2217
|
// item in the menu, use the placeholder.
|
|
2216
2218
|
|
|
2217
2219
|
const menuText = selectedItem ? selectedItem.props.label : placeholder;
|
|
2218
|
-
const dropdownOpener = opener ? /*#__PURE__*/createElement(DropdownOpener, {
|
|
2220
|
+
const dropdownOpener = opener ? /*#__PURE__*/React.createElement(DropdownOpener, {
|
|
2219
2221
|
onClick: this.handleClick,
|
|
2220
2222
|
disabled: numItems === 0 || disabled,
|
|
2221
2223
|
ref: this.handleOpenerRef,
|
|
2222
2224
|
text: menuText
|
|
2223
|
-
}, opener) : /*#__PURE__*/createElement(SelectOpener, _extends({}, sharedProps, {
|
|
2225
|
+
}, opener) : /*#__PURE__*/React.createElement(SelectOpener, _extends({}, sharedProps, {
|
|
2224
2226
|
disabled: numItems === 0 || disabled,
|
|
2225
2227
|
id: id,
|
|
2226
2228
|
isPlaceholder: !selectedItem,
|
|
@@ -2246,12 +2248,12 @@ class SingleSelect extends Component {
|
|
|
2246
2248
|
const {
|
|
2247
2249
|
searchText
|
|
2248
2250
|
} = this.state;
|
|
2249
|
-
const allChildren = Children.toArray(children).filter(Boolean);
|
|
2251
|
+
const allChildren = React.Children.toArray(children).filter(Boolean);
|
|
2250
2252
|
const filteredItems = this.getMenuItems(allChildren);
|
|
2251
2253
|
const opener = this.renderOpener(allChildren.length);
|
|
2252
2254
|
const searchField = this.getSearchField();
|
|
2253
2255
|
const items = searchField ? [searchField].concat(filteredItems) : filteredItems;
|
|
2254
|
-
return /*#__PURE__*/createElement(DropdownCore$1, {
|
|
2256
|
+
return /*#__PURE__*/React.createElement(DropdownCore$1, {
|
|
2255
2257
|
role: "listbox",
|
|
2256
2258
|
alignment: alignment,
|
|
2257
2259
|
dropdownStyle: [isFilterable && filterableDropdownStyle, selectDropdownStyle, dropdownStyle],
|
|
@@ -2276,7 +2278,7 @@ SingleSelect.defaultProps = {
|
|
|
2276
2278
|
light: false
|
|
2277
2279
|
};
|
|
2278
2280
|
|
|
2279
|
-
const _excluded
|
|
2281
|
+
const _excluded = ["disabled", "id", "light", "opener", "testId", "alignment", "dropdownStyle", "implicitAllEnabled", "isFilterable", "labels", "onChange", "onToggle", "opened", "selectedValues", "shortcuts", "style", "className"];
|
|
2280
2282
|
|
|
2281
2283
|
/**
|
|
2282
2284
|
* A dropdown that consists of multiple selection items. This select allows
|
|
@@ -2286,7 +2288,7 @@ const _excluded$6 = ["disabled", "id", "light", "opener", "testId", "alignment",
|
|
|
2286
2288
|
* The multi select stays open until closed by the user. The onChange callback
|
|
2287
2289
|
* happens every time there is a change in the selection of the items.
|
|
2288
2290
|
*/
|
|
2289
|
-
class MultiSelect extends Component {
|
|
2291
|
+
class MultiSelect extends React.Component {
|
|
2290
2292
|
constructor(props) {
|
|
2291
2293
|
super(props);
|
|
2292
2294
|
|
|
@@ -2323,7 +2325,7 @@ class MultiSelect extends Component {
|
|
|
2323
2325
|
children,
|
|
2324
2326
|
onChange
|
|
2325
2327
|
} = this.props;
|
|
2326
|
-
const selected = Children.toArray(children).filter(Boolean).map(option => option.props.value);
|
|
2328
|
+
const selected = React.Children.toArray(children).filter(Boolean).map(option => option.props.value);
|
|
2327
2329
|
onChange(selected);
|
|
2328
2330
|
};
|
|
2329
2331
|
|
|
@@ -2445,7 +2447,7 @@ class MultiSelect extends Component {
|
|
|
2445
2447
|
filter
|
|
2446
2448
|
} = this.state.labels;
|
|
2447
2449
|
return [{
|
|
2448
|
-
component: /*#__PURE__*/createElement(SearchTextInput, {
|
|
2450
|
+
component: /*#__PURE__*/React.createElement(SearchTextInput, {
|
|
2449
2451
|
key: "search-text-input",
|
|
2450
2452
|
onChange: this.handleSearchTextChanged,
|
|
2451
2453
|
searchText: this.state.searchText,
|
|
@@ -2472,7 +2474,7 @@ class MultiSelect extends Component {
|
|
|
2472
2474
|
if (shortcuts && !this.state.searchText) {
|
|
2473
2475
|
const selectAllDisabled = numOptions === selectedValues.length;
|
|
2474
2476
|
const selectAll = {
|
|
2475
|
-
component: /*#__PURE__*/createElement(ActionItem, {
|
|
2477
|
+
component: /*#__PURE__*/React.createElement(ActionItem, {
|
|
2476
2478
|
disabled: selectAllDisabled,
|
|
2477
2479
|
label: selectAllLabel(numOptions),
|
|
2478
2480
|
indent: true,
|
|
@@ -2483,7 +2485,7 @@ class MultiSelect extends Component {
|
|
|
2483
2485
|
};
|
|
2484
2486
|
const selectNoneDisabled = selectedValues.length === 0;
|
|
2485
2487
|
const selectNone = {
|
|
2486
|
-
component: /*#__PURE__*/createElement(ActionItem, {
|
|
2488
|
+
component: /*#__PURE__*/React.createElement(ActionItem, {
|
|
2487
2489
|
disabled: selectNoneDisabled,
|
|
2488
2490
|
label: selectNoneLabel,
|
|
2489
2491
|
indent: true,
|
|
@@ -2493,7 +2495,7 @@ class MultiSelect extends Component {
|
|
|
2493
2495
|
populatedProps: {}
|
|
2494
2496
|
};
|
|
2495
2497
|
const separator = {
|
|
2496
|
-
component: /*#__PURE__*/createElement(SeparatorItem, {
|
|
2498
|
+
component: /*#__PURE__*/React.createElement(SeparatorItem, {
|
|
2497
2499
|
key: "shortcuts-separator"
|
|
2498
2500
|
}),
|
|
2499
2501
|
focusable: false,
|
|
@@ -2540,7 +2542,7 @@ class MultiSelect extends Component {
|
|
|
2540
2542
|
|
|
2541
2543
|
if (lastSelectedChildren.length && restOfTheChildren.length) {
|
|
2542
2544
|
lastSelectedItems.push({
|
|
2543
|
-
component: /*#__PURE__*/createElement(SeparatorItem, {
|
|
2545
|
+
component: /*#__PURE__*/React.createElement(SeparatorItem, {
|
|
2544
2546
|
key: "selected-separator"
|
|
2545
2547
|
}),
|
|
2546
2548
|
focusable: false,
|
|
@@ -2560,19 +2562,19 @@ class MultiSelect extends Component {
|
|
|
2560
2562
|
opener,
|
|
2561
2563
|
testId
|
|
2562
2564
|
} = _this$props,
|
|
2563
|
-
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded
|
|
2565
|
+
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
2564
2566
|
|
|
2565
2567
|
const {
|
|
2566
2568
|
noneSelected
|
|
2567
2569
|
} = this.state.labels;
|
|
2568
2570
|
const menuText = this.getMenuText(allChildren);
|
|
2569
2571
|
const numOptions = allChildren.length;
|
|
2570
|
-
const dropdownOpener = opener ? /*#__PURE__*/createElement(DropdownOpener, {
|
|
2572
|
+
const dropdownOpener = opener ? /*#__PURE__*/React.createElement(DropdownOpener, {
|
|
2571
2573
|
onClick: this.handleClick,
|
|
2572
2574
|
disabled: numOptions === 0 || disabled,
|
|
2573
2575
|
ref: this.handleOpenerRef,
|
|
2574
2576
|
text: menuText
|
|
2575
|
-
}, opener) : /*#__PURE__*/createElement(SelectOpener, _extends({}, sharedProps, {
|
|
2577
|
+
}, opener) : /*#__PURE__*/React.createElement(SelectOpener, _extends({}, sharedProps, {
|
|
2576
2578
|
disabled: numOptions === 0 || disabled,
|
|
2577
2579
|
id: id,
|
|
2578
2580
|
isPlaceholder: menuText === noneSelected,
|
|
@@ -2602,11 +2604,11 @@ class MultiSelect extends Component {
|
|
|
2602
2604
|
const {
|
|
2603
2605
|
noResults
|
|
2604
2606
|
} = this.state.labels;
|
|
2605
|
-
const allChildren = Children.toArray(children).filter(Boolean);
|
|
2607
|
+
const allChildren = React.Children.toArray(children).filter(Boolean);
|
|
2606
2608
|
const numOptions = allChildren.length;
|
|
2607
2609
|
const filteredItems = this.getMenuItems(allChildren);
|
|
2608
2610
|
const opener = this.renderOpener(allChildren);
|
|
2609
|
-
return /*#__PURE__*/createElement(DropdownCore$1, {
|
|
2611
|
+
return /*#__PURE__*/React.createElement(DropdownCore$1, {
|
|
2610
2612
|
role: "listbox",
|
|
2611
2613
|
alignment: alignment,
|
|
2612
2614
|
dropdownStyle: [isFilterable && filterableDropdownStyle, selectDropdownStyle, dropdownStyle],
|