@box/blueprint-web 7.19.12 → 7.20.0
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.
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { SelectItemCheck, SelectItem, ComboboxItem, useComboboxStore, useSelectStore, PopoverAnchor, Combobox as Combobox$1, SelectList, ComboboxPopover } from '@ariakit/react';
|
|
2
|
+
import { SelectItemCheck, SelectItem, ComboboxItem, useComboboxStore, useSelectStore, PopoverAnchor, Combobox as Combobox$1, ComboboxCancel, SelectList, ComboboxPopover } from '@ariakit/react';
|
|
3
3
|
import { SelectRenderer } from '@ariakit/react-core/select/select-renderer';
|
|
4
|
-
import { Checkmark } from '@box/blueprint-web-assets/icons/Fill';
|
|
4
|
+
import { Checkmark, XMark } from '@box/blueprint-web-assets/icons/Fill';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import React__default, { forwardRef, useMemo, useRef, useCallback, useEffect } from 'react';
|
|
7
7
|
import { InputChip } from '../input-chip/input-chip.js';
|
|
8
8
|
import { LoadingIndicator } from '../loading-indicator/loading-indicator.js';
|
|
9
|
+
import { IconButton } from '../primitives/icon-button/icon-button.js';
|
|
9
10
|
import { InlineError } from '../primitives/inline-error/inline-error.js';
|
|
10
11
|
import { TextArea } from '../text-area/text-area.js';
|
|
11
12
|
import { useForkRef } from '../utils/useForkRef.js';
|
|
@@ -67,6 +68,8 @@ const RootInner = ({
|
|
|
67
68
|
experimentalVirtualization = false,
|
|
68
69
|
getPopoverRef,
|
|
69
70
|
focusLoop,
|
|
71
|
+
clearButtonAriaLabel,
|
|
72
|
+
endComboboxIcon,
|
|
70
73
|
...comboboxProps
|
|
71
74
|
} = rest;
|
|
72
75
|
const isInput = useMemo(() => as === 'input', [as]);
|
|
@@ -139,6 +142,9 @@ const RootInner = ({
|
|
|
139
142
|
const {
|
|
140
143
|
setValue: setSelectedValue
|
|
141
144
|
} = selectStore;
|
|
145
|
+
const resetSelectedValue = useCallback(() => {
|
|
146
|
+
setSelectedValue(multiselect ? [] : '');
|
|
147
|
+
}, [multiselect, setSelectedValue]);
|
|
142
148
|
const filteredOptions = useMemo(() => {
|
|
143
149
|
const visibleOptions = filterFn ? options.filter(option => filterFn(inputValue, option)) : options;
|
|
144
150
|
if (!hideSelectedOptions) {
|
|
@@ -194,10 +200,10 @@ const RootInner = ({
|
|
|
194
200
|
return;
|
|
195
201
|
}
|
|
196
202
|
setInputValue('');
|
|
197
|
-
|
|
203
|
+
resetSelectedValue();
|
|
198
204
|
}
|
|
199
205
|
}
|
|
200
|
-
}, [clearOnEscape, isOpen,
|
|
206
|
+
}, [clearOnEscape, isOpen, resetSelectedValue, setInputValue, setOpen]);
|
|
201
207
|
// Reset input on blur
|
|
202
208
|
const handleOnBlur = useCallback(() => {
|
|
203
209
|
if (!clearOnBlur || isOpen) {
|
|
@@ -229,6 +235,7 @@ const RootInner = ({
|
|
|
229
235
|
};
|
|
230
236
|
const reference = useForkRef(inputRef, ref);
|
|
231
237
|
const showChipsGroup = Array.isArray(selectedValue) && selectedValue.length > 0;
|
|
238
|
+
const showComboboxCancelButton = clearButtonAriaLabel && (inputValue.length > 0 || (Array.isArray(selectedValue) ? selectedValue.length > 0 : !!selectedValue));
|
|
232
239
|
const inputComponent = isInput ? jsxs(Fragment, {
|
|
233
240
|
children: [jsx("label", {
|
|
234
241
|
className: clsx(styles.label, {
|
|
@@ -243,7 +250,8 @@ const RootInner = ({
|
|
|
243
250
|
children: jsxs("div", {
|
|
244
251
|
className: clsx(styles.comboboxContainer, {
|
|
245
252
|
[styles.error]: hasError,
|
|
246
|
-
[styles.withChipsGroup]: showChipsGroup
|
|
253
|
+
[styles.withChipsGroup]: showChipsGroup,
|
|
254
|
+
[styles.withComboboxButtons]: showComboboxCancelButton || Boolean(endComboboxIcon)
|
|
247
255
|
}),
|
|
248
256
|
children: [showChipsGroup && jsx(ChipsGroup, {
|
|
249
257
|
children: selectedValue.map(selected => jsx(InputChip, {
|
|
@@ -252,9 +260,9 @@ const RootInner = ({
|
|
|
252
260
|
onDelete: () => removeInputChip(selected),
|
|
253
261
|
tooltip: getTooltipValueFromOptionValue(selected, options, displayTooltip)
|
|
254
262
|
}, selected))
|
|
255
|
-
}),
|
|
263
|
+
}), jsxs("div", {
|
|
256
264
|
className: styles.textInputWrapper,
|
|
257
|
-
children: jsx(Combobox$1, {
|
|
265
|
+
children: [jsx(Combobox$1, {
|
|
258
266
|
...comboboxProps,
|
|
259
267
|
ref: reference,
|
|
260
268
|
"aria-invalid": hasError,
|
|
@@ -268,7 +276,20 @@ const RootInner = ({
|
|
|
268
276
|
onKeyDown: handleKeyDown,
|
|
269
277
|
required: required,
|
|
270
278
|
store: comboboxStore
|
|
271
|
-
})
|
|
279
|
+
}), jsx("div", {
|
|
280
|
+
className: styles.comboboxButtons,
|
|
281
|
+
children: showComboboxCancelButton ? jsx(ComboboxCancel, {
|
|
282
|
+
onClick: resetSelectedValue,
|
|
283
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
284
|
+
render: cancelProps => jsx(IconButton, {
|
|
285
|
+
...cancelProps,
|
|
286
|
+
"aria-label": clearButtonAriaLabel,
|
|
287
|
+
icon: XMark,
|
|
288
|
+
size: "x-small"
|
|
289
|
+
}),
|
|
290
|
+
store: comboboxStore
|
|
291
|
+
}) : endComboboxIcon
|
|
292
|
+
})]
|
|
272
293
|
})]
|
|
273
294
|
})
|
|
274
295
|
}), jsx(InlineError, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"container":"bp_combobox_module_container--
|
|
2
|
+
var styles = {"container":"bp_combobox_module_container--40e62","disabled":"bp_combobox_module_disabled--40e62","label":"bp_combobox_module_label--40e62","hiddenLabel":"bp_combobox_module_hiddenLabel--40e62","comboboxContainer":"bp_combobox_module_comboboxContainer--40e62","withComboboxButtons":"bp_combobox_module_withComboboxButtons--40e62","error":"bp_combobox_module_error--40e62","textInputWrapper":"bp_combobox_module_textInputWrapper--40e62","textInput":"bp_combobox_module_textInput--40e62","errorIcon":"bp_combobox_module_errorIcon--40e62","comboboxButtons":"bp_combobox_module_comboboxButtons--40e62","withChipsGroup":"bp_combobox_module_withChipsGroup--40e62","inlineError":"bp_combobox_module_inlineError--40e62","popover":"bp_combobox_module_popover--40e62","option":"bp_combobox_module_option--40e62","indicator":"bp_combobox_module_indicator--40e62","indicatorIcon":"bp_combobox_module_indicatorIcon--40e62","optionWithIndicator":"bp_combobox_module_optionWithIndicator--40e62","loadingIndicator":"bp_combobox_module_loadingIndicator--40e62","noResultOption":"bp_combobox_module_noResultOption--40e62"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -188,6 +188,15 @@ export interface ComboboxBaseProps<Multiple extends boolean, FreeInput extends b
|
|
|
188
188
|
* Callback used when combobox input/textarea is focused
|
|
189
189
|
*/
|
|
190
190
|
onFocus?: () => void;
|
|
191
|
+
/**
|
|
192
|
+
* aria-label passed to the Combobox clear button. If not provided, the clear button is not shown.
|
|
193
|
+
*/
|
|
194
|
+
clearButtonAriaLabel?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Instance of an icon to be rendered at the end of the combobox input. When used in combination with `clearButtonAriaLabel`,
|
|
197
|
+
* it dissapears when the input is not empty
|
|
198
|
+
*/
|
|
199
|
+
endComboboxIcon?: React.ReactNode;
|
|
191
200
|
}
|
|
192
201
|
export type ComboboxTextArea = Pick<TextAreaProps, 'maxRows' | 'minRows' | 'maxLength'> & {
|
|
193
202
|
as: 'textarea';
|
package/lib-esm/index.css
CHANGED
|
@@ -1515,7 +1515,7 @@
|
|
|
1515
1515
|
max-width:100%;
|
|
1516
1516
|
}
|
|
1517
1517
|
|
|
1518
|
-
.bp_combobox_module_container--
|
|
1518
|
+
.bp_combobox_module_container--40e62{
|
|
1519
1519
|
display:flex;
|
|
1520
1520
|
flex-direction:column;
|
|
1521
1521
|
font-family:Lato, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
|
|
@@ -1526,10 +1526,10 @@
|
|
|
1526
1526
|
text-decoration:none;
|
|
1527
1527
|
text-transform:none;
|
|
1528
1528
|
}
|
|
1529
|
-
.bp_combobox_module_container--
|
|
1529
|
+
.bp_combobox_module_container--40e62.bp_combobox_module_disabled--40e62{
|
|
1530
1530
|
opacity:60%;
|
|
1531
1531
|
}
|
|
1532
|
-
.bp_combobox_module_container--
|
|
1532
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_label--40e62{
|
|
1533
1533
|
color:var(--text-text-on-light);
|
|
1534
1534
|
flex:0 0 fit-content;
|
|
1535
1535
|
font-family:Lato, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
|
|
@@ -1541,10 +1541,10 @@
|
|
|
1541
1541
|
text-decoration:none;
|
|
1542
1542
|
text-transform:none;
|
|
1543
1543
|
}
|
|
1544
|
-
.bp_combobox_module_container--
|
|
1544
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_label--40e62:not(.bp_combobox_module_hiddenLabel--40e62){
|
|
1545
1545
|
margin-block-end:var(--space-2);
|
|
1546
1546
|
}
|
|
1547
|
-
.bp_combobox_module_container--
|
|
1547
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62{
|
|
1548
1548
|
background-color:var(--surface-dropdown-surface);
|
|
1549
1549
|
border:var(--border-1) solid var(--border-input-border);
|
|
1550
1550
|
border-radius:var(--blueprint-combobox-input-radius, var(--radius-2));
|
|
@@ -1557,22 +1557,25 @@
|
|
|
1557
1557
|
padding-inline:var(--space-3);
|
|
1558
1558
|
position:relative;
|
|
1559
1559
|
}
|
|
1560
|
-
.bp_combobox_module_container--
|
|
1560
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62.bp_combobox_module_withComboboxButtons--40e62{
|
|
1561
|
+
padding-inline-end:var(--space-10);
|
|
1562
|
+
}
|
|
1563
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62:not(.bp_combobox_module_error--40e62):has(input:focus),.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62:not(.bp_combobox_module_error--40e62):has(input[data-focus-visible]:focus){
|
|
1561
1564
|
border-color:#0000;
|
|
1562
1565
|
box-shadow:0 0 0 var(--border-2) var(--outline-focus-on-light);
|
|
1563
1566
|
}
|
|
1564
|
-
.bp_combobox_module_container--
|
|
1567
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62:not(:disabled).bp_combobox_module_error--40e62{
|
|
1565
1568
|
background-color:var(--surface-dropdown-surface-error);
|
|
1566
1569
|
border:var(--border-2) solid var(--border-input-border-error);
|
|
1567
1570
|
padding-block:calc((2.5rem - var(--space-5))/2 - var(--border-2));
|
|
1568
1571
|
}
|
|
1569
|
-
.bp_combobox_module_container--
|
|
1572
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62 .bp_combobox_module_textInputWrapper--40e62{
|
|
1570
1573
|
align-items:center;
|
|
1571
1574
|
display:flex;
|
|
1572
1575
|
flex:content;
|
|
1573
1576
|
gap:var(--space-2);
|
|
1574
1577
|
}
|
|
1575
|
-
.bp_combobox_module_container--
|
|
1578
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62 .bp_combobox_module_textInputWrapper--40e62 .bp_combobox_module_textInput--40e62{
|
|
1576
1579
|
background-color:initial;
|
|
1577
1580
|
border:none;
|
|
1578
1581
|
color:var(--text-text-on-light);
|
|
@@ -1588,21 +1591,28 @@
|
|
|
1588
1591
|
text-transform:none;
|
|
1589
1592
|
width:100%;
|
|
1590
1593
|
}
|
|
1591
|
-
.bp_combobox_module_container--
|
|
1594
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62 .bp_combobox_module_textInputWrapper--40e62 .bp_combobox_module_errorIcon--40e62 path{
|
|
1592
1595
|
fill:var(--icon-icon-error-on-light);
|
|
1593
1596
|
}
|
|
1594
|
-
.bp_combobox_module_container--
|
|
1597
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62 .bp_combobox_module_textInputWrapper--40e62 .bp_combobox_module_comboboxButtons--40e62{
|
|
1598
|
+
align-items:center;
|
|
1599
|
+
display:flex;
|
|
1600
|
+
position:absolute;
|
|
1601
|
+
right:var(--space-2);
|
|
1602
|
+
top:var(--space-2);
|
|
1603
|
+
}
|
|
1604
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62.bp_combobox_module_withChipsGroup--40e62{
|
|
1595
1605
|
max-height:calc(var(--space-2)*2 + var(--space-6)*3);
|
|
1596
1606
|
padding-block:calc((2.5rem - var(--space-7))/2 - var(--border-1));
|
|
1597
1607
|
}
|
|
1598
|
-
.bp_combobox_module_container--
|
|
1608
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_comboboxContainer--40e62.bp_combobox_module_withChipsGroup--40e62:not(:disabled).bp_combobox_module_error--40e62{
|
|
1599
1609
|
padding-block:calc((2.5rem - var(--space-7))/2 - var(--border-2));
|
|
1600
1610
|
}
|
|
1601
|
-
.bp_combobox_module_container--
|
|
1611
|
+
.bp_combobox_module_container--40e62 .bp_combobox_module_inlineError--40e62{
|
|
1602
1612
|
margin-block-start:var(--space-2);
|
|
1603
1613
|
}
|
|
1604
1614
|
|
|
1605
|
-
.bp_combobox_module_popover--
|
|
1615
|
+
.bp_combobox_module_popover--40e62{
|
|
1606
1616
|
background-color:var(--surface-menu-surface);
|
|
1607
1617
|
border:var(--border-1) solid var(--border-card-border);
|
|
1608
1618
|
border-radius:var(--radius-3);
|
|
@@ -1620,7 +1630,7 @@
|
|
|
1620
1630
|
text-transform:none;
|
|
1621
1631
|
z-index:380;
|
|
1622
1632
|
}
|
|
1623
|
-
.bp_combobox_module_popover--
|
|
1633
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_option--40e62{
|
|
1624
1634
|
border:var(--border-2) solid #0000;
|
|
1625
1635
|
border-radius:var(--radius-3);
|
|
1626
1636
|
box-sizing:border-box;
|
|
@@ -1634,17 +1644,17 @@
|
|
|
1634
1644
|
user-select:none;
|
|
1635
1645
|
width:100%;
|
|
1636
1646
|
}
|
|
1637
|
-
.bp_combobox_module_popover--
|
|
1647
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_option--40e62[aria-disabled]{
|
|
1638
1648
|
opacity:60%;
|
|
1639
1649
|
}
|
|
1640
|
-
.bp_combobox_module_popover--
|
|
1650
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_option--40e62[data-active-item]:not([aria-disabled]){
|
|
1641
1651
|
background-color:var(--surface-menu-surface-focus);
|
|
1642
1652
|
border:var(--border-2) solid var(--outline-focus-on-light);
|
|
1643
1653
|
}
|
|
1644
|
-
.bp_combobox_module_popover--
|
|
1654
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_option--40e62:hover{
|
|
1645
1655
|
background-color:var(--surface-menu-surface-hover);
|
|
1646
1656
|
}
|
|
1647
|
-
.bp_combobox_module_popover--
|
|
1657
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_option--40e62 .bp_combobox_module_indicator--40e62{
|
|
1648
1658
|
align-items:center;
|
|
1649
1659
|
display:flex;
|
|
1650
1660
|
height:var(--size-9);
|
|
@@ -1653,16 +1663,16 @@
|
|
|
1653
1663
|
position:absolute;
|
|
1654
1664
|
top:0;
|
|
1655
1665
|
}
|
|
1656
|
-
.bp_combobox_module_popover--
|
|
1666
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_option--40e62 .bp_combobox_module_indicator--40e62 .bp_combobox_module_indicatorIcon--40e62 path{
|
|
1657
1667
|
fill:var(--icon-icon-on-light);
|
|
1658
1668
|
}
|
|
1659
|
-
.bp_combobox_module_popover--
|
|
1669
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_optionWithIndicator--40e62{
|
|
1660
1670
|
padding-inline:var(--space-10) var(--space-2);
|
|
1661
1671
|
}
|
|
1662
|
-
.bp_combobox_module_popover--
|
|
1672
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_loadingIndicator--40e62{
|
|
1663
1673
|
position:unset;
|
|
1664
1674
|
}
|
|
1665
|
-
.bp_combobox_module_popover--
|
|
1675
|
+
.bp_combobox_module_popover--40e62 .bp_combobox_module_noResultOption--40e62{
|
|
1666
1676
|
color:var(--text-text-on-light);
|
|
1667
1677
|
-webkit-user-select:none;
|
|
1668
1678
|
user-select:none;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"react-stately": "^3.31.1",
|
|
67
67
|
"tsx": "^4.16.5"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "194653f3af1b0b647738e4ee473940cad442bee8",
|
|
70
70
|
"module": "lib-esm/index.js",
|
|
71
71
|
"main": "lib-esm/index.js",
|
|
72
72
|
"exports": {
|