@khanacademy/wonder-blocks-dropdown 9.1.1 → 9.1.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 +49 -0
- package/dist/components/multi-select.d.ts +8 -3
- package/dist/components/single-select.d.ts +8 -3
- package/dist/es/index.js +288 -172
- package/dist/index.js +287 -171
- package/package.json +11 -11
package/dist/es/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useId } from 'react';
|
|
4
4
|
import { StyleSheet } from 'aphrodite';
|
|
5
5
|
import { CompactCell, DetailCell } from '@khanacademy/wonder-blocks-cell';
|
|
6
|
-
import { spacing,
|
|
6
|
+
import { spacing, semanticColor, border, color, font } from '@khanacademy/wonder-blocks-tokens';
|
|
7
7
|
import { LabelMedium, LabelSmall, LabelLarge } from '@khanacademy/wonder-blocks-typography';
|
|
8
8
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
|
|
9
9
|
import { View, addStyle, keys, Id, useOnMountEffect } from '@khanacademy/wonder-blocks-core';
|
|
@@ -67,11 +67,6 @@ const defaultComboboxLabels = {
|
|
|
67
67
|
unselected: labels => `${labels} not selected`
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
const {
|
|
71
|
-
blue: blue$1,
|
|
72
|
-
white: white$1,
|
|
73
|
-
offBlack: offBlack$1
|
|
74
|
-
} = color;
|
|
75
70
|
class ActionItem extends React.Component {
|
|
76
71
|
static isClassOf(instance) {
|
|
77
72
|
return instance && instance.type && instance.type.__IS_ACTION_ITEM__;
|
|
@@ -92,13 +87,13 @@ class ActionItem extends React.Component {
|
|
|
92
87
|
style,
|
|
93
88
|
testId
|
|
94
89
|
} = this.props;
|
|
95
|
-
const defaultStyle = [styles$
|
|
90
|
+
const defaultStyle = [styles$b.wrapper, style];
|
|
96
91
|
const labelComponent = typeof label === "string" ? React.createElement(LabelMedium, {
|
|
97
92
|
lang: lang,
|
|
98
|
-
style: styles$
|
|
93
|
+
style: styles$b.label
|
|
99
94
|
}, label) : (React.cloneElement(label, _extends({
|
|
100
95
|
lang,
|
|
101
|
-
style: styles$
|
|
96
|
+
style: styles$b.label
|
|
102
97
|
}, label.props)));
|
|
103
98
|
return React.createElement(CompactCell, {
|
|
104
99
|
disabled: disabled,
|
|
@@ -106,7 +101,7 @@ class ActionItem extends React.Component {
|
|
|
106
101
|
rootStyle: defaultStyle,
|
|
107
102
|
leftAccessory: leftAccessory,
|
|
108
103
|
rightAccessory: rightAccessory,
|
|
109
|
-
style: [styles$
|
|
104
|
+
style: [styles$b.shared, indent && styles$b.indent],
|
|
110
105
|
role: role,
|
|
111
106
|
testId: testId,
|
|
112
107
|
title: labelComponent,
|
|
@@ -123,28 +118,37 @@ ActionItem.defaultProps = {
|
|
|
123
118
|
role: "menuitem"
|
|
124
119
|
};
|
|
125
120
|
ActionItem.__IS_ACTION_ITEM__ = true;
|
|
126
|
-
const
|
|
121
|
+
const actionType$1 = semanticColor.action.primary.progressive;
|
|
122
|
+
const theme$7 = {
|
|
123
|
+
actionItem: {
|
|
124
|
+
color: {
|
|
125
|
+
hover: {
|
|
126
|
+
background: actionType$1.hover.background,
|
|
127
|
+
foreground: actionType$1.hover.foreground
|
|
128
|
+
},
|
|
129
|
+
press: {
|
|
130
|
+
background: actionType$1.press.background,
|
|
131
|
+
foreground: actionType$1.press.foreground
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const styles$b = StyleSheet.create({
|
|
127
137
|
wrapper: {
|
|
128
138
|
minHeight: DROPDOWN_ITEM_HEIGHT,
|
|
129
139
|
touchAction: "manipulation",
|
|
130
140
|
":focus": {
|
|
131
141
|
borderRadius: spacing.xxxSmall_4,
|
|
132
|
-
outline: `${spacing.xxxxSmall_2}px solid ${
|
|
142
|
+
outline: `${spacing.xxxxSmall_2}px solid ${semanticColor.focus.outer}`,
|
|
133
143
|
outlineOffset: -spacing.xxxxSmall_2
|
|
134
144
|
},
|
|
135
145
|
[":hover[aria-disabled=false]"]: {
|
|
136
|
-
color:
|
|
137
|
-
background:
|
|
138
|
-
},
|
|
139
|
-
["@media not (hover: hover)"]: {
|
|
140
|
-
[":hover[aria-disabled=false]"]: {
|
|
141
|
-
color: white$1,
|
|
142
|
-
background: offBlack$1
|
|
143
|
-
}
|
|
146
|
+
color: theme$7.actionItem.color.hover.foreground,
|
|
147
|
+
background: theme$7.actionItem.color.hover.background
|
|
144
148
|
},
|
|
145
149
|
[":active[aria-disabled=false]"]: {
|
|
146
|
-
color: color.
|
|
147
|
-
background: color.
|
|
150
|
+
color: theme$7.actionItem.color.press.foreground,
|
|
151
|
+
background: theme$7.actionItem.color.press.background
|
|
148
152
|
}
|
|
149
153
|
},
|
|
150
154
|
shared: {
|
|
@@ -167,10 +171,10 @@ const Check = function Check(props) {
|
|
|
167
171
|
return React.createElement(PhosphorIcon, {
|
|
168
172
|
icon: checkIcon,
|
|
169
173
|
size: "small",
|
|
170
|
-
style: [styles$
|
|
174
|
+
style: [styles$a.bounds, !selected && styles$a.hide]
|
|
171
175
|
});
|
|
172
176
|
};
|
|
173
|
-
const styles$
|
|
177
|
+
const styles$a = StyleSheet.create({
|
|
174
178
|
bounds: {
|
|
175
179
|
alignSelf: "center",
|
|
176
180
|
height: spacing.medium_16,
|
|
@@ -182,11 +186,6 @@ const styles$b = StyleSheet.create({
|
|
|
182
186
|
}
|
|
183
187
|
});
|
|
184
188
|
|
|
185
|
-
const {
|
|
186
|
-
offBlack16,
|
|
187
|
-
offBlack50,
|
|
188
|
-
offWhite
|
|
189
|
-
} = color;
|
|
190
189
|
const Checkbox = function Checkbox(props) {
|
|
191
190
|
const {
|
|
192
191
|
disabled,
|
|
@@ -194,7 +193,7 @@ const Checkbox = function Checkbox(props) {
|
|
|
194
193
|
} = props;
|
|
195
194
|
return React.createElement(View, {
|
|
196
195
|
className: "checkbox",
|
|
197
|
-
style: [styles$
|
|
196
|
+
style: [styles$9.checkbox, selected && !disabled && styles$9.noBorder, disabled && styles$9.disabledCheckbox]
|
|
198
197
|
}, selected && React.createElement(PhosphorIcon, {
|
|
199
198
|
icon: checkIcon,
|
|
200
199
|
size: "small",
|
|
@@ -203,26 +202,39 @@ const Checkbox = function Checkbox(props) {
|
|
|
203
202
|
width: spacing.small_12,
|
|
204
203
|
height: spacing.small_12,
|
|
205
204
|
margin: spacing.xxxxSmall_2
|
|
206
|
-
}, disabled && selected && styles$
|
|
205
|
+
}, disabled && selected && styles$9.disabledCheckFormatting]
|
|
207
206
|
}));
|
|
208
207
|
};
|
|
209
|
-
const
|
|
208
|
+
const theme$6 = {
|
|
209
|
+
checkbox: {
|
|
210
|
+
color: {
|
|
211
|
+
default: {
|
|
212
|
+
border: semanticColor.border.strong
|
|
213
|
+
},
|
|
214
|
+
disabled: {
|
|
215
|
+
border: semanticColor.action.secondary.disabled.border,
|
|
216
|
+
background: semanticColor.action.secondary.disabled.background
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
const styles$9 = StyleSheet.create({
|
|
210
222
|
checkbox: {
|
|
211
223
|
alignSelf: "center",
|
|
212
224
|
minHeight: spacing.medium_16,
|
|
213
225
|
minWidth: spacing.medium_16,
|
|
214
226
|
height: spacing.medium_16,
|
|
215
|
-
borderRadius:
|
|
216
|
-
borderWidth:
|
|
227
|
+
borderRadius: border.radius.small_3,
|
|
228
|
+
borderWidth: border.width.hairline,
|
|
217
229
|
borderStyle: "solid",
|
|
218
|
-
borderColor:
|
|
230
|
+
borderColor: theme$6.checkbox.color.default.border
|
|
219
231
|
},
|
|
220
232
|
noBorder: {
|
|
221
233
|
borderWidth: 0
|
|
222
234
|
},
|
|
223
235
|
disabledCheckbox: {
|
|
224
|
-
borderColor:
|
|
225
|
-
backgroundColor:
|
|
236
|
+
borderColor: theme$6.checkbox.color.disabled.border,
|
|
237
|
+
backgroundColor: theme$6.checkbox.color.disabled.background
|
|
226
238
|
},
|
|
227
239
|
disabledCheckFormatting: {
|
|
228
240
|
position: "absolute",
|
|
@@ -276,12 +288,12 @@ class OptionItem extends React.Component {
|
|
|
276
288
|
} = _this$props,
|
|
277
289
|
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$5);
|
|
278
290
|
const CheckComponent = this.getCheckComponent();
|
|
279
|
-
const defaultStyle = [styles$
|
|
291
|
+
const defaultStyle = [styles$8.item, style];
|
|
280
292
|
return React.createElement(DetailCell, _extends({
|
|
281
293
|
disabled: disabled,
|
|
282
294
|
horizontalRule: horizontalRule,
|
|
283
|
-
rootStyle: parentComponent === "listbox" ? styles$
|
|
284
|
-
style: styles$
|
|
295
|
+
rootStyle: parentComponent === "listbox" ? styles$8.listboxItem : defaultStyle,
|
|
296
|
+
style: styles$8.itemContainer,
|
|
285
297
|
"aria-selected": parentComponent !== "listbox" && selected ? "true" : "false",
|
|
286
298
|
role: parentComponent !== "listbox" ? role : undefined,
|
|
287
299
|
testId: testId,
|
|
@@ -303,7 +315,7 @@ class OptionItem extends React.Component {
|
|
|
303
315
|
className: "subtitle"
|
|
304
316
|
}, subtitle1) : undefined,
|
|
305
317
|
title: React.createElement(LabelMedium, {
|
|
306
|
-
style: styles$
|
|
318
|
+
style: styles$8.label
|
|
307
319
|
}, label),
|
|
308
320
|
subtitle2: subtitle2 ? React.createElement(LabelSmall, {
|
|
309
321
|
className: "subtitle"
|
|
@@ -320,18 +332,19 @@ class OptionItem extends React.Component {
|
|
|
320
332
|
selected
|
|
321
333
|
} = this.props;
|
|
322
334
|
if (parentComponent === "listbox") {
|
|
323
|
-
return React.createElement(StyledLi, {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
+
return (React.createElement(StyledLi, {
|
|
336
|
+
onMouseDown: e => {
|
|
337
|
+
e.preventDefault();
|
|
338
|
+
},
|
|
339
|
+
onClick: this.handleClick,
|
|
340
|
+
style: [styles$8.reset, styles$8.item, focused && styles$8.itemFocused, disabled && styles$8.itemDisabled],
|
|
341
|
+
role: role,
|
|
342
|
+
"aria-selected": selected ? "true" : "false",
|
|
343
|
+
"aria-disabled": disabled ? "true" : "false",
|
|
344
|
+
id: this.props.id,
|
|
345
|
+
tabIndex: -1
|
|
346
|
+
}, this.renderCell())
|
|
347
|
+
);
|
|
335
348
|
}
|
|
336
349
|
return this.renderCell();
|
|
337
350
|
}
|
|
@@ -345,17 +358,64 @@ OptionItem.defaultProps = {
|
|
|
345
358
|
selected: false
|
|
346
359
|
};
|
|
347
360
|
OptionItem.__IS_OPTION_ITEM__ = true;
|
|
348
|
-
const {
|
|
349
|
-
blue,
|
|
350
|
-
white,
|
|
351
|
-
offBlack
|
|
352
|
-
} = color;
|
|
353
361
|
const focusedStyle = {
|
|
354
362
|
borderRadius: spacing.xxxSmall_4,
|
|
355
|
-
outline: `${spacing.xxxxSmall_2}px solid ${
|
|
363
|
+
outline: `${spacing.xxxxSmall_2}px solid ${semanticColor.focus.outer}`,
|
|
356
364
|
outlineOffset: -spacing.xxxxSmall_2
|
|
357
365
|
};
|
|
358
|
-
const
|
|
366
|
+
const actionType = semanticColor.action.primary.progressive;
|
|
367
|
+
const theme$5 = {
|
|
368
|
+
optionItem: {
|
|
369
|
+
color: {
|
|
370
|
+
default: {
|
|
371
|
+
background: semanticColor.surface.primary,
|
|
372
|
+
foreground: semanticColor.text.primary
|
|
373
|
+
},
|
|
374
|
+
hover: {
|
|
375
|
+
background: actionType.hover.background,
|
|
376
|
+
foreground: actionType.hover.foreground
|
|
377
|
+
},
|
|
378
|
+
press: {
|
|
379
|
+
background: actionType.press.background,
|
|
380
|
+
foreground: actionType.press.foreground
|
|
381
|
+
},
|
|
382
|
+
disabled: {
|
|
383
|
+
background: "transparent",
|
|
384
|
+
foreground: semanticColor.action.secondary.disabled.foreground
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
checkbox: {
|
|
389
|
+
color: {
|
|
390
|
+
hover: {
|
|
391
|
+
background: semanticColor.action.secondary.progressive.hover.background,
|
|
392
|
+
foreground: semanticColor.action.secondary.progressive.hover.foreground
|
|
393
|
+
},
|
|
394
|
+
press: {
|
|
395
|
+
background: semanticColor.surface.primary,
|
|
396
|
+
foreground: semanticColor.action.secondary.progressive.press.foreground
|
|
397
|
+
},
|
|
398
|
+
selected: {
|
|
399
|
+
background: actionType.default.background,
|
|
400
|
+
foreground: actionType.default.foreground
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
subtitle: {
|
|
405
|
+
color: {
|
|
406
|
+
default: {
|
|
407
|
+
foreground: semanticColor.text.secondary
|
|
408
|
+
},
|
|
409
|
+
hover: {
|
|
410
|
+
foreground: semanticColor.text.inverse
|
|
411
|
+
},
|
|
412
|
+
press: {
|
|
413
|
+
foreground: semanticColor.text.inverse
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
const styles$8 = StyleSheet.create({
|
|
359
419
|
reset: {
|
|
360
420
|
margin: 0,
|
|
361
421
|
padding: 0,
|
|
@@ -374,69 +434,68 @@ const styles$9 = StyleSheet.create({
|
|
|
374
434
|
color: "inherit"
|
|
375
435
|
},
|
|
376
436
|
item: {
|
|
377
|
-
|
|
437
|
+
background: theme$5.optionItem.color.default.background,
|
|
438
|
+
color: theme$5.optionItem.color.default.foreground,
|
|
378
439
|
minHeight: "unset",
|
|
379
440
|
":focus": focusedStyle,
|
|
380
441
|
":focus-visible": {
|
|
381
442
|
overflow: "visible"
|
|
382
443
|
},
|
|
383
444
|
[":hover[aria-disabled=false]"]: {
|
|
384
|
-
color:
|
|
385
|
-
background:
|
|
445
|
+
color: theme$5.optionItem.color.hover.foreground,
|
|
446
|
+
background: theme$5.optionItem.color.hover.background
|
|
386
447
|
},
|
|
387
448
|
[":active[aria-selected=false]"]: {},
|
|
388
449
|
[":hover[aria-disabled=true]"]: {
|
|
389
450
|
cursor: "not-allowed"
|
|
390
451
|
},
|
|
391
452
|
[":is([aria-disabled=true])"]: {
|
|
392
|
-
color: color.
|
|
453
|
+
color: theme$5.optionItem.color.disabled.foreground,
|
|
393
454
|
":focus-visible": {
|
|
394
455
|
outline: "none"
|
|
395
456
|
}
|
|
396
457
|
},
|
|
397
|
-
["@media not (hover: hover)"]: {
|
|
398
|
-
[":hover[aria-disabled=false]"]: {
|
|
399
|
-
color: white,
|
|
400
|
-
background: offBlack
|
|
401
|
-
}
|
|
402
|
-
},
|
|
403
458
|
[":active[aria-disabled=false]"]: {
|
|
404
|
-
color: color.
|
|
405
|
-
background: color.
|
|
459
|
+
color: theme$5.optionItem.color.press.foreground,
|
|
460
|
+
background: theme$5.optionItem.color.press.background
|
|
406
461
|
},
|
|
407
462
|
[":hover[aria-disabled=false] .checkbox"]: {
|
|
408
|
-
background:
|
|
463
|
+
background: theme$5.checkbox.color.hover.background
|
|
464
|
+
},
|
|
465
|
+
[":active[aria-disabled=false] .checkbox"]: {
|
|
466
|
+
background: theme$5.checkbox.color.press.background
|
|
409
467
|
},
|
|
410
468
|
[":hover[aria-disabled=false] .check"]: {
|
|
411
|
-
color:
|
|
469
|
+
color: theme$5.checkbox.color.hover.foreground
|
|
412
470
|
},
|
|
413
471
|
[":active[aria-disabled=false] .check"]: {
|
|
414
|
-
color: color.
|
|
472
|
+
color: theme$5.checkbox.color.press.foreground
|
|
415
473
|
},
|
|
416
474
|
[":is([aria-selected=true]) .checkbox"]: {
|
|
417
|
-
background:
|
|
475
|
+
background: theme$5.checkbox.color.selected.background
|
|
418
476
|
},
|
|
419
477
|
[":is([aria-selected=true]) .check"]: {
|
|
420
|
-
color:
|
|
478
|
+
color: theme$5.checkbox.color.selected.foreground
|
|
421
479
|
},
|
|
422
480
|
[":is([aria-disabled=false]) .subtitle"]: {
|
|
423
|
-
color: color.
|
|
481
|
+
color: theme$5.subtitle.color.default.foreground
|
|
424
482
|
},
|
|
425
483
|
[":hover[aria-disabled=false] .subtitle"]: {
|
|
426
|
-
color: color.
|
|
484
|
+
color: theme$5.subtitle.color.hover.foreground
|
|
427
485
|
},
|
|
428
486
|
[":active[aria-disabled=false] .subtitle"]: {
|
|
429
|
-
color:
|
|
487
|
+
color: theme$5.subtitle.color.press.foreground
|
|
430
488
|
}
|
|
431
489
|
},
|
|
432
490
|
itemFocused: focusedStyle,
|
|
433
491
|
itemDisabled: {
|
|
434
|
-
outlineColor:
|
|
492
|
+
outlineColor: semanticColor.focus.outer
|
|
435
493
|
},
|
|
436
494
|
itemContainer: {
|
|
437
495
|
minHeight: "unset",
|
|
438
|
-
|
|
439
|
-
|
|
496
|
+
paddingBlock: spacing.xSmall_8 + spacing.xxxxSmall_2,
|
|
497
|
+
paddingInlineStart: spacing.xSmall_8,
|
|
498
|
+
paddingInlineEnd: spacing.medium_16,
|
|
440
499
|
whiteSpace: "nowrap"
|
|
441
500
|
},
|
|
442
501
|
label: {
|
|
@@ -456,16 +515,23 @@ class SeparatorItem extends React.Component {
|
|
|
456
515
|
}
|
|
457
516
|
render() {
|
|
458
517
|
return (React.createElement(View, {
|
|
459
|
-
style: [styles$
|
|
518
|
+
style: [styles$7.separator, this.props.style],
|
|
460
519
|
"aria-hidden": "true"
|
|
461
520
|
})
|
|
462
521
|
);
|
|
463
522
|
}
|
|
464
523
|
}
|
|
465
524
|
SeparatorItem.__IS_SEPARATOR_ITEM__ = true;
|
|
466
|
-
const
|
|
525
|
+
const theme$4 = {
|
|
526
|
+
separator: {
|
|
527
|
+
color: {
|
|
528
|
+
border: semanticColor.border.primary
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
const styles$7 = StyleSheet.create({
|
|
467
533
|
separator: {
|
|
468
|
-
|
|
534
|
+
borderTop: `1px solid ${theme$4.separator.color.border}`,
|
|
469
535
|
height: 1,
|
|
470
536
|
minHeight: 1,
|
|
471
537
|
marginTop: spacing.xxxSmall_4,
|
|
@@ -1172,7 +1238,7 @@ class DropdownCore extends React.Component {
|
|
|
1172
1238
|
const numResults = items.length;
|
|
1173
1239
|
if (numResults === 0) {
|
|
1174
1240
|
return React.createElement(LabelMedium, {
|
|
1175
|
-
style: styles$
|
|
1241
|
+
style: styles$6.noResult,
|
|
1176
1242
|
testId: "dropdown-core-no-results"
|
|
1177
1243
|
}, noResults);
|
|
1178
1244
|
}
|
|
@@ -1247,7 +1313,7 @@ class DropdownCore extends React.Component {
|
|
|
1247
1313
|
onChange: this.handleSearchTextChanged,
|
|
1248
1314
|
placeholder: labels.filter,
|
|
1249
1315
|
ref: this.searchFieldRef,
|
|
1250
|
-
style: styles$
|
|
1316
|
+
style: styles$6.searchInputStyle,
|
|
1251
1317
|
value: searchText || ""
|
|
1252
1318
|
});
|
|
1253
1319
|
}
|
|
@@ -1265,12 +1331,12 @@ class DropdownCore extends React.Component {
|
|
|
1265
1331
|
const minDropdownWidth = openerStyle ? openerStyle.getPropertyValue("width") : 0;
|
|
1266
1332
|
return React.createElement(View, {
|
|
1267
1333
|
onMouseUp: this.handleDropdownMouseUp,
|
|
1268
|
-
style: [styles$
|
|
1334
|
+
style: [styles$6.dropdown, isReferenceHidden && styles$6.hidden, dropdownStyle],
|
|
1269
1335
|
testId: "dropdown-core-container"
|
|
1270
1336
|
}, isFilterable && this.renderSearchField(), React.createElement(View, {
|
|
1271
1337
|
id: id,
|
|
1272
1338
|
role: role,
|
|
1273
|
-
style: [styles$
|
|
1339
|
+
style: [styles$6.listboxOrMenu, {
|
|
1274
1340
|
minWidth: minDropdownWidth
|
|
1275
1341
|
}],
|
|
1276
1342
|
"aria-invalid": role === "listbox" ? ariaInvalid : undefined,
|
|
@@ -1304,7 +1370,7 @@ class DropdownCore extends React.Component {
|
|
|
1304
1370
|
"aria-live": "polite",
|
|
1305
1371
|
"aria-atomic": "true",
|
|
1306
1372
|
"aria-relevant": "additions text",
|
|
1307
|
-
style: styles$
|
|
1373
|
+
style: styles$6.srOnly,
|
|
1308
1374
|
"data-testid": "dropdown-live-region"
|
|
1309
1375
|
}, open && labels.someResults(totalItems));
|
|
1310
1376
|
}
|
|
@@ -1319,7 +1385,7 @@ class DropdownCore extends React.Component {
|
|
|
1319
1385
|
return React.createElement(View, {
|
|
1320
1386
|
onKeyDown: !disabled ? this.handleKeyDown : undefined,
|
|
1321
1387
|
onKeyUp: !disabled ? this.handleKeyUp : undefined,
|
|
1322
|
-
style: [styles$
|
|
1388
|
+
style: [styles$6.menuWrapper, style],
|
|
1323
1389
|
className: className
|
|
1324
1390
|
}, this.renderLiveRegion(), opener, open && this.renderDropdown());
|
|
1325
1391
|
}
|
|
@@ -1336,17 +1402,32 @@ DropdownCore.defaultProps = {
|
|
|
1336
1402
|
},
|
|
1337
1403
|
selectionType: "single"
|
|
1338
1404
|
};
|
|
1339
|
-
const
|
|
1405
|
+
const theme$3 = {
|
|
1406
|
+
dropdown: {
|
|
1407
|
+
color: {
|
|
1408
|
+
default: {
|
|
1409
|
+
background: semanticColor.surface.primary,
|
|
1410
|
+
border: semanticColor.border.primary
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
},
|
|
1414
|
+
noResults: {
|
|
1415
|
+
color: {
|
|
1416
|
+
foreground: semanticColor.text.secondary
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
};
|
|
1420
|
+
const styles$6 = StyleSheet.create({
|
|
1340
1421
|
menuWrapper: {
|
|
1341
1422
|
width: "fit-content"
|
|
1342
1423
|
},
|
|
1343
1424
|
dropdown: {
|
|
1344
|
-
backgroundColor: color.
|
|
1345
|
-
borderRadius:
|
|
1425
|
+
backgroundColor: theme$3.dropdown.color.default.background,
|
|
1426
|
+
borderRadius: border.radius.medium_4,
|
|
1346
1427
|
paddingTop: spacing.xxxSmall_4,
|
|
1347
1428
|
paddingBottom: spacing.xxxSmall_4,
|
|
1348
|
-
border: `solid 1px ${color.
|
|
1349
|
-
boxShadow: `0px 8px 8px 0px ${
|
|
1429
|
+
border: `solid 1px ${theme$3.dropdown.color.default.border}`,
|
|
1430
|
+
boxShadow: `0px 8px 8px 0px ${color.offBlack8}`,
|
|
1350
1431
|
maxHeight: "var(--popper-max-height)"
|
|
1351
1432
|
},
|
|
1352
1433
|
listboxOrMenu: {
|
|
@@ -1357,7 +1438,7 @@ const styles$7 = StyleSheet.create({
|
|
|
1357
1438
|
visibility: "hidden"
|
|
1358
1439
|
},
|
|
1359
1440
|
noResult: {
|
|
1360
|
-
color: color.
|
|
1441
|
+
color: theme$3.noResults.color.foreground,
|
|
1361
1442
|
alignSelf: "center",
|
|
1362
1443
|
marginTop: spacing.xxSmall_6
|
|
1363
1444
|
},
|
|
@@ -1396,10 +1477,8 @@ class ActionMenuOpenerCore extends React.Component {
|
|
|
1396
1477
|
"aria-label": ariaLabel
|
|
1397
1478
|
} = _this$props,
|
|
1398
1479
|
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded$4);
|
|
1399
|
-
const buttonColor = color.blue;
|
|
1400
|
-
const buttonStyles = _generateStyles$1(buttonColor);
|
|
1401
1480
|
const disabled = disabledProp;
|
|
1402
|
-
const defaultStyle = [sharedStyles.shared,
|
|
1481
|
+
const defaultStyle = [sharedStyles.shared, sharedStyles.default, disabled && sharedStyles.disabled, !disabled && pressed && sharedStyles.press];
|
|
1403
1482
|
const label = React.createElement(LabelLarge, {
|
|
1404
1483
|
style: sharedStyles.text
|
|
1405
1484
|
}, children);
|
|
@@ -1413,7 +1492,7 @@ class ActionMenuOpenerCore extends React.Component {
|
|
|
1413
1492
|
}, restProps, {
|
|
1414
1493
|
"data-testid": testId
|
|
1415
1494
|
}), React.createElement(View, {
|
|
1416
|
-
style: !disabled && (hovered || focused) &&
|
|
1495
|
+
style: !disabled && (hovered || focused) && sharedStyles.focus
|
|
1417
1496
|
}, label), React.createElement(Strut, {
|
|
1418
1497
|
size: spacing.xxxSmall_4
|
|
1419
1498
|
}), React.createElement(PhosphorIcon, {
|
|
@@ -1424,6 +1503,22 @@ class ActionMenuOpenerCore extends React.Component {
|
|
|
1424
1503
|
}));
|
|
1425
1504
|
}
|
|
1426
1505
|
}
|
|
1506
|
+
const theme$2 = {
|
|
1507
|
+
actionMenuOpener: {
|
|
1508
|
+
color: {
|
|
1509
|
+
default: {
|
|
1510
|
+
background: "none",
|
|
1511
|
+
foreground: semanticColor.action.secondary.progressive.default.foreground
|
|
1512
|
+
},
|
|
1513
|
+
disabled: {
|
|
1514
|
+
foreground: semanticColor.action.secondary.disabled.foreground
|
|
1515
|
+
},
|
|
1516
|
+
press: {
|
|
1517
|
+
foreground: semanticColor.action.secondary.progressive.press.foreground
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1427
1522
|
const sharedStyles = StyleSheet.create({
|
|
1428
1523
|
shared: {
|
|
1429
1524
|
position: "relative",
|
|
@@ -1442,8 +1537,13 @@ const sharedStyles = StyleSheet.create({
|
|
|
1442
1537
|
WebkitTapHighlightColor: "rgba(0,0,0,0)"
|
|
1443
1538
|
}
|
|
1444
1539
|
},
|
|
1540
|
+
default: {
|
|
1541
|
+
background: theme$2.actionMenuOpener.color.default.background,
|
|
1542
|
+
color: theme$2.actionMenuOpener.color.default.foreground
|
|
1543
|
+
},
|
|
1445
1544
|
disabled: {
|
|
1446
|
-
|
|
1545
|
+
color: theme$2.actionMenuOpener.color.disabled.foreground,
|
|
1546
|
+
cursor: "not-allowed"
|
|
1447
1547
|
},
|
|
1448
1548
|
small: {
|
|
1449
1549
|
height: spacing.xLarge_32
|
|
@@ -1459,52 +1559,22 @@ const sharedStyles = StyleSheet.create({
|
|
|
1459
1559
|
textOverflow: "ellipsis",
|
|
1460
1560
|
pointerEvents: "none"
|
|
1461
1561
|
},
|
|
1462
|
-
|
|
1463
|
-
|
|
1562
|
+
focus: {
|
|
1563
|
+
":after": {
|
|
1564
|
+
content: "''",
|
|
1565
|
+
position: "absolute",
|
|
1566
|
+
height: 2,
|
|
1567
|
+
left: 0,
|
|
1568
|
+
right: 0,
|
|
1569
|
+
bottom: -1,
|
|
1570
|
+
background: "currentColor",
|
|
1571
|
+
borderRadius: border.radius.xSmall_2
|
|
1572
|
+
}
|
|
1464
1573
|
},
|
|
1465
|
-
|
|
1466
|
-
|
|
1574
|
+
press: {
|
|
1575
|
+
color: theme$2.actionMenuOpener.color.press.foreground
|
|
1467
1576
|
}
|
|
1468
1577
|
});
|
|
1469
|
-
const styles$6 = {};
|
|
1470
|
-
const _generateStyles$1 = localColor => {
|
|
1471
|
-
const buttonType = localColor;
|
|
1472
|
-
if (styles$6[buttonType]) {
|
|
1473
|
-
return styles$6[buttonType];
|
|
1474
|
-
}
|
|
1475
|
-
const {
|
|
1476
|
-
offBlack32
|
|
1477
|
-
} = color;
|
|
1478
|
-
const activeColor = color.activeBlue;
|
|
1479
|
-
let newStyles = {};
|
|
1480
|
-
newStyles = {
|
|
1481
|
-
default: {
|
|
1482
|
-
background: "none",
|
|
1483
|
-
color: localColor
|
|
1484
|
-
},
|
|
1485
|
-
focus: {
|
|
1486
|
-
":after": {
|
|
1487
|
-
content: "''",
|
|
1488
|
-
position: "absolute",
|
|
1489
|
-
height: 2,
|
|
1490
|
-
left: 0,
|
|
1491
|
-
right: 0,
|
|
1492
|
-
bottom: -1,
|
|
1493
|
-
background: "currentColor",
|
|
1494
|
-
borderRadius: 2
|
|
1495
|
-
}
|
|
1496
|
-
},
|
|
1497
|
-
active: {
|
|
1498
|
-
color: activeColor
|
|
1499
|
-
},
|
|
1500
|
-
disabled: {
|
|
1501
|
-
color: offBlack32,
|
|
1502
|
-
cursor: "default"
|
|
1503
|
-
}
|
|
1504
|
-
};
|
|
1505
|
-
styles$6[buttonType] = StyleSheet.create(newStyles);
|
|
1506
|
-
return styles$6[buttonType];
|
|
1507
|
-
};
|
|
1508
1578
|
|
|
1509
1579
|
const _excluded$3 = ["text", "opened"];
|
|
1510
1580
|
class ActionMenu extends React.Component {
|
|
@@ -1676,7 +1746,7 @@ const styles$5 = StyleSheet.create({
|
|
|
1676
1746
|
}
|
|
1677
1747
|
});
|
|
1678
1748
|
|
|
1679
|
-
const _excluded$2 = ["children", "disabled", "error", "id", "isPlaceholder", "open", "testId", "aria-label", "aria-required", "onBlur", "onOpenChanged"];
|
|
1749
|
+
const _excluded$2 = ["children", "disabled", "error", "id", "isPlaceholder", "open", "testId", "aria-label", "aria-required", "aria-controls", "onBlur", "onOpenChanged"];
|
|
1680
1750
|
const StyledButton = addStyle("button");
|
|
1681
1751
|
class SelectOpener extends React.Component {
|
|
1682
1752
|
constructor(props) {
|
|
@@ -1721,11 +1791,12 @@ class SelectOpener extends React.Component {
|
|
|
1721
1791
|
testId,
|
|
1722
1792
|
"aria-label": ariaLabel,
|
|
1723
1793
|
"aria-required": ariaRequired,
|
|
1794
|
+
"aria-controls": ariaControls,
|
|
1724
1795
|
onBlur
|
|
1725
1796
|
} = _this$props,
|
|
1726
1797
|
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$2);
|
|
1727
1798
|
const stateStyles = _generateStyles(isPlaceholder, error);
|
|
1728
|
-
const iconColor = disabled ? semanticColor.
|
|
1799
|
+
const iconColor = disabled ? semanticColor.icon.disabled : semanticColor.icon.primary;
|
|
1729
1800
|
const style = [styles$4.shared, stateStyles.default, disabled && stateStyles.disabled, !disabled && this.state.pressed && stateStyles.press];
|
|
1730
1801
|
return React.createElement(StyledButton, _extends({}, sharedProps, {
|
|
1731
1802
|
"aria-disabled": disabled,
|
|
@@ -1734,6 +1805,7 @@ class SelectOpener extends React.Component {
|
|
|
1734
1805
|
"aria-label": ariaLabel != null ? ariaLabel : undefined,
|
|
1735
1806
|
"aria-required": ariaRequired,
|
|
1736
1807
|
"aria-haspopup": "listbox",
|
|
1808
|
+
"aria-controls": ariaControls,
|
|
1737
1809
|
"data-testid": testId,
|
|
1738
1810
|
id: id,
|
|
1739
1811
|
role: "combobox",
|
|
@@ -1804,8 +1876,8 @@ const _generateStyles = (placeholder, error) => {
|
|
|
1804
1876
|
foreground: semanticColor.text.primary
|
|
1805
1877
|
},
|
|
1806
1878
|
disabled: {
|
|
1807
|
-
border: semanticColor.border
|
|
1808
|
-
background: semanticColor.action.disabled.
|
|
1879
|
+
border: semanticColor.action.secondary.disabled.border,
|
|
1880
|
+
background: semanticColor.action.secondary.disabled.background,
|
|
1809
1881
|
foreground: semanticColor.text.secondary
|
|
1810
1882
|
},
|
|
1811
1883
|
error: {
|
|
@@ -1815,18 +1887,21 @@ const _generateStyles = (placeholder, error) => {
|
|
|
1815
1887
|
}
|
|
1816
1888
|
};
|
|
1817
1889
|
const actionType = error ? "destructive" : "progressive";
|
|
1818
|
-
const action = semanticColor.action.
|
|
1890
|
+
const action = semanticColor.action.secondary[actionType];
|
|
1819
1891
|
const sharedOutlineStyling = {
|
|
1820
1892
|
outlineOffset: -border.width.thin,
|
|
1821
1893
|
outlineStyle: "solid",
|
|
1822
1894
|
outlineWidth: border.width.thin
|
|
1823
1895
|
};
|
|
1824
|
-
const
|
|
1896
|
+
const focusStyling = _extends({}, sharedOutlineStyling, {
|
|
1897
|
+
outlineColor: semanticColor.focus.outer
|
|
1898
|
+
});
|
|
1899
|
+
const hoverStyling = _extends({}, sharedOutlineStyling, {
|
|
1825
1900
|
outlineColor: action.hover.border
|
|
1826
|
-
}
|
|
1901
|
+
});
|
|
1827
1902
|
const pressStyling = _extends({
|
|
1828
1903
|
background: action.press.background,
|
|
1829
|
-
color: placeholder ? error ? semanticColor.text.secondary : semanticColor.action.
|
|
1904
|
+
color: placeholder ? error ? semanticColor.text.secondary : semanticColor.action.secondary.progressive.press.foreground : semanticColor.text.primary,
|
|
1830
1905
|
outlineColor: action.press.border
|
|
1831
1906
|
}, sharedOutlineStyling);
|
|
1832
1907
|
const currentState = error ? states.error : states.default;
|
|
@@ -1836,7 +1911,7 @@ const _generateStyles = (placeholder, error) => {
|
|
|
1836
1911
|
borderColor: currentState.border,
|
|
1837
1912
|
borderWidth: border.width.hairline,
|
|
1838
1913
|
color: placeholder ? semanticColor.text.secondary : currentState.foreground,
|
|
1839
|
-
":hover:not([aria-disabled=true])":
|
|
1914
|
+
":hover:not([aria-disabled=true])": hoverStyling,
|
|
1840
1915
|
["@media not (hover: hover)"]: {
|
|
1841
1916
|
":hover:not([aria-disabled=true])": {
|
|
1842
1917
|
borderColor: currentState.border,
|
|
@@ -1845,7 +1920,7 @@ const _generateStyles = (placeholder, error) => {
|
|
|
1845
1920
|
paddingRight: spacing.small_12
|
|
1846
1921
|
}
|
|
1847
1922
|
},
|
|
1848
|
-
":focus-visible:not([aria-disabled=true])":
|
|
1923
|
+
":focus-visible:not([aria-disabled=true])": focusStyling,
|
|
1849
1924
|
":active:not([aria-disabled=true])": pressStyling
|
|
1850
1925
|
},
|
|
1851
1926
|
disabled: {
|
|
@@ -1854,7 +1929,7 @@ const _generateStyles = (placeholder, error) => {
|
|
|
1854
1929
|
color: states.disabled.foreground,
|
|
1855
1930
|
cursor: "not-allowed",
|
|
1856
1931
|
":focus-visible": _extends({
|
|
1857
|
-
outlineColor: semanticColor.
|
|
1932
|
+
outlineColor: semanticColor.focus.outer
|
|
1858
1933
|
}, sharedOutlineStyling)
|
|
1859
1934
|
},
|
|
1860
1935
|
press: pressStyling
|
|
@@ -2773,7 +2848,7 @@ const styles$2 = StyleSheet.create({
|
|
|
2773
2848
|
paddingInlineEnd: spacing.xxxSmall_4
|
|
2774
2849
|
},
|
|
2775
2850
|
pillFocused: {
|
|
2776
|
-
outline: `1px solid ${
|
|
2851
|
+
outline: `1px solid ${semanticColor.focus.outer}`
|
|
2777
2852
|
}
|
|
2778
2853
|
});
|
|
2779
2854
|
|
|
@@ -2858,12 +2933,21 @@ function Listbox(props) {
|
|
|
2858
2933
|
"aria-multiselectable": selectionType === "multiple"
|
|
2859
2934
|
}, children);
|
|
2860
2935
|
}
|
|
2936
|
+
const theme$1 = {
|
|
2937
|
+
listbox: {
|
|
2938
|
+
color: {
|
|
2939
|
+
disabled: {
|
|
2940
|
+
foreground: semanticColor.action.secondary.disabled.foreground
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
};
|
|
2861
2945
|
const styles$1 = StyleSheet.create({
|
|
2862
2946
|
listbox: {
|
|
2863
2947
|
outline: "none"
|
|
2864
2948
|
},
|
|
2865
2949
|
disabled: {
|
|
2866
|
-
color: color.
|
|
2950
|
+
color: theme$1.listbox.color.disabled.foreground
|
|
2867
2951
|
}
|
|
2868
2952
|
});
|
|
2869
2953
|
|
|
@@ -3031,7 +3115,7 @@ function Combobox({
|
|
|
3031
3115
|
const startIconElement = React.cloneElement(startIcon, _extends({
|
|
3032
3116
|
size: "small"
|
|
3033
3117
|
}, startIcon.props, {
|
|
3034
|
-
color: disabled ?
|
|
3118
|
+
color: disabled ? semanticColor.icon.disabled : (_startIcon$props$colo = startIcon.props.color) != null ? _startIcon$props$colo : semanticColor.icon.primary
|
|
3035
3119
|
}));
|
|
3036
3120
|
return React.createElement(View, {
|
|
3037
3121
|
style: styles.iconWrapper
|
|
@@ -3140,6 +3224,38 @@ function Combobox({
|
|
|
3140
3224
|
}, renderList));
|
|
3141
3225
|
}));
|
|
3142
3226
|
}
|
|
3227
|
+
const theme = {
|
|
3228
|
+
combobox: {
|
|
3229
|
+
color: {
|
|
3230
|
+
default: {
|
|
3231
|
+
border: semanticColor.border.strong,
|
|
3232
|
+
background: semanticColor.surface.primary
|
|
3233
|
+
},
|
|
3234
|
+
focus: {
|
|
3235
|
+
border: semanticColor.focus.outer,
|
|
3236
|
+
background: semanticColor.surface.primary
|
|
3237
|
+
},
|
|
3238
|
+
disabled: {
|
|
3239
|
+
border: semanticColor.action.secondary.disabled.border,
|
|
3240
|
+
background: semanticColor.action.secondary.disabled.background,
|
|
3241
|
+
foreground: semanticColor.action.secondary.disabled.foreground
|
|
3242
|
+
},
|
|
3243
|
+
error: {
|
|
3244
|
+
border: semanticColor.status.critical.foreground,
|
|
3245
|
+
background: semanticColor.status.critical.background,
|
|
3246
|
+
foreground: semanticColor.text.primary
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
},
|
|
3250
|
+
listbox: {
|
|
3251
|
+
color: {
|
|
3252
|
+
default: {
|
|
3253
|
+
background: semanticColor.surface.primary,
|
|
3254
|
+
border: semanticColor.border.primary
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
};
|
|
3143
3259
|
const styles = StyleSheet.create({
|
|
3144
3260
|
wrapper: {
|
|
3145
3261
|
flexDirection: "row",
|
|
@@ -3147,24 +3263,24 @@ const styles = StyleSheet.create({
|
|
|
3147
3263
|
width: "100%",
|
|
3148
3264
|
maxWidth: "100%",
|
|
3149
3265
|
flexWrap: "wrap",
|
|
3150
|
-
background: color.
|
|
3266
|
+
background: theme.combobox.color.default.background,
|
|
3151
3267
|
borderRadius: border.radius.medium_4,
|
|
3152
|
-
border: `solid 1px ${color.
|
|
3268
|
+
border: `solid 1px ${theme.combobox.color.default.border}`,
|
|
3153
3269
|
paddingInline: spacing.xSmall_8
|
|
3154
3270
|
},
|
|
3155
3271
|
focused: {
|
|
3156
|
-
background: color.
|
|
3157
|
-
border: `1px solid ${color.
|
|
3272
|
+
background: theme.combobox.color.focus.background,
|
|
3273
|
+
border: `1px solid ${theme.combobox.color.focus.border}`
|
|
3158
3274
|
},
|
|
3159
3275
|
disabled: {
|
|
3160
|
-
background: color.
|
|
3161
|
-
border: `1px solid ${color.
|
|
3162
|
-
color: color.
|
|
3276
|
+
background: theme.combobox.color.disabled.background,
|
|
3277
|
+
border: `1px solid ${theme.combobox.color.disabled.border}`,
|
|
3278
|
+
color: theme.combobox.color.disabled.foreground
|
|
3163
3279
|
},
|
|
3164
3280
|
error: {
|
|
3165
|
-
background: color.
|
|
3166
|
-
border: `1px solid ${color.
|
|
3167
|
-
color: color.
|
|
3281
|
+
background: theme.combobox.color.error.background,
|
|
3282
|
+
border: `1px solid ${theme.combobox.color.error.border}`,
|
|
3283
|
+
color: theme.combobox.color.error.foreground
|
|
3168
3284
|
},
|
|
3169
3285
|
combobox: {
|
|
3170
3286
|
appearance: "none",
|
|
@@ -3182,9 +3298,9 @@ const styles = StyleSheet.create({
|
|
|
3182
3298
|
}
|
|
3183
3299
|
},
|
|
3184
3300
|
listbox: {
|
|
3185
|
-
backgroundColor: color.
|
|
3301
|
+
backgroundColor: theme.listbox.color.default.background,
|
|
3186
3302
|
borderRadius: border.radius.medium_4,
|
|
3187
|
-
border: `solid
|
|
3303
|
+
border: `solid ${border.width.hairline}px ${theme.listbox.color.default.border}`,
|
|
3188
3304
|
boxShadow: `0px ${spacing.xSmall_8}px ${spacing.xSmall_8}px 0px ${color.offBlack8}`,
|
|
3189
3305
|
maxHeight: "var(--popper-max-height)",
|
|
3190
3306
|
overflowY: "auto"
|