@box/blueprint-web 12.37.0 → 12.38.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.
- package/dist/lib-esm/combobox/combobox.js +12 -12
- package/dist/lib-esm/combobox/types.d.ts +6 -0
- package/dist/lib-esm/index.css +120 -52
- package/dist/lib-esm/input-chip/input-chip.js +12 -1
- package/dist/lib-esm/input-chip/input-chip.module.js +1 -1
- package/dist/lib-esm/input-chip/types.d.ts +1 -1
- package/dist/lib-esm/switch/switch-item.js +5 -0
- package/dist/lib-esm/switch/switch.module.js +1 -1
- package/package.json +1 -1
|
@@ -18,18 +18,15 @@ import styles from './combobox.module.js';
|
|
|
18
18
|
|
|
19
19
|
const getOptionValue = option => typeof option === 'string' ? option : option.value;
|
|
20
20
|
const getOptionFromValue = (value, options) => options.find(option => typeof option === 'string' ? option === value : option.value === value);
|
|
21
|
-
|
|
21
|
+
// Generic helper to apply a callback to an option looked up by value, with a fallback when callback is absent.
|
|
22
|
+
const applyOptionCallback = (optionValue, options, callback, fallback) => {
|
|
22
23
|
const option = getOptionFromValue(optionValue, options);
|
|
23
|
-
return
|
|
24
|
-
};
|
|
25
|
-
const getDisplayAvatarFromOptionValue = (optionValue, options, displayAvatar) => {
|
|
26
|
-
const option = getOptionFromValue(optionValue, options);
|
|
27
|
-
return displayAvatar && option ? displayAvatar(option) : undefined;
|
|
28
|
-
};
|
|
29
|
-
const getTooltipValueFromOptionValue = (optionValue, options, displayTooltip) => {
|
|
30
|
-
const option = getOptionFromValue(optionValue, options);
|
|
31
|
-
return displayTooltip && option ? displayTooltip(option) : undefined;
|
|
24
|
+
return callback && option ? callback(option) : fallback;
|
|
32
25
|
};
|
|
26
|
+
const getDisplayValueFromOptionValue = (optionValue, options, displayValue) => applyOptionCallback(optionValue, options, displayValue, optionValue);
|
|
27
|
+
const getDisplayAvatarFromOptionValue = (optionValue, options, displayAvatar) => applyOptionCallback(optionValue, options, displayAvatar, undefined);
|
|
28
|
+
const getTooltipValueFromOptionValue = (optionValue, options, displayTooltip) => applyOptionCallback(optionValue, options, displayTooltip, undefined);
|
|
29
|
+
const getDisplayChipVariantFromOptionValue = (optionValue, options, displayChipVariant) => applyOptionCallback(optionValue, options, displayChipVariant, 'default');
|
|
33
30
|
const RootInner = ({
|
|
34
31
|
as = 'input',
|
|
35
32
|
...props
|
|
@@ -60,6 +57,7 @@ const RootInner = ({
|
|
|
60
57
|
displayValue,
|
|
61
58
|
displayAvatar,
|
|
62
59
|
displayTooltip,
|
|
60
|
+
displayChipVariant,
|
|
63
61
|
hideOnEscape,
|
|
64
62
|
renderOption,
|
|
65
63
|
options,
|
|
@@ -333,12 +331,14 @@ const RootInner = ({
|
|
|
333
331
|
avatar: getDisplayAvatarFromOptionValue(selected, options, displayAvatar),
|
|
334
332
|
label: getDisplayValueFromOptionValue(selected, options, displayValue),
|
|
335
333
|
onDelete: () => removeMultiSelectInputChip(selected),
|
|
336
|
-
tooltip: getTooltipValueFromOptionValue(selected, options, displayTooltip)
|
|
334
|
+
tooltip: getTooltipValueFromOptionValue(selected, options, displayTooltip),
|
|
335
|
+
variant: getDisplayChipVariantFromOptionValue(selected, options, displayChipVariant)
|
|
337
336
|
}, selected))
|
|
338
337
|
}), showSingleSelectChip && jsx(InputChip, {
|
|
339
338
|
label: getDisplayValueFromOptionValue(selectedValue, options, displayValue),
|
|
340
339
|
onDelete: showComboboxCancelButton ? undefined : removeSingleSelectInputChip,
|
|
341
|
-
tooltip: getTooltipValueFromOptionValue(selectedValue, options, displayTooltip)
|
|
340
|
+
tooltip: getTooltipValueFromOptionValue(selectedValue, options, displayTooltip),
|
|
341
|
+
variant: getDisplayChipVariantFromOptionValue(selectedValue, options, displayChipVariant)
|
|
342
342
|
}), jsxs("div", {
|
|
343
343
|
className: styles.textInputWrapper,
|
|
344
344
|
children: [jsx(Combobox$1, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ComboboxPopoverProps } from '@ariakit/react';
|
|
2
2
|
import { type SelectItemProps } from '@ariakit/react-core/select/select-item';
|
|
3
3
|
import { type SelectRendererProps } from '@ariakit/react-core/select/select-renderer';
|
|
4
|
+
import { type InputChipProps } from '../input-chip/types';
|
|
4
5
|
import { type TextAreaProps } from '../text-area/types';
|
|
5
6
|
import { type Labelable } from '../util-components/labelable/types';
|
|
6
7
|
export type OptionValue = {
|
|
@@ -88,6 +89,11 @@ export interface ComboboxBaseProps<Multiple extends boolean, FreeInput extends b
|
|
|
88
89
|
* Return a string representation of a tooltip displayed on hover of an Input Chip in Combobox.
|
|
89
90
|
*/
|
|
90
91
|
displayTooltip?: (option: T) => string;
|
|
92
|
+
/**
|
|
93
|
+
* Return the variant of the InputChip to display for a given option.
|
|
94
|
+
* Falls back to 'default' when not provided.
|
|
95
|
+
*/
|
|
96
|
+
displayChipVariant?: (option: T) => InputChipProps['variant'];
|
|
91
97
|
/**
|
|
92
98
|
* Return a JSX representations of an option displayed in Combobox dropdown
|
|
93
99
|
* If not provided `displayValue()` is used to render select option item with a checkmark.
|
package/dist/lib-esm/index.css
CHANGED
|
@@ -1845,7 +1845,10 @@
|
|
|
1845
1845
|
.bp_chips_group_module_chipsGroup--61ede > [role=row]{
|
|
1846
1846
|
max-width:100%;
|
|
1847
1847
|
}
|
|
1848
|
-
.bp_input_chip_module_container--
|
|
1848
|
+
.bp_input_chip_module_container--7e728{
|
|
1849
|
+
--surface-inputchip-surface-variable:var(--purple-rain-20);
|
|
1850
|
+
--text-inputchip-text-variable:var(--purple-rain-120);
|
|
1851
|
+
--icon-inputchip-deleteicon-variable:var(--purple-rain-120);
|
|
1849
1852
|
align-items:center;
|
|
1850
1853
|
background-color:var(--surface-inputchip-surface);
|
|
1851
1854
|
border:none;
|
|
@@ -1869,33 +1872,24 @@
|
|
|
1869
1872
|
-webkit-user-select:none;
|
|
1870
1873
|
user-select:none;
|
|
1871
1874
|
}
|
|
1872
|
-
.bp_input_chip_module_container--
|
|
1875
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_avatarContainer--7e728{
|
|
1873
1876
|
padding-inline:var(--space-05);
|
|
1874
1877
|
}
|
|
1875
|
-
.bp_input_chip_module_container--
|
|
1878
|
+
.bp_input_chip_module_container--7e728:not(.bp_input_chip_module_avatarContainer--7e728).bp_input_chip_module_deleteButton--7e728{
|
|
1876
1879
|
padding-inline:var(--space-1) var(--space-05);
|
|
1877
1880
|
}
|
|
1878
|
-
.bp_input_chip_module_container--
|
|
1881
|
+
.bp_input_chip_module_container--7e728:not(.bp_input_chip_module_error--7e728):focus{
|
|
1879
1882
|
background-color:var(--surface-inputchip-surface-hover);
|
|
1880
1883
|
box-shadow:0 0 0 var(--border-1) var(--outline-focus-on-dark), 0 0 0 calc(var(--border-2) + var(--border-1)) var(--outline-focus-on-light);
|
|
1881
1884
|
}
|
|
1882
|
-
.bp_input_chip_module_container--
|
|
1885
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_error--7e728{
|
|
1883
1886
|
background-color:var(--surface-inputchip-surface-error);
|
|
1884
1887
|
outline:var(--border-1) solid var(--border-inputchip-border-error);
|
|
1885
1888
|
}
|
|
1886
|
-
.bp_input_chip_module_container--
|
|
1889
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_error--7e728:focus{
|
|
1887
1890
|
box-shadow:0 0 0 var(--border-2) var(--outline-focus-on-dark), 0 0 0 calc(var(--border-2) + var(--border-2)) var(--outline-focus-on-light);
|
|
1888
1891
|
}
|
|
1889
|
-
.bp_input_chip_module_container--
|
|
1890
|
-
flex-shrink:0;
|
|
1891
|
-
}
|
|
1892
|
-
.bp_input_chip_module_container--9f437 .bp_input_chip_module_label--9f437{
|
|
1893
|
-
overflow:hidden;
|
|
1894
|
-
padding-inline:var(--space-2);
|
|
1895
|
-
text-overflow:ellipsis;
|
|
1896
|
-
white-space:nowrap;
|
|
1897
|
-
}
|
|
1898
|
-
.bp_input_chip_module_container--9f437 .bp_input_chip_module_deleteIcon--9f437{
|
|
1892
|
+
.bp_input_chip_module_container--7e728 .bp_input_chip_module_deleteIcon--7e728{
|
|
1899
1893
|
align-items:center;
|
|
1900
1894
|
background:var(--surface-cta-surface-icon);
|
|
1901
1895
|
border-radius:var(--radius-half);
|
|
@@ -1905,21 +1899,57 @@
|
|
|
1905
1899
|
padding-block:var(--space-1);
|
|
1906
1900
|
padding-inline:var(--space-1);
|
|
1907
1901
|
}
|
|
1908
|
-
.bp_input_chip_module_container--
|
|
1902
|
+
.bp_input_chip_module_container--7e728 .bp_input_chip_module_deleteIcon--7e728 *{
|
|
1909
1903
|
fill:var(--icon-cta-icon);
|
|
1910
1904
|
}
|
|
1911
|
-
.bp_input_chip_module_container--
|
|
1905
|
+
.bp_input_chip_module_container--7e728 .bp_input_chip_module_deleteIcon--7e728:hover{
|
|
1912
1906
|
background:var(--surface-cta-surface-icon-hover);
|
|
1913
1907
|
}
|
|
1914
|
-
.bp_input_chip_module_container--
|
|
1908
|
+
.bp_input_chip_module_container--7e728 .bp_input_chip_module_deleteIcon--7e728:hover *{
|
|
1915
1909
|
fill:var(--icon-cta-icon-hover);
|
|
1916
1910
|
}
|
|
1917
|
-
.bp_input_chip_module_container--
|
|
1911
|
+
.bp_input_chip_module_container--7e728 .bp_input_chip_module_deleteIcon--7e728:active{
|
|
1918
1912
|
background:var(--surface-cta-surface-icon-pressed);
|
|
1919
1913
|
}
|
|
1920
|
-
.bp_input_chip_module_container--
|
|
1914
|
+
.bp_input_chip_module_container--7e728 .bp_input_chip_module_deleteIcon--7e728:active *{
|
|
1921
1915
|
fill:var(--icon-cta-icon-pressed);
|
|
1922
1916
|
}
|
|
1917
|
+
.bp_input_chip_module_container--7e728 .bp_input_chip_module_label--7e728{
|
|
1918
|
+
overflow:hidden;
|
|
1919
|
+
padding-inline:var(--space-2);
|
|
1920
|
+
text-overflow:ellipsis;
|
|
1921
|
+
white-space:nowrap;
|
|
1922
|
+
}
|
|
1923
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728{
|
|
1924
|
+
background-color:var(--surface-inputchip-surface-variable);
|
|
1925
|
+
}
|
|
1926
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728 .bp_input_chip_module_label--7e728{
|
|
1927
|
+
color:var(--text-inputchip-text-variable);
|
|
1928
|
+
}
|
|
1929
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728:focus{
|
|
1930
|
+
background-color:var(--surface-inputchip-surface-variable);
|
|
1931
|
+
}
|
|
1932
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728 .bp_input_chip_module_deleteIcon--7e728{
|
|
1933
|
+
background:var(--surface-cta-surface-icon);
|
|
1934
|
+
}
|
|
1935
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728 .bp_input_chip_module_deleteIcon--7e728 *{
|
|
1936
|
+
fill:var(--icon-inputchip-deleteicon-variable);
|
|
1937
|
+
}
|
|
1938
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728 .bp_input_chip_module_deleteIcon--7e728:hover{
|
|
1939
|
+
background:var(--surface-cta-surface-icon-hover);
|
|
1940
|
+
}
|
|
1941
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728 .bp_input_chip_module_deleteIcon--7e728:hover *{
|
|
1942
|
+
fill:var(--icon-inputchip-deleteicon-variable);
|
|
1943
|
+
}
|
|
1944
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728 .bp_input_chip_module_deleteIcon--7e728:active{
|
|
1945
|
+
background:var(--surface-cta-surface-icon-pressed);
|
|
1946
|
+
}
|
|
1947
|
+
.bp_input_chip_module_container--7e728.bp_input_chip_module_variable--7e728 .bp_input_chip_module_deleteIcon--7e728:active *{
|
|
1948
|
+
fill:var(--icon-inputchip-deleteicon-variable);
|
|
1949
|
+
}
|
|
1950
|
+
.bp_input_chip_module_container--7e728 .bp_input_chip_module_avatar--7e728{
|
|
1951
|
+
flex-shrink:0;
|
|
1952
|
+
}
|
|
1923
1953
|
.bp_inline_error_module_inlineError--9a67c{
|
|
1924
1954
|
align-items:center;
|
|
1925
1955
|
color:var(--text-text-error-on-light);
|
|
@@ -7267,7 +7297,45 @@ div[data-radix-popper-content-wrapper]:has([role=menu]):has([data-state=open]):h
|
|
|
7267
7297
|
min-width:var(--split-button-dropdown-min-width);
|
|
7268
7298
|
}
|
|
7269
7299
|
|
|
7270
|
-
.bp_switch_module_option--
|
|
7300
|
+
.bp_switch_module_option--d724c[data-modern=false]{
|
|
7301
|
+
--switch-width:var(--size-10);
|
|
7302
|
+
--switch-height:var(--size-5);
|
|
7303
|
+
--switch-margin-left:var(--space-10);
|
|
7304
|
+
--switch-margin-right:var(--space-3);
|
|
7305
|
+
--description-margin:calc(var(--switch-margin-right) + var(--switch-width));
|
|
7306
|
+
--thumb-width:var(--size-5);
|
|
7307
|
+
--thumb-height:var(--size-5);
|
|
7308
|
+
--thumb-bg:var(--surface-switch-surface);
|
|
7309
|
+
--thumb-border:var(--border-1) solid var(--border-switch-border);
|
|
7310
|
+
--thumb-radius:var(--size-10);
|
|
7311
|
+
--thumb-shadow:var(--dropshadow-3);
|
|
7312
|
+
--switch-bg-off:var(--surface-switch-surface-off);
|
|
7313
|
+
--switch-bg-on:var(--surface-switch-surface-on);
|
|
7314
|
+
--switch-radius:var(--size-10);
|
|
7315
|
+
--switch-outline:var(--outline-focus-on-light);
|
|
7316
|
+
--switch-disabled-opacity:.5;
|
|
7317
|
+
}
|
|
7318
|
+
|
|
7319
|
+
.bp_switch_module_option--d724c[data-modern=true]{
|
|
7320
|
+
--switch-width:var(--bp-size-110);
|
|
7321
|
+
--switch-height:var(--bp-size-060);
|
|
7322
|
+
--switch-margin-left:var(--bp-space-100);
|
|
7323
|
+
--switch-margin-right:var(--bp-space-030);
|
|
7324
|
+
--description-margin:calc(var(--switch-margin-right) + var(--switch-width));
|
|
7325
|
+
--thumb-width:var(--bp-size-060);
|
|
7326
|
+
--thumb-height:var(--bp-size-060);
|
|
7327
|
+
--thumb-bg:var(--bp-surface-switch-surface);
|
|
7328
|
+
--thumb-border:var(--bp-border-01) solid var(--bp-border-switch-border);
|
|
7329
|
+
--thumb-radius:var(--bp-size-100);
|
|
7330
|
+
--thumb-shadow:var(--dropshadow-3);
|
|
7331
|
+
--switch-bg-off:var(--bp-surface-switch-surface-off);
|
|
7332
|
+
--switch-bg-on:var(--bp-surface-switch-surface-on);
|
|
7333
|
+
--switch-radius:var(--bp-size-100);
|
|
7334
|
+
--switch-outline:var(--bp-outline-focus-on-light);
|
|
7335
|
+
--switch-disabled-opacity:.6;
|
|
7336
|
+
}
|
|
7337
|
+
|
|
7338
|
+
.bp_switch_module_option--d724c{
|
|
7271
7339
|
display:flex;
|
|
7272
7340
|
flex-direction:column;
|
|
7273
7341
|
font-family:var(--body-default-font-family);
|
|
@@ -7279,69 +7347,69 @@ div[data-radix-popper-content-wrapper]:has([role=menu]):has([data-state=open]):h
|
|
|
7279
7347
|
text-decoration:var(--body-default-text-decoration);
|
|
7280
7348
|
text-transform:var(--body-default-text-case);
|
|
7281
7349
|
}
|
|
7282
|
-
.bp_switch_module_option--
|
|
7350
|
+
.bp_switch_module_option--d724c .bp_switch_module_label--d724c{
|
|
7283
7351
|
cursor:pointer;
|
|
7284
7352
|
display:inline-flex;
|
|
7285
7353
|
flex-direction:row;
|
|
7286
7354
|
width:-moz-fit-content;
|
|
7287
7355
|
width:fit-content;
|
|
7288
7356
|
}
|
|
7289
|
-
.bp_switch_module_option--
|
|
7357
|
+
.bp_switch_module_option--d724c .bp_switch_module_label--d724c.bp_switch_module_rightAlign--d724c{
|
|
7290
7358
|
flex-direction:row-reverse;
|
|
7291
7359
|
justify-content:space-between;
|
|
7292
7360
|
width:unset;
|
|
7293
7361
|
}
|
|
7294
|
-
.bp_switch_module_option--
|
|
7295
|
-
margin-left:
|
|
7362
|
+
.bp_switch_module_option--d724c .bp_switch_module_description--d724c{
|
|
7363
|
+
margin-left:var(--description-margin);
|
|
7296
7364
|
}
|
|
7297
|
-
.bp_switch_module_option--
|
|
7365
|
+
.bp_switch_module_option--d724c .bp_switch_module_description--d724c.bp_switch_module_rightAlign--d724c{
|
|
7298
7366
|
margin-left:unset;
|
|
7299
|
-
margin-right:
|
|
7367
|
+
margin-right:var(--description-margin);
|
|
7300
7368
|
}
|
|
7301
|
-
.bp_switch_module_option--
|
|
7302
|
-
background-color:var(--
|
|
7303
|
-
border:var(--
|
|
7304
|
-
border-radius:var(--
|
|
7305
|
-
box-shadow:var(--
|
|
7369
|
+
.bp_switch_module_option--d724c .bp_switch_module_thumb--d724c{
|
|
7370
|
+
background-color:var(--thumb-bg);
|
|
7371
|
+
border:var(--thumb-border);
|
|
7372
|
+
border-radius:var(--thumb-radius);
|
|
7373
|
+
box-shadow:var(--thumb-shadow);
|
|
7306
7374
|
box-sizing:border-box;
|
|
7307
7375
|
display:block;
|
|
7308
|
-
height:var(--
|
|
7376
|
+
height:var(--thumb-height);
|
|
7309
7377
|
transition:transform .4s;
|
|
7310
|
-
width:var(--
|
|
7378
|
+
width:var(--thumb-width);
|
|
7311
7379
|
will-change:transform;
|
|
7312
7380
|
}
|
|
7313
|
-
.bp_switch_module_option--
|
|
7381
|
+
.bp_switch_module_option--d724c .bp_switch_module_switch--d724c{
|
|
7314
7382
|
all:unset;
|
|
7315
7383
|
align-items:center;
|
|
7316
|
-
background-color:var(--
|
|
7317
|
-
border-radius:var(--
|
|
7384
|
+
background-color:var(--switch-bg-off);
|
|
7385
|
+
border-radius:var(--switch-radius);
|
|
7318
7386
|
display:flex;
|
|
7319
7387
|
flex-shrink:0;
|
|
7320
|
-
height:var(--
|
|
7321
|
-
margin-right:var(--
|
|
7388
|
+
height:var(--switch-height);
|
|
7389
|
+
margin-right:var(--switch-margin-right);
|
|
7322
7390
|
position:relative;
|
|
7323
7391
|
transition:background-color .4s;
|
|
7324
|
-
width:var(--
|
|
7392
|
+
width:var(--switch-width);
|
|
7325
7393
|
will-change:transition;
|
|
7326
7394
|
}
|
|
7327
|
-
.bp_switch_module_option--
|
|
7328
|
-
margin-left:var(--
|
|
7395
|
+
.bp_switch_module_option--d724c .bp_switch_module_switch--d724c.bp_switch_module_rightAlign--d724c{
|
|
7396
|
+
margin-left:var(--switch-margin-left);
|
|
7329
7397
|
margin-right:unset;
|
|
7330
7398
|
}
|
|
7331
|
-
.bp_switch_module_option--
|
|
7332
|
-
box-shadow:0 0 0 var(--border-1, 1px) var(--background-background), 0 0 0 var(--border-3) var(--outline
|
|
7399
|
+
.bp_switch_module_option--d724c .bp_switch_module_switch--d724c:focus-visible{
|
|
7400
|
+
box-shadow:0 0 0 var(--border-1, 1px) var(--background-background), 0 0 0 var(--border-3) var(--switch-outline);
|
|
7333
7401
|
}
|
|
7334
|
-
.bp_switch_module_option--
|
|
7335
|
-
background-color:var(--
|
|
7402
|
+
.bp_switch_module_option--d724c .bp_switch_module_switch--d724c[aria-checked=true]{
|
|
7403
|
+
background-color:var(--switch-bg-on);
|
|
7336
7404
|
}
|
|
7337
|
-
.bp_switch_module_option--
|
|
7338
|
-
transform:translateX(calc(var(--
|
|
7405
|
+
.bp_switch_module_option--d724c .bp_switch_module_switch--d724c[aria-checked=true] .bp_switch_module_thumb--d724c{
|
|
7406
|
+
transform:translateX(calc(var(--switch-width)/2));
|
|
7339
7407
|
}
|
|
7340
|
-
.bp_switch_module_option--
|
|
7408
|
+
.bp_switch_module_option--d724c.bp_switch_module_disabled--d724c .bp_switch_module_label--d724c{
|
|
7341
7409
|
cursor:default;
|
|
7342
7410
|
}
|
|
7343
|
-
.bp_switch_module_option--
|
|
7344
|
-
opacity:
|
|
7411
|
+
.bp_switch_module_option--d724c.bp_switch_module_disabled--d724c .bp_switch_module_switch--d724c{
|
|
7412
|
+
opacity:var(--switch-disabled-opacity);
|
|
7345
7413
|
}
|
|
7346
7414
|
|
|
7347
7415
|
.bp_text_button_module_textButton--84555[data-modern=false]{
|
|
@@ -6,6 +6,15 @@ import React__default, { forwardRef } from 'react';
|
|
|
6
6
|
import { Text } from '../text/text.js';
|
|
7
7
|
import styles from './input-chip.module.js';
|
|
8
8
|
|
|
9
|
+
const getVariantClass = variant => {
|
|
10
|
+
if (variant === 'error') {
|
|
11
|
+
return styles.error;
|
|
12
|
+
}
|
|
13
|
+
if (variant === 'variable') {
|
|
14
|
+
return styles.variable;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
};
|
|
9
18
|
const DELETE_TRIGGER_KEYS = ['Backspace', 'Delete'];
|
|
10
19
|
const InputChip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
11
20
|
const {
|
|
@@ -44,11 +53,13 @@ const InputChip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
44
53
|
buttonProps.onKeyDown?.(event);
|
|
45
54
|
};
|
|
46
55
|
const hasError = variant === 'error';
|
|
56
|
+
const variantClass = getVariantClass(variant);
|
|
57
|
+
const containerClassName = clsx(styles.container, variantClass, avatar && styles.avatarContainer, onDelete && styles.deleteButton, className);
|
|
47
58
|
return /* eslint-disable-next-line jsx-a11y/role-supports-aria-props */jsxs("button", {
|
|
48
59
|
...buttonProps,
|
|
49
60
|
ref: ref,
|
|
50
61
|
"aria-invalid": hasError,
|
|
51
|
-
className:
|
|
62
|
+
className: containerClassName,
|
|
52
63
|
onKeyDown: handleKeyDown,
|
|
53
64
|
type: "button",
|
|
54
65
|
children: [avatar, jsx(Text, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"container":"bp_input_chip_module_container--
|
|
2
|
+
var styles = {"container":"bp_input_chip_module_container--7e728","avatarContainer":"bp_input_chip_module_avatarContainer--7e728","deleteButton":"bp_input_chip_module_deleteButton--7e728","error":"bp_input_chip_module_error--7e728","deleteIcon":"bp_input_chip_module_deleteIcon--7e728","label":"bp_input_chip_module_label--7e728","variable":"bp_input_chip_module_variable--7e728","avatar":"bp_input_chip_module_avatar--7e728"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -17,7 +17,7 @@ export interface InputChipProps extends HTMLAttributes<HTMLElement> {
|
|
|
17
17
|
*
|
|
18
18
|
* @default "default"
|
|
19
19
|
*/
|
|
20
|
-
variant?: 'default' | 'error';
|
|
20
|
+
variant?: 'default' | 'error' | 'variable';
|
|
21
21
|
/**
|
|
22
22
|
* Callback fired when chip is deleted with X button click or keyboard interaction.
|
|
23
23
|
*/
|
|
@@ -2,6 +2,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as RadixSwitch from '@radix-ui/react-switch';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
|
+
import { useBlueprintModernization } from '../blueprint-modernization-context/useBlueprintModernization.js';
|
|
5
6
|
import { TextWithInfoBadge } from '../util-components/text-with-info-badge/text-with-info-badge.js';
|
|
6
7
|
import { useUniqueId } from '../utils/useUniqueId.js';
|
|
7
8
|
import styles from './switch.module.js';
|
|
@@ -24,10 +25,14 @@ const Switch = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
24
25
|
...rest
|
|
25
26
|
} = props;
|
|
26
27
|
const descriptionId = useUniqueId('description-', !!description);
|
|
28
|
+
const {
|
|
29
|
+
enableModernizedComponents
|
|
30
|
+
} = useBlueprintModernization();
|
|
27
31
|
return jsxs("div", {
|
|
28
32
|
className: clsx([styles.option], {
|
|
29
33
|
[styles.disabled]: disabled
|
|
30
34
|
}, className),
|
|
35
|
+
"data-modern": enableModernizedComponents,
|
|
31
36
|
children: [jsxs("label", {
|
|
32
37
|
className: clsx(styles.label, {
|
|
33
38
|
[styles.rightAlign]: isRightAligned
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"option":"bp_switch_module_option--
|
|
2
|
+
var styles = {"option":"bp_switch_module_option--d724c","label":"bp_switch_module_label--d724c","rightAlign":"bp_switch_module_rightAlign--d724c","description":"bp_switch_module_description--d724c","thumb":"bp_switch_module_thumb--d724c","switch":"bp_switch_module_switch--d724c","disabled":"bp_switch_module_disabled--d724c"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|