@czi-sds/components 22.7.0 → 22.8.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/index.cjs.d.ts +2 -0
- package/dist/index.cjs.js +12 -12
- package/dist/index.esm.d.ts +2 -0
- package/dist/index.esm.js +12 -12
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/index.cjs.d.ts
CHANGED
|
@@ -1079,6 +1079,7 @@ interface StyleProps$1 extends CommonThemeProps {
|
|
|
1079
1079
|
count?: number;
|
|
1080
1080
|
icon?: ReactElement;
|
|
1081
1081
|
search?: boolean;
|
|
1082
|
+
isSearchAutoFocus?: boolean;
|
|
1082
1083
|
title?: string;
|
|
1083
1084
|
isMultiColumn?: boolean;
|
|
1084
1085
|
}
|
|
@@ -1322,6 +1323,7 @@ interface ExtraDropdownProps<T, Multiple extends boolean | undefined, DisableCle
|
|
|
1322
1323
|
label: ReactNode;
|
|
1323
1324
|
options: AutocompleteSingleColumnOption<T>[] | AutocompleteMultiColumnOption<T, Multiple, DisableClearable, FreeSolo>[];
|
|
1324
1325
|
search?: boolean;
|
|
1326
|
+
isSearchAutoFocus?: boolean;
|
|
1325
1327
|
DropdownMenuProps?: Partial<SdsDropdownMenuProps<T, Multiple, DisableClearable, FreeSolo>>;
|
|
1326
1328
|
InputDropdownProps?: Partial<InputDropdownPropsType$0>;
|
|
1327
1329
|
value?: AutocompleteValue$1<T, Multiple, DisableClearable, FreeSolo>;
|
package/dist/index.cjs.js
CHANGED
|
@@ -6405,7 +6405,7 @@ var StyledPaper$1 = styled__default.default(material.Paper, {
|
|
|
6405
6405
|
var borders = getBorders(props);
|
|
6406
6406
|
var shadows = getShadows(props);
|
|
6407
6407
|
var semanticColors = getSemanticColors(props);
|
|
6408
|
-
return "\n box-shadow: ".concat(shadows === null || shadows === void 0 ? void 0 : shadows.none, " !important;\n border: ").concat(borders === null || borders === void 0 ? void 0 : borders.none, ";\n background-color: ").concat((_a = semanticColors === null || semanticColors === void 0 ? void 0 : semanticColors.base) === null || _a === void 0 ? void 0 : _a.surface, ";\n background-image: none;\n margin: 0;\n padding: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.xxs, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px;\n\n .MuiAutocomplete-root,\n .MuiFormControl-root.MuiTextField-root {\n margin-bottom: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.m, "px;\n margin-right: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.m, "px;\n }\n\n // (masoudmanson): Remove margin-right and margin-bottom for the single column autocomplete\n // as it has been added to the parent container\n .MuiAutocomplete-root .MuiFormControl-root.MuiTextField-root {\n margin-right: 0;\n margin-bottom: 0
|
|
6408
|
+
return "\n box-shadow: ".concat(shadows === null || shadows === void 0 ? void 0 : shadows.none, " !important;\n border: ").concat(borders === null || borders === void 0 ? void 0 : borders.none, ";\n background-color: ").concat((_a = semanticColors === null || semanticColors === void 0 ? void 0 : semanticColors.base) === null || _a === void 0 ? void 0 : _a.surface, ";\n background-image: none;\n margin: 0;\n padding: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.xxs, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px;\n\n .MuiAutocomplete-root,\n .MuiFormControl-root.MuiTextField-root {\n margin-bottom: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.m, "px;\n margin-right: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.m, "px;\n }\n\n // (masoudmanson): Remove margin-right and margin-bottom for the single column autocomplete\n // as it has been added to the parent container\n .MuiAutocomplete-root .MuiFormControl-root.MuiTextField-root {\n margin-right: 0;\n margin-bottom: 0;\n }\n ");
|
|
6409
6409
|
});
|
|
6410
6410
|
var StyledDropdownMenuHeader = styled__default.default("div")(templateObject_5$f || (templateObject_5$f = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
6411
6411
|
var search = props.search;
|
|
@@ -6423,7 +6423,7 @@ var DEFAULT_POPPER_BASE_PROPS = {
|
|
|
6423
6423
|
var DropdownMenu = function (props) {
|
|
6424
6424
|
var _a, _b;
|
|
6425
6425
|
var theme = material.useTheme();
|
|
6426
|
-
var anchorEl = props.anchorEl, id = props.id, InputBaseProps = props.InputBaseProps, _c = props.open, open = _c === void 0 ? false : _c, _d = props.PopperComponent, PopperComponent = _d === void 0 ? StyledPopper : _d, _e = props.PaperComponent, PaperComponent = _e === void 0 ? StyledPaper$1 : _e, _f = props.PopperPlacement, PopperPlacement = _f === void 0 ? "bottom-start" : _f, _g = props.PopperBaseProps, PopperBaseProps = _g === void 0 ? {} : _g, _h = props.search, search =
|
|
6426
|
+
var anchorEl = props.anchorEl, id = props.id, InputBaseProps = props.InputBaseProps, _c = props.open, open = _c === void 0 ? false : _c, _d = props.PopperComponent, PopperComponent = _d === void 0 ? StyledPopper : _d, _e = props.PaperComponent, PaperComponent = _e === void 0 ? StyledPaper$1 : _e, _f = props.PopperPlacement, PopperPlacement = _f === void 0 ? "bottom-start" : _f, _g = props.PopperBaseProps, PopperBaseProps = _g === void 0 ? {} : _g, _h = props.isSearchAutoFocus, isSearchAutoFocus = _h === void 0 ? true : _h, _j = props.search, search = _j === void 0 ? false : _j, title = props.title, headerComponentSlot = props.headerComponentSlot, _k = props.label, label = _k === void 0 ? "Search" : _k, children = props.children, options = props.options, _l = props.onClickAway, onClickAway = _l === void 0 ? noop : _l, ClickAwayListenerProps = props.ClickAwayListenerProps, _m = props.width, width = _m === void 0 ? MINIMUM_DROPDOWN_MENU_POPPER_WIDTH : _m, rest = __rest(props, ["anchorEl", "id", "InputBaseProps", "open", "PopperComponent", "PaperComponent", "PopperPlacement", "PopperBaseProps", "isSearchAutoFocus", "search", "title", "headerComponentSlot", "label", "children", "options", "onClickAway", "ClickAwayListenerProps", "width"]);
|
|
6427
6427
|
var isMultiColumn = "options" in ((options === null || options === void 0 ? void 0 : options[0]) || EMPTY_OBJECT);
|
|
6428
6428
|
// (masoudmanson): The DropdownMenu's Popper component should have a minimum
|
|
6429
6429
|
// width of MINIMUM_DROPDOWN_MENU_POPPER_WIDTH pixels if the DropdownMenu is
|
|
@@ -6433,8 +6433,8 @@ var DropdownMenu = function (props) {
|
|
|
6433
6433
|
return __assign({ minWidth: MINIMUM_DROPDOWN_MENU_POPPER_WIDTH, width: isMultiColumn ? "auto" : width }, PopperBaseProps === null || PopperBaseProps === void 0 ? void 0 : PopperBaseProps.sx);
|
|
6434
6434
|
}, [PopperBaseProps === null || PopperBaseProps === void 0 ? void 0 : PopperBaseProps.sx, isMultiColumn, width]);
|
|
6435
6435
|
var DefaultInputBaseProps = React.useMemo(function () {
|
|
6436
|
-
return __assign(__assign({}, InputBaseProps), { autoFocus:
|
|
6437
|
-
}, [InputBaseProps]);
|
|
6436
|
+
return __assign(__assign({}, InputBaseProps), { autoFocus: isSearchAutoFocus, onClick: noop });
|
|
6437
|
+
}, [InputBaseProps, isSearchAutoFocus]);
|
|
6438
6438
|
return (jsxRuntime.jsx(PopperComponent, __assign({ id: id, modifiers: [
|
|
6439
6439
|
{
|
|
6440
6440
|
name: "offset",
|
|
@@ -7429,29 +7429,29 @@ var templateObject_1$A, templateObject_2$n;
|
|
|
7429
7429
|
|
|
7430
7430
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
7431
7431
|
var Dropdown = function (props) {
|
|
7432
|
-
var options = props.options, _a = props.label, label = _a === void 0 ? "" : _a, _b = props.multiple, multiple = _b === void 0 ? false : _b, _c = props.search, search = _c === void 0 ? false : _c, _d = props.buttonPosition, buttonPosition =
|
|
7432
|
+
var options = props.options, _a = props.label, label = _a === void 0 ? "" : _a, _b = props.multiple, multiple = _b === void 0 ? false : _b, _c = props.search, search = _c === void 0 ? false : _c, _d = props.isSearchAutoFocus, isSearchAutoFocus = _d === void 0 ? true : _d, _e = props.buttonPosition, buttonPosition = _e === void 0 ? "right" : _e, _f = props.buttons, buttons = _f === void 0 ? false : _f,
|
|
7433
7433
|
// By default, most dropdowns will close when the user clicks outside the dropdown.
|
|
7434
7434
|
// The exception is the multiple select variant with Apply/Cancel buttons,
|
|
7435
7435
|
// which by default will not close on blur. If closeOnBlur is enabled, clicking out
|
|
7436
7436
|
// is equivalent to clicking the Cancel button, closing the dropdown and losing
|
|
7437
7437
|
// unapplied changes.
|
|
7438
|
-
|
|
7438
|
+
_g = props.closeOnBlur,
|
|
7439
7439
|
// By default, most dropdowns will close when the user clicks outside the dropdown.
|
|
7440
7440
|
// The exception is the multiple select variant with Apply/Cancel buttons,
|
|
7441
7441
|
// which by default will not close on blur. If closeOnBlur is enabled, clicking out
|
|
7442
7442
|
// is equivalent to clicking the Cancel button, closing the dropdown and losing
|
|
7443
7443
|
// unapplied changes.
|
|
7444
|
-
closeOnBlur =
|
|
7444
|
+
closeOnBlur = _g === void 0 ? !buttons : _g, onClose = props.onClose, onChange = props.onChange, _h = props.DropdownMenuProps, DropdownMenuProps = _h === void 0 ? {} : _h, _j = props.InputDropdownProps, InputDropdownProps = _j === void 0 ? { sdsStyle: "minimal" } : _j, _k = props.InputDropdownComponent, InputDropdownComponent = _k === void 0 ? InputDropdown : _k, _l = props.isTriggerChangeOnOptionClick, isTriggerChangeOnOptionClick = _l === void 0 ? false : _l, _m = props.disabled, disabled = _m === void 0 ? false : _m, propValue = props.value, onClick = props.onClick, rest = __rest(props, ["options", "label", "multiple", "search", "isSearchAutoFocus", "buttonPosition", "buttons", "closeOnBlur", "onClose", "onChange", "DropdownMenuProps", "InputDropdownProps", "InputDropdownComponent", "isTriggerChangeOnOptionClick", "disabled", "value", "onClick"]);
|
|
7445
7445
|
if (buttons && !multiple) {
|
|
7446
7446
|
// eslint-disable-next-line no-console
|
|
7447
7447
|
console.warn("Warning: buttons are only supported for multiple select dropdowns.");
|
|
7448
7448
|
}
|
|
7449
7449
|
var isMultiColumn = "options" in ((options === null || options === void 0 ? void 0 : options[0]) || EMPTY_OBJECT);
|
|
7450
7450
|
var isControlled = propValue !== undefined;
|
|
7451
|
-
var
|
|
7452
|
-
var
|
|
7453
|
-
var
|
|
7454
|
-
var
|
|
7451
|
+
var _o = React.useState(null), anchorEl = _o[0], setAnchorEl = _o[1];
|
|
7452
|
+
var _p = React.useState(false), open = _p[0], setOpen = _p[1];
|
|
7453
|
+
var _q = React.useState(getInitialValue()), value = _q[0], setValue = _q[1];
|
|
7454
|
+
var _r = React.useState(getInitialValue()), pendingValue = _r[0], setPendingValue = _r[1];
|
|
7455
7455
|
var shouldShowButtons = buttons && !isTriggerChangeOnOptionClick && multiple;
|
|
7456
7456
|
React.useEffect(function () {
|
|
7457
7457
|
if (isControlled) {
|
|
@@ -7461,7 +7461,7 @@ var Dropdown = function (props) {
|
|
|
7461
7461
|
}
|
|
7462
7462
|
}
|
|
7463
7463
|
}, [isControlled, propValue, multiple]);
|
|
7464
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(InputDropdownComponent, __assign({ disabled: disabled, label: label, onClick: handleClick }, InputDropdownProps, rest)), jsxRuntime.jsx(DropdownMenu, __assign({ anchorEl: anchorEl, open: open, search: search, onClose: handleClose, multiple: multiple, disableCloseOnSelect: multiple, options: options, onClickAway: handleClickAway, width: 250, onChange: handleChange, value: isMultiColumn ? value : multiple ? pendingValue : value }, DropdownMenuProps, rest, { children: shouldShowButtons ? (jsxRuntime.jsx(StyledButtonsWrapper, { buttonPosition: buttonPosition, children: buttonPosition === "left" ? (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(StyledButton, { onClick: handleButtonClose, sdsStyle: "square", sdsType: "primary", children: "Apply" }), jsxRuntime.jsx(StyledButton, { onClick: handleCancel, sdsStyle: "square", sdsType: "secondary", children: "Cancel" })] })) : (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(StyledButton, { onClick: handleCancel, sdsStyle: "square", sdsType: "secondary", children: "Cancel" }), jsxRuntime.jsx(StyledButton, { onClick: handleButtonClose, sdsStyle: "square", sdsType: "primary", children: "Apply" })] })) })) : null }))] }));
|
|
7464
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(InputDropdownComponent, __assign({ disabled: disabled, label: label, onClick: handleClick }, InputDropdownProps, rest)), jsxRuntime.jsx(DropdownMenu, __assign({ anchorEl: anchorEl, open: open, search: search, onClose: handleClose, multiple: multiple, disableCloseOnSelect: multiple, options: options, onClickAway: handleClickAway, width: 250, onChange: handleChange, value: isMultiColumn ? value : multiple ? pendingValue : value, isSearchAutoFocus: isSearchAutoFocus }, DropdownMenuProps, rest, { children: shouldShowButtons ? (jsxRuntime.jsx(StyledButtonsWrapper, { buttonPosition: buttonPosition, children: buttonPosition === "left" ? (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(StyledButton, { onClick: handleButtonClose, sdsStyle: "square", sdsType: "primary", children: "Apply" }), jsxRuntime.jsx(StyledButton, { onClick: handleCancel, sdsStyle: "square", sdsType: "secondary", children: "Cancel" })] })) : (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(StyledButton, { onClick: handleCancel, sdsStyle: "square", sdsType: "secondary", children: "Cancel" }), jsxRuntime.jsx(StyledButton, { onClick: handleButtonClose, sdsStyle: "square", sdsType: "primary", children: "Apply" })] })) })) : null }))] }));
|
|
7465
7465
|
function getInitialValue() {
|
|
7466
7466
|
return multiple
|
|
7467
7467
|
? []
|
package/dist/index.esm.d.ts
CHANGED
|
@@ -1079,6 +1079,7 @@ interface StyleProps$1 extends CommonThemeProps {
|
|
|
1079
1079
|
count?: number;
|
|
1080
1080
|
icon?: ReactElement;
|
|
1081
1081
|
search?: boolean;
|
|
1082
|
+
isSearchAutoFocus?: boolean;
|
|
1082
1083
|
title?: string;
|
|
1083
1084
|
isMultiColumn?: boolean;
|
|
1084
1085
|
}
|
|
@@ -1322,6 +1323,7 @@ interface ExtraDropdownProps<T, Multiple extends boolean | undefined, DisableCle
|
|
|
1322
1323
|
label: ReactNode;
|
|
1323
1324
|
options: AutocompleteSingleColumnOption<T>[] | AutocompleteMultiColumnOption<T, Multiple, DisableClearable, FreeSolo>[];
|
|
1324
1325
|
search?: boolean;
|
|
1326
|
+
isSearchAutoFocus?: boolean;
|
|
1325
1327
|
DropdownMenuProps?: Partial<SdsDropdownMenuProps<T, Multiple, DisableClearable, FreeSolo>>;
|
|
1326
1328
|
InputDropdownProps?: Partial<InputDropdownPropsType$0>;
|
|
1327
1329
|
value?: AutocompleteValue$1<T, Multiple, DisableClearable, FreeSolo>;
|
package/dist/index.esm.js
CHANGED
|
@@ -6382,7 +6382,7 @@ var StyledPaper$1 = styled$2(Paper, {
|
|
|
6382
6382
|
var borders = getBorders(props);
|
|
6383
6383
|
var shadows = getShadows(props);
|
|
6384
6384
|
var semanticColors = getSemanticColors(props);
|
|
6385
|
-
return "\n box-shadow: ".concat(shadows === null || shadows === void 0 ? void 0 : shadows.none, " !important;\n border: ").concat(borders === null || borders === void 0 ? void 0 : borders.none, ";\n background-color: ").concat((_a = semanticColors === null || semanticColors === void 0 ? void 0 : semanticColors.base) === null || _a === void 0 ? void 0 : _a.surface, ";\n background-image: none;\n margin: 0;\n padding: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.xxs, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px;\n\n .MuiAutocomplete-root,\n .MuiFormControl-root.MuiTextField-root {\n margin-bottom: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.m, "px;\n margin-right: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.m, "px;\n }\n\n // (masoudmanson): Remove margin-right and margin-bottom for the single column autocomplete\n // as it has been added to the parent container\n .MuiAutocomplete-root .MuiFormControl-root.MuiTextField-root {\n margin-right: 0;\n margin-bottom: 0
|
|
6385
|
+
return "\n box-shadow: ".concat(shadows === null || shadows === void 0 ? void 0 : shadows.none, " !important;\n border: ").concat(borders === null || borders === void 0 ? void 0 : borders.none, ";\n background-color: ").concat((_a = semanticColors === null || semanticColors === void 0 ? void 0 : semanticColors.base) === null || _a === void 0 ? void 0 : _a.surface, ";\n background-image: none;\n margin: 0;\n padding: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.xxs, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.l, "px;\n\n .MuiAutocomplete-root,\n .MuiFormControl-root.MuiTextField-root {\n margin-bottom: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.m, "px;\n margin-right: ").concat(spaces === null || spaces === void 0 ? void 0 : spaces.m, "px;\n }\n\n // (masoudmanson): Remove margin-right and margin-bottom for the single column autocomplete\n // as it has been added to the parent container\n .MuiAutocomplete-root .MuiFormControl-root.MuiTextField-root {\n margin-right: 0;\n margin-bottom: 0;\n }\n ");
|
|
6386
6386
|
});
|
|
6387
6387
|
var StyledDropdownMenuHeader = styled$2("div")(templateObject_5$f || (templateObject_5$f = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
6388
6388
|
var search = props.search;
|
|
@@ -6400,7 +6400,7 @@ var DEFAULT_POPPER_BASE_PROPS = {
|
|
|
6400
6400
|
var DropdownMenu = function (props) {
|
|
6401
6401
|
var _a, _b;
|
|
6402
6402
|
var theme = useTheme$4();
|
|
6403
|
-
var anchorEl = props.anchorEl, id = props.id, InputBaseProps = props.InputBaseProps, _c = props.open, open = _c === void 0 ? false : _c, _d = props.PopperComponent, PopperComponent = _d === void 0 ? StyledPopper : _d, _e = props.PaperComponent, PaperComponent = _e === void 0 ? StyledPaper$1 : _e, _f = props.PopperPlacement, PopperPlacement = _f === void 0 ? "bottom-start" : _f, _g = props.PopperBaseProps, PopperBaseProps = _g === void 0 ? {} : _g, _h = props.search, search =
|
|
6403
|
+
var anchorEl = props.anchorEl, id = props.id, InputBaseProps = props.InputBaseProps, _c = props.open, open = _c === void 0 ? false : _c, _d = props.PopperComponent, PopperComponent = _d === void 0 ? StyledPopper : _d, _e = props.PaperComponent, PaperComponent = _e === void 0 ? StyledPaper$1 : _e, _f = props.PopperPlacement, PopperPlacement = _f === void 0 ? "bottom-start" : _f, _g = props.PopperBaseProps, PopperBaseProps = _g === void 0 ? {} : _g, _h = props.isSearchAutoFocus, isSearchAutoFocus = _h === void 0 ? true : _h, _j = props.search, search = _j === void 0 ? false : _j, title = props.title, headerComponentSlot = props.headerComponentSlot, _k = props.label, label = _k === void 0 ? "Search" : _k, children = props.children, options = props.options, _l = props.onClickAway, onClickAway = _l === void 0 ? noop : _l, ClickAwayListenerProps = props.ClickAwayListenerProps, _m = props.width, width = _m === void 0 ? MINIMUM_DROPDOWN_MENU_POPPER_WIDTH : _m, rest = __rest(props, ["anchorEl", "id", "InputBaseProps", "open", "PopperComponent", "PaperComponent", "PopperPlacement", "PopperBaseProps", "isSearchAutoFocus", "search", "title", "headerComponentSlot", "label", "children", "options", "onClickAway", "ClickAwayListenerProps", "width"]);
|
|
6404
6404
|
var isMultiColumn = "options" in ((options === null || options === void 0 ? void 0 : options[0]) || EMPTY_OBJECT);
|
|
6405
6405
|
// (masoudmanson): The DropdownMenu's Popper component should have a minimum
|
|
6406
6406
|
// width of MINIMUM_DROPDOWN_MENU_POPPER_WIDTH pixels if the DropdownMenu is
|
|
@@ -6410,8 +6410,8 @@ var DropdownMenu = function (props) {
|
|
|
6410
6410
|
return __assign({ minWidth: MINIMUM_DROPDOWN_MENU_POPPER_WIDTH, width: isMultiColumn ? "auto" : width }, PopperBaseProps === null || PopperBaseProps === void 0 ? void 0 : PopperBaseProps.sx);
|
|
6411
6411
|
}, [PopperBaseProps === null || PopperBaseProps === void 0 ? void 0 : PopperBaseProps.sx, isMultiColumn, width]);
|
|
6412
6412
|
var DefaultInputBaseProps = useMemo(function () {
|
|
6413
|
-
return __assign(__assign({}, InputBaseProps), { autoFocus:
|
|
6414
|
-
}, [InputBaseProps]);
|
|
6413
|
+
return __assign(__assign({}, InputBaseProps), { autoFocus: isSearchAutoFocus, onClick: noop });
|
|
6414
|
+
}, [InputBaseProps, isSearchAutoFocus]);
|
|
6415
6415
|
return (jsx(PopperComponent, __assign({ id: id, modifiers: [
|
|
6416
6416
|
{
|
|
6417
6417
|
name: "offset",
|
|
@@ -7406,29 +7406,29 @@ var templateObject_1$A, templateObject_2$n;
|
|
|
7406
7406
|
|
|
7407
7407
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
7408
7408
|
var Dropdown = function (props) {
|
|
7409
|
-
var options = props.options, _a = props.label, label = _a === void 0 ? "" : _a, _b = props.multiple, multiple = _b === void 0 ? false : _b, _c = props.search, search = _c === void 0 ? false : _c, _d = props.buttonPosition, buttonPosition =
|
|
7409
|
+
var options = props.options, _a = props.label, label = _a === void 0 ? "" : _a, _b = props.multiple, multiple = _b === void 0 ? false : _b, _c = props.search, search = _c === void 0 ? false : _c, _d = props.isSearchAutoFocus, isSearchAutoFocus = _d === void 0 ? true : _d, _e = props.buttonPosition, buttonPosition = _e === void 0 ? "right" : _e, _f = props.buttons, buttons = _f === void 0 ? false : _f,
|
|
7410
7410
|
// By default, most dropdowns will close when the user clicks outside the dropdown.
|
|
7411
7411
|
// The exception is the multiple select variant with Apply/Cancel buttons,
|
|
7412
7412
|
// which by default will not close on blur. If closeOnBlur is enabled, clicking out
|
|
7413
7413
|
// is equivalent to clicking the Cancel button, closing the dropdown and losing
|
|
7414
7414
|
// unapplied changes.
|
|
7415
|
-
|
|
7415
|
+
_g = props.closeOnBlur,
|
|
7416
7416
|
// By default, most dropdowns will close when the user clicks outside the dropdown.
|
|
7417
7417
|
// The exception is the multiple select variant with Apply/Cancel buttons,
|
|
7418
7418
|
// which by default will not close on blur. If closeOnBlur is enabled, clicking out
|
|
7419
7419
|
// is equivalent to clicking the Cancel button, closing the dropdown and losing
|
|
7420
7420
|
// unapplied changes.
|
|
7421
|
-
closeOnBlur =
|
|
7421
|
+
closeOnBlur = _g === void 0 ? !buttons : _g, onClose = props.onClose, onChange = props.onChange, _h = props.DropdownMenuProps, DropdownMenuProps = _h === void 0 ? {} : _h, _j = props.InputDropdownProps, InputDropdownProps = _j === void 0 ? { sdsStyle: "minimal" } : _j, _k = props.InputDropdownComponent, InputDropdownComponent = _k === void 0 ? InputDropdown : _k, _l = props.isTriggerChangeOnOptionClick, isTriggerChangeOnOptionClick = _l === void 0 ? false : _l, _m = props.disabled, disabled = _m === void 0 ? false : _m, propValue = props.value, onClick = props.onClick, rest = __rest(props, ["options", "label", "multiple", "search", "isSearchAutoFocus", "buttonPosition", "buttons", "closeOnBlur", "onClose", "onChange", "DropdownMenuProps", "InputDropdownProps", "InputDropdownComponent", "isTriggerChangeOnOptionClick", "disabled", "value", "onClick"]);
|
|
7422
7422
|
if (buttons && !multiple) {
|
|
7423
7423
|
// eslint-disable-next-line no-console
|
|
7424
7424
|
console.warn("Warning: buttons are only supported for multiple select dropdowns.");
|
|
7425
7425
|
}
|
|
7426
7426
|
var isMultiColumn = "options" in ((options === null || options === void 0 ? void 0 : options[0]) || EMPTY_OBJECT);
|
|
7427
7427
|
var isControlled = propValue !== undefined;
|
|
7428
|
-
var
|
|
7429
|
-
var
|
|
7430
|
-
var
|
|
7431
|
-
var
|
|
7428
|
+
var _o = useState(null), anchorEl = _o[0], setAnchorEl = _o[1];
|
|
7429
|
+
var _p = useState(false), open = _p[0], setOpen = _p[1];
|
|
7430
|
+
var _q = useState(getInitialValue()), value = _q[0], setValue = _q[1];
|
|
7431
|
+
var _r = useState(getInitialValue()), pendingValue = _r[0], setPendingValue = _r[1];
|
|
7432
7432
|
var shouldShowButtons = buttons && !isTriggerChangeOnOptionClick && multiple;
|
|
7433
7433
|
useEffect(function () {
|
|
7434
7434
|
if (isControlled) {
|
|
@@ -7438,7 +7438,7 @@ var Dropdown = function (props) {
|
|
|
7438
7438
|
}
|
|
7439
7439
|
}
|
|
7440
7440
|
}, [isControlled, propValue, multiple]);
|
|
7441
|
-
return (jsxs(Fragment, { children: [jsx(InputDropdownComponent, __assign({ disabled: disabled, label: label, onClick: handleClick }, InputDropdownProps, rest)), jsx(DropdownMenu, __assign({ anchorEl: anchorEl, open: open, search: search, onClose: handleClose, multiple: multiple, disableCloseOnSelect: multiple, options: options, onClickAway: handleClickAway, width: 250, onChange: handleChange, value: isMultiColumn ? value : multiple ? pendingValue : value }, DropdownMenuProps, rest, { children: shouldShowButtons ? (jsx(StyledButtonsWrapper, { buttonPosition: buttonPosition, children: buttonPosition === "left" ? (jsxs("div", { children: [jsx(StyledButton, { onClick: handleButtonClose, sdsStyle: "square", sdsType: "primary", children: "Apply" }), jsx(StyledButton, { onClick: handleCancel, sdsStyle: "square", sdsType: "secondary", children: "Cancel" })] })) : (jsxs("div", { children: [jsx(StyledButton, { onClick: handleCancel, sdsStyle: "square", sdsType: "secondary", children: "Cancel" }), jsx(StyledButton, { onClick: handleButtonClose, sdsStyle: "square", sdsType: "primary", children: "Apply" })] })) })) : null }))] }));
|
|
7441
|
+
return (jsxs(Fragment, { children: [jsx(InputDropdownComponent, __assign({ disabled: disabled, label: label, onClick: handleClick }, InputDropdownProps, rest)), jsx(DropdownMenu, __assign({ anchorEl: anchorEl, open: open, search: search, onClose: handleClose, multiple: multiple, disableCloseOnSelect: multiple, options: options, onClickAway: handleClickAway, width: 250, onChange: handleChange, value: isMultiColumn ? value : multiple ? pendingValue : value, isSearchAutoFocus: isSearchAutoFocus }, DropdownMenuProps, rest, { children: shouldShowButtons ? (jsx(StyledButtonsWrapper, { buttonPosition: buttonPosition, children: buttonPosition === "left" ? (jsxs("div", { children: [jsx(StyledButton, { onClick: handleButtonClose, sdsStyle: "square", sdsType: "primary", children: "Apply" }), jsx(StyledButton, { onClick: handleCancel, sdsStyle: "square", sdsType: "secondary", children: "Cancel" })] })) : (jsxs("div", { children: [jsx(StyledButton, { onClick: handleCancel, sdsStyle: "square", sdsType: "secondary", children: "Cancel" }), jsx(StyledButton, { onClick: handleButtonClose, sdsStyle: "square", sdsType: "primary", children: "Apply" })] })) })) : null }))] }));
|
|
7442
7442
|
function getInitialValue() {
|
|
7443
7443
|
return multiple
|
|
7444
7444
|
? []
|