@czi-sds/components 20.1.0 → 20.1.1
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 +8 -3
- package/dist/index.cjs.js +128 -30
- package/dist/index.esm.d.ts +8 -3
- package/dist/index.esm.js +128 -30
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/index.cjs.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AccordionProps as RawAccordionProps } from "@mui/material";
|
|
|
4
4
|
import { AccordionSummaryProps as RawAccordionSummaryProps } from "@mui/material";
|
|
5
5
|
import { AutocompleteChangeDetails as AutocompleteChangeDetails$0 } from "@mui/material";
|
|
6
6
|
import { AutocompleteChangeReason as AutocompleteChangeReason$0 } from "@mui/material";
|
|
7
|
+
import { AutocompleteCloseReason as AutocompleteCloseReason$0 } from "@mui/material";
|
|
7
8
|
import { AutocompleteValue as AutocompleteValue$0 } from "@mui/material";
|
|
8
9
|
import { AutocompleteProps as MuiAutocompleteProps } from "@mui/material";
|
|
9
10
|
import { TextFieldProps as RawTextFieldSearchProps } from "@mui/material";
|
|
@@ -35,7 +36,7 @@ import { CSSProperties, ReactElement, ReactNode, SyntheticEvent, ComponentType }
|
|
|
35
36
|
import { Theme, ThemeOptions, TypographyStyle, PaletteOptions } from "@mui/material/styles";
|
|
36
37
|
import { SerializedStyles } from "@emotion/react";
|
|
37
38
|
import { AlertProps } from "@mui/lab";
|
|
38
|
-
import { AutocompleteChangeDetails, AutocompleteChangeReason, AutocompleteValue } from "@mui/base";
|
|
39
|
+
import { AutocompleteChangeDetails, AutocompleteChangeReason, AutocompleteCloseReason, AutocompleteValue } from "@mui/base";
|
|
39
40
|
import { AlertTitleProps } from "@mui/material/AlertTitle";
|
|
40
41
|
import { AutocompleteValue as AutocompleteValue$1 } from "@mui/material/useAutocomplete";
|
|
41
42
|
declare const AccordionDetails: (props: AccordionDetailsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -791,6 +792,8 @@ interface ExtraAutocompleteProps<T, Multiple, DisableClearable, FreeSolo> extend
|
|
|
791
792
|
onChange?: (event: React.SyntheticEvent, value: AutocompleteValue$0<T, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason$0, details?: AutocompleteChangeDetails$0<T>) => void;
|
|
792
793
|
InputBaseProps?: Partial<InputSearchProps>;
|
|
793
794
|
label?: string;
|
|
795
|
+
onClickAway?: (event?: MouseEvent | TouchEvent, reason?: AutocompleteCloseReason$0) => void;
|
|
796
|
+
onClick?: (event?: TouchEvent | MouseEvent) => void;
|
|
794
797
|
}
|
|
795
798
|
type CustomAutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined> = Omit<MuiAutocompleteProps<T, Multiple, DisableClearable, FreeSolo>, "renderInput" | "nonce" | "rev" | "rel" | "autoFocus" | "content">;
|
|
796
799
|
type AutocompleteBaseProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined> = CustomAutocompleteProps<T, Multiple, DisableClearable, FreeSolo> & ExtraAutocompleteProps<T, Multiple, DisableClearable, FreeSolo>;
|
|
@@ -824,7 +827,8 @@ interface ExtraAutocompleteMultiColumnProps<T, Multiple extends boolean | undefi
|
|
|
824
827
|
PopperComponent?: React.JSXElementConstructor<PopperProps>;
|
|
825
828
|
PopperPlacement?: "bottom-start" | "top-start" | "bottom-end" | "top-end";
|
|
826
829
|
children?: JSX.Element | null;
|
|
827
|
-
onClickAway?: (event
|
|
830
|
+
onClickAway?: (event?: MouseEvent | TouchEvent, reason?: AutocompleteCloseReason$0) => void;
|
|
831
|
+
onClick?: (event?: TouchEvent | MouseEvent) => void;
|
|
828
832
|
ClickAwayListenerProps?: Partial<MUIClickAwayListenerProps>;
|
|
829
833
|
options: AutocompleteMultiColumnOption<T, Multiple, DisableClearable, FreeSolo>[];
|
|
830
834
|
value?: AutocompleteMultiColumnValue<T, Multiple, DisableClearable, FreeSolo>;
|
|
@@ -851,7 +855,8 @@ interface ExtraAutocompleteProps$0<T, Multiple extends boolean | undefined, Disa
|
|
|
851
855
|
options: SDSAutocompleteOptions<T, Multiple, DisableClearable, FreeSolo>;
|
|
852
856
|
PopperBaseProps?: Partial<PopperProps>;
|
|
853
857
|
value?: SDSAutocompleteValue<T, Multiple, DisableClearable, FreeSolo>;
|
|
854
|
-
onClickAway?: (event
|
|
858
|
+
onClickAway?: (event?: MouseEvent | TouchEvent, reason?: AutocompleteCloseReason) => void;
|
|
859
|
+
onClick?: (event?: TouchEvent | MouseEvent) => void;
|
|
855
860
|
onChange?: SDSAutocompleteOnChange<T, Multiple, DisableClearable, FreeSolo>;
|
|
856
861
|
count?: number;
|
|
857
862
|
icon?: ReactElement;
|
package/dist/index.cjs.js
CHANGED
|
@@ -4258,25 +4258,37 @@ var StyledMenuItemText = styles.styled("div")(templateObject_6$7 || (templateObj
|
|
|
4258
4258
|
var templateObject_1$K, templateObject_2$s, templateObject_3$k, templateObject_4$h, templateObject_5$b, templateObject_6$7;
|
|
4259
4259
|
|
|
4260
4260
|
var AutocompleteBase = function (props) {
|
|
4261
|
-
var multiple = props.multiple, _a = props.disableCloseOnSelect, disableCloseOnSelect = _a === void 0 ? multiple : _a, _b = props.getOptionLabel, getOptionLabel = _b === void 0 ? defaultGetOptionLabel : _b, _c = props.InputBaseProps, InputBaseProps = _c === void 0 ? EMPTY_OBJECT : _c, _d = props.isOptionEqualToValue, isOptionEqualToValue = _d === void 0 ? defaultIsOptionEqualToValue : _d, _e = props.keepSearchOnSelect, keepSearchOnSelect = _e === void 0 ? false : _e, _f = props.label, label = _f === void 0 ? "Label" : _f, _g = props.loading, loading = _g === void 0 ? false : _g, _h = props.loadingText, loadingText = _h === void 0 ? "" : _h, _j = props.noOptionsText, noOptionsText = _j === void 0 ? "No options" : _j, _k = props.onInputChange, onInputChange = _k === void 0 ? noop : _k, _l = props.renderOption, renderOption = _l === void 0 ? defaultRenderOption : _l, _m = props.renderTags, renderTags = _m === void 0 ? defaultRenderTags : _m, _o = props.search, search = _o === void 0 ? false : _o, _p = props.clearOnBlur, clearOnBlur = _p === void 0 ? false : _p, _q = props.blurOnSelect, blurOnSelect = _q === void 0 ? !multiple : _q;
|
|
4261
|
+
var multiple = props.multiple, _a = props.disableCloseOnSelect, disableCloseOnSelect = _a === void 0 ? multiple : _a, _b = props.getOptionLabel, getOptionLabel = _b === void 0 ? defaultGetOptionLabel : _b, _c = props.InputBaseProps, InputBaseProps = _c === void 0 ? EMPTY_OBJECT : _c, _d = props.isOptionEqualToValue, isOptionEqualToValue = _d === void 0 ? defaultIsOptionEqualToValue : _d, _e = props.keepSearchOnSelect, keepSearchOnSelect = _e === void 0 ? false : _e, _f = props.label, label = _f === void 0 ? "Label" : _f, _g = props.loading, loading = _g === void 0 ? false : _g, _h = props.loadingText, loadingText = _h === void 0 ? "" : _h, _j = props.noOptionsText, noOptionsText = _j === void 0 ? "No options" : _j, _k = props.onInputChange, onInputChange = _k === void 0 ? noop : _k, _l = props.renderOption, renderOption = _l === void 0 ? defaultRenderOption : _l, _m = props.renderTags, renderTags = _m === void 0 ? defaultRenderTags : _m, _o = props.search, search = _o === void 0 ? false : _o, _p = props.clearOnBlur, clearOnBlur = _p === void 0 ? false : _p, _q = props.blurOnSelect, blurOnSelect = _q === void 0 ? !multiple : _q, onClickAway = props.onClickAway, onClick = props.onClick, onOpen = props.onOpen, onClose = props.onClose;
|
|
4262
4262
|
var theme = styles.useTheme();
|
|
4263
4263
|
var _r = React.useState(""), inputValue = _r[0], setInputValue = _r[1];
|
|
4264
|
-
return (jsxRuntime.jsx(StyledAutocompleteBase, __assign({ clearOnBlur: clearOnBlur, disableCloseOnSelect: disableCloseOnSelect, disablePortal: true, renderTags: renderTags, loading: loading, loadingText: loadingText, noOptionsText: noOptionsText, PaperComponent: StyledPaper$3, PopperComponent: useDefaultPopperComponent(), renderOption: renderOption, getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue, inputValue: inputValue, renderInput: defaultRenderInput, multiple: multiple
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4264
|
+
return (jsxRuntime.jsx(StyledAutocompleteBase, __assign({ clearOnBlur: clearOnBlur, disableCloseOnSelect: disableCloseOnSelect, disablePortal: true, renderTags: renderTags, loading: loading, loadingText: loadingText, noOptionsText: noOptionsText, PaperComponent: StyledPaper$3, PopperComponent: useDefaultPopperComponent(), renderOption: renderOption, getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue, inputValue: inputValue, renderInput: defaultRenderInput, multiple: multiple,
|
|
4265
|
+
/**
|
|
4266
|
+
* (masoudmanson): Overrides the onOpen and onClose handlers to ensure that
|
|
4267
|
+
* the onClick and onClickAway handlers are triggered when a controlled dropdown
|
|
4268
|
+
* is opened or closed, respectively.
|
|
4269
|
+
*/
|
|
4270
|
+
onOpen: defaultOnOpen, onClose: defaultOnClose }, props, {
|
|
4271
|
+
/**
|
|
4272
|
+
* (masoudmanson): For multiple options (multiple = true), setting blurOnSelect to false
|
|
4273
|
+
* keeps the dropdown open after selecting an option. This feature enhances user experience
|
|
4274
|
+
* by preventing the dropdown from closing, enabling users to select multiple options
|
|
4275
|
+
* without having to reopen the menu repeatedly.
|
|
4276
|
+
*/
|
|
4269
4277
|
blurOnSelect: multiple ? false : blurOnSelect,
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4278
|
+
/**
|
|
4279
|
+
* (masoudmanson): Given the necessity of maintaining consistent onBlur functionality,
|
|
4280
|
+
* and clearing the input value on blur, it's crucial to include the onBlur handler
|
|
4281
|
+
* after spreading other props. Furthermore, within the defaultOnBlur function, the
|
|
4282
|
+
* actual onBlur function is invoked for completeness.
|
|
4283
|
+
*/
|
|
4274
4284
|
onBlur: defaultOnBlur,
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4285
|
+
/**
|
|
4286
|
+
* (masoudmanson): To ensure component-level actions (changing the input field value)
|
|
4287
|
+
* trigger upon input changes, it's crucial to position the onInputChange handler after
|
|
4288
|
+
* spreading the other props. Furthermore, within the defaultOnInputChange function,
|
|
4289
|
+
* the provided onInputChange from props is called at the end to emit the input changes
|
|
4290
|
+
* to the user.
|
|
4291
|
+
*/
|
|
4280
4292
|
onInputChange: defaultOnInputChange })));
|
|
4281
4293
|
/**
|
|
4282
4294
|
* (masoudmanson): Using a custom Popper or Paper with the Autocomplete
|
|
@@ -4320,6 +4332,24 @@ var AutocompleteBase = function (props) {
|
|
|
4320
4332
|
setInputValue("");
|
|
4321
4333
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
4322
4334
|
}
|
|
4335
|
+
/**
|
|
4336
|
+
* (masoudmanson): The default onOpen handler is the Callback fired when the popup
|
|
4337
|
+
* requests to be opened. This function is responsible for invoking the onOpen and onClick
|
|
4338
|
+
* handlers when a controlled dropdown is opening.
|
|
4339
|
+
*/
|
|
4340
|
+
function defaultOnOpen(event) {
|
|
4341
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen(event);
|
|
4342
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
4343
|
+
}
|
|
4344
|
+
/**
|
|
4345
|
+
* (masoudmanson): The default onClose handler is the callback fired when the popup
|
|
4346
|
+
* requests to be closed. This function is responsible for invoking the onClose and onClickAway
|
|
4347
|
+
* handlers when a controlled dropdown is closing.
|
|
4348
|
+
*/
|
|
4349
|
+
function defaultOnClose(event, reason) {
|
|
4350
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(event, reason);
|
|
4351
|
+
onClickAway === null || onClickAway === void 0 ? void 0 : onClickAway(event, reason);
|
|
4352
|
+
}
|
|
4323
4353
|
function defaultOnInputChange(event, value, reason) {
|
|
4324
4354
|
if (!multiple) {
|
|
4325
4355
|
if (reason === "input") {
|
|
@@ -4480,16 +4510,26 @@ var templateObject_1$I, templateObject_2$q, templateObject_3$i, templateObject_4
|
|
|
4480
4510
|
|
|
4481
4511
|
var AutocompleteMultiColumn = function (props) {
|
|
4482
4512
|
var _a;
|
|
4483
|
-
var InputBaseProps = props.InputBaseProps,
|
|
4513
|
+
var InputBaseProps = props.InputBaseProps, open = props.open, _b = props.PopperPlacement, PopperPlacement = _b === void 0 ? "bottom-start" : _b, PopperBaseProps = props.PopperBaseProps, _c = props.search, search = _c === void 0 ? false : _c, _d = props.label, label = _d === void 0 ? "Search" : _d, onClickAway = props.onClickAway, onClick = props.onClick, ClickAwayListenerProps = props.ClickAwayListenerProps, options = props.options, onInputChange = props.onInputChange, onBlur = props.onBlur, multiple = props.multiple, parentInitialValue = props.value, onChange = props.onChange, _e = props.PopperComponent, PopperComponent = _e === void 0 ? StyledPopper$2 : _e, rest = __rest(props, ["InputBaseProps", "open", "PopperPlacement", "PopperBaseProps", "search", "label", "onClickAway", "onClick", "ClickAwayListenerProps", "options", "onInputChange", "onBlur", "multiple", "value", "onChange", "PopperComponent"]);
|
|
4484
4514
|
var theme = styles.useTheme();
|
|
4485
|
-
var
|
|
4486
|
-
var
|
|
4515
|
+
var isOpenControlled = open !== undefined;
|
|
4516
|
+
var _f = React.useState(""), inputValue = _f[0], setInputValue = _f[1];
|
|
4517
|
+
var _g = React.useState(isOpenControlled ? open : false), popperOpen = _g[0], setPopperOpen = _g[1];
|
|
4518
|
+
/**
|
|
4519
|
+
* (masoudmanson): This useEffect is used to update the popperOpen state
|
|
4520
|
+
* when the open prop is controlled.
|
|
4521
|
+
*/
|
|
4522
|
+
React.useEffect(function () {
|
|
4523
|
+
if (isOpenControlled) {
|
|
4524
|
+
setPopperOpen(open);
|
|
4525
|
+
}
|
|
4526
|
+
}, [isOpenControlled, open]);
|
|
4487
4527
|
var anchorRef = React.useRef(null);
|
|
4488
|
-
var
|
|
4528
|
+
var _h = React.useState(null), anchorEl = _h[0], setAnchorEl = _h[1];
|
|
4489
4529
|
React.useEffect(function () {
|
|
4490
4530
|
setAnchorEl(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current);
|
|
4491
4531
|
}, [anchorRef]);
|
|
4492
|
-
var
|
|
4532
|
+
var _j = React.useState({}), autocompleteMultiColumnValue = _j[0], setAutocompleteMultiColumnValue = _j[1];
|
|
4493
4533
|
React.useEffect(function () {
|
|
4494
4534
|
if (parentInitialValue !== undefined) {
|
|
4495
4535
|
setAutocompleteMultiColumnValue(parentInitialValue);
|
|
@@ -4503,7 +4543,7 @@ var AutocompleteMultiColumn = function (props) {
|
|
|
4503
4543
|
});
|
|
4504
4544
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, __assign(__assign({}, autocompleteMultiColumnValue), (_a = {}, _a[column] = val, _a)), reason, details);
|
|
4505
4545
|
};
|
|
4506
|
-
return (jsxRuntime.jsx(material.ClickAwayListener, __assign({ onClickAway:
|
|
4546
|
+
return (jsxRuntime.jsx(material.ClickAwayListener, __assign({ onClickAway: defaultOnClickAway }, ClickAwayListenerProps, { children: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(StyledAutocompleteInput, __assign({ id: "location-search", label: label, placeholder: label, value: inputValue, onChange: handleInputChange, onClick: handleInputClick, onBlur: handleInputBlur, ref: anchorRef, search: search, onKeyDown: handleInputKeyDown, InputProps: __assign(__assign({}, InputBaseProps === null || InputBaseProps === void 0 ? void 0 : InputBaseProps.ref), { endAdornment: (jsxRuntime.jsx(StyledInputAdornment, { position: "end", children: inputValue && (jsxRuntime.jsx(Button, { "aria-label": "clear-button", className: "input-search-clear-icon", sdsType: "tertiary", sdsSize: "small", sdsStyle: "icon", sdsIconProps: {
|
|
4507
4547
|
sdsType: "iconButton",
|
|
4508
4548
|
}, icon: "XMarkCircle", onClick: clearInput })) })),
|
|
4509
4549
|
/**
|
|
@@ -4530,7 +4570,22 @@ var AutocompleteMultiColumn = function (props) {
|
|
|
4530
4570
|
*/
|
|
4531
4571
|
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange({ target: { value: "" } }, "", "clear");
|
|
4532
4572
|
}
|
|
4533
|
-
function handleInputClick(
|
|
4573
|
+
function handleInputClick(event) {
|
|
4574
|
+
/**
|
|
4575
|
+
* (masoudmanson): Because the Autocomplete component overrides the
|
|
4576
|
+
* InputSearch's onClick, we must also include the parent onClick here.
|
|
4577
|
+
*/
|
|
4578
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
4579
|
+
/**
|
|
4580
|
+
* (masoudmanson): If the dropdown is controlled, we call the onClick prop to allow the parent
|
|
4581
|
+
* to handle the opening and closing of the dropdown.
|
|
4582
|
+
*/
|
|
4583
|
+
if (isOpenControlled) {
|
|
4584
|
+
return;
|
|
4585
|
+
}
|
|
4586
|
+
/**
|
|
4587
|
+
* (masoudmanson): If the dropdown is not controlled, we toggle the dropdown open and closed.
|
|
4588
|
+
*/
|
|
4534
4589
|
if (popperOpen) {
|
|
4535
4590
|
setPopperOpen(false);
|
|
4536
4591
|
}
|
|
@@ -4554,13 +4609,55 @@ var AutocompleteMultiColumn = function (props) {
|
|
|
4554
4609
|
setInputValue("");
|
|
4555
4610
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
4556
4611
|
}
|
|
4557
|
-
|
|
4558
|
-
|
|
4612
|
+
/**
|
|
4613
|
+
* (masoudmanson): This is the default onClickAway handler for the Autocomplete component.
|
|
4614
|
+
* It is used to close the dropdown when the user clicks away from the dropdown. It also
|
|
4615
|
+
* calls the parent onClickAway prop if it is provided.
|
|
4616
|
+
*/
|
|
4617
|
+
function defaultOnClickAway(event) {
|
|
4618
|
+
/**
|
|
4619
|
+
* (masoudmanson): We only want to close the dropdown if it is open.
|
|
4620
|
+
* This may sound unnecessary, but it is to prevent the dropdown from
|
|
4621
|
+
* calling the parent onClickAway prop when the dropdown is closed.
|
|
4622
|
+
*/
|
|
4623
|
+
if (popperOpen) {
|
|
4624
|
+
onClickAway === null || onClickAway === void 0 ? void 0 : onClickAway(event, "blur");
|
|
4625
|
+
/**
|
|
4626
|
+
* (masoudmanson): If the dropdown is controlled, we call the onClickAway prop to allow the parent
|
|
4627
|
+
* to handle the closing of the dropdown.
|
|
4628
|
+
*/
|
|
4629
|
+
if (isOpenControlled)
|
|
4630
|
+
return;
|
|
4631
|
+
// (masoudmanson): If the dropdown is not controlled, we close the dropdown.
|
|
4632
|
+
setPopperOpen(false);
|
|
4633
|
+
}
|
|
4559
4634
|
}
|
|
4560
4635
|
function handleInputKeyDown(event) {
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4636
|
+
var _a;
|
|
4637
|
+
/**
|
|
4638
|
+
* (masoudmanson): Because the Autocomplete component overrides the
|
|
4639
|
+
* InputSearch's onKeyDown, we must also include the user defined onKeyDown here.
|
|
4640
|
+
*/
|
|
4641
|
+
if (props === null || props === void 0 ? void 0 : props.onKeyDown) {
|
|
4642
|
+
(_a = props === null || props === void 0 ? void 0 : props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
4643
|
+
}
|
|
4644
|
+
else {
|
|
4645
|
+
// (masoudmanson): This prevents Backspace from deselecting selected dropdown options.
|
|
4646
|
+
if (event.key === "Backspace") {
|
|
4647
|
+
event.stopPropagation();
|
|
4648
|
+
}
|
|
4649
|
+
/**
|
|
4650
|
+
* (masoudmanson): This is to handle the Escape key to close the dropdown.
|
|
4651
|
+
* If the dropdown is controlled, we call the onClick prop to allow the parent
|
|
4652
|
+
* to handle the closing of the dropdown.
|
|
4653
|
+
*/
|
|
4654
|
+
if (event.key === "Escape") {
|
|
4655
|
+
if (isOpenControlled) {
|
|
4656
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
4657
|
+
return;
|
|
4658
|
+
}
|
|
4659
|
+
setPopperOpen(false);
|
|
4660
|
+
}
|
|
4564
4661
|
}
|
|
4565
4662
|
}
|
|
4566
4663
|
};
|
|
@@ -4572,7 +4669,7 @@ var Autocomplete = function (props) {
|
|
|
4572
4669
|
if (options.length > 1) {
|
|
4573
4670
|
return (jsxRuntime.jsx(AutocompleteMultiColumn, __assign({ options: options, value: value, onChange: onChange }, rest, {
|
|
4574
4671
|
// (masoudmanson): groupBy option is disabled on MultiColumn dropdowns
|
|
4575
|
-
groupBy: undefined
|
|
4672
|
+
groupBy: undefined })));
|
|
4576
4673
|
}
|
|
4577
4674
|
else {
|
|
4578
4675
|
return (jsxRuntime.jsx(AutocompleteBase, __assign({ options: options[0].options, value: value, onChange: onChange }, rest)));
|
|
@@ -5246,7 +5343,7 @@ var DropdownMenu = function (props) {
|
|
|
5246
5343
|
], open: open, anchorEl: anchorEl, placement: PopperPlacement }, PopperBaseProps, {
|
|
5247
5344
|
// (masoudmanson): To override the width of the Popper,
|
|
5248
5345
|
// the sx prop's value must be set after spreading the PopperBaseProps.
|
|
5249
|
-
sx: dropdownMenuPopperSx, children: jsxRuntime.jsx(PaperComponent, { children: jsxRuntime.jsx(material.ClickAwayListener, __assign({ onClickAway: onClickAway }, ClickAwayListenerProps, { children: jsxRuntime.jsxs(StyledDropdownMenuAutocompleteWrapper, { children: [title && (jsxRuntime.jsx(StyledHeaderTitle, { search: search, children: title })), anchorEl && (jsxRuntime.jsx(Autocomplete, __assign({ label: label, search: search, title: title, open: open, options: options, PopperBaseProps: DEFAULT_POPPER_BASE_PROPS, disablePortal: true, onClickAway: noop }, rest, { InputBaseProps: DefaultInputBaseProps }))), children] }) })) }) })));
|
|
5346
|
+
sx: dropdownMenuPopperSx, children: jsxRuntime.jsx(PaperComponent, { children: jsxRuntime.jsx(material.ClickAwayListener, __assign({ onClickAway: onClickAway }, ClickAwayListenerProps, { children: jsxRuntime.jsxs(StyledDropdownMenuAutocompleteWrapper, { children: [title && (jsxRuntime.jsx(StyledHeaderTitle, { search: search, children: title })), anchorEl && (jsxRuntime.jsx(Autocomplete, __assign({ label: label, search: search, title: title, open: open, options: options, PopperBaseProps: DEFAULT_POPPER_BASE_PROPS, disablePortal: true, onClickAway: noop, onClick: noop }, rest, { InputBaseProps: DefaultInputBaseProps }))), children] }) })) }) })));
|
|
5250
5347
|
};
|
|
5251
5348
|
|
|
5252
5349
|
var doNotForwardProps$e = [
|
|
@@ -5843,7 +5940,7 @@ var Dropdown = function (props) {
|
|
|
5843
5940
|
// which by default will not close on blur. If closeOnBlur is enabled, clicking out
|
|
5844
5941
|
// is equivalent to clicking the Cancel button, closing the dropdown and losing
|
|
5845
5942
|
// unapplied changes.
|
|
5846
|
-
closeOnBlur = _f === void 0 ? !buttons : _f, onClose = props.onClose, onChange = props.onChange, _g = props.DropdownMenuProps, DropdownMenuProps = _g === void 0 ? {} : _g, _h = props.InputDropdownProps, InputDropdownProps = _h === void 0 ? { sdsStyle: "minimal" } : _h, _j = props.InputDropdownComponent, InputDropdownComponent = _j === void 0 ? InputDropdown : _j, _k = props.isTriggerChangeOnOptionClick, isTriggerChangeOnOptionClick = _k === void 0 ? false : _k, _l = props.disabled, disabled = _l === void 0 ? false : _l, propValue = props.value, rest = __rest(props, ["options", "label", "multiple", "search", "buttonPosition", "buttons", "closeOnBlur", "onClose", "onChange", "DropdownMenuProps", "InputDropdownProps", "InputDropdownComponent", "isTriggerChangeOnOptionClick", "disabled", "value"]);
|
|
5943
|
+
closeOnBlur = _f === void 0 ? !buttons : _f, onClose = props.onClose, onChange = props.onChange, _g = props.DropdownMenuProps, DropdownMenuProps = _g === void 0 ? {} : _g, _h = props.InputDropdownProps, InputDropdownProps = _h === void 0 ? { sdsStyle: "minimal" } : _h, _j = props.InputDropdownComponent, InputDropdownComponent = _j === void 0 ? InputDropdown : _j, _k = props.isTriggerChangeOnOptionClick, isTriggerChangeOnOptionClick = _k === void 0 ? false : _k, _l = props.disabled, disabled = _l === void 0 ? false : _l, propValue = props.value, onClick = props.onClick, rest = __rest(props, ["options", "label", "multiple", "search", "buttonPosition", "buttons", "closeOnBlur", "onClose", "onChange", "DropdownMenuProps", "InputDropdownProps", "InputDropdownComponent", "isTriggerChangeOnOptionClick", "disabled", "value", "onClick"]);
|
|
5847
5944
|
if (buttons && !multiple) {
|
|
5848
5945
|
// eslint-disable-next-line no-console
|
|
5849
5946
|
console.warn("Warning: buttons are only supported for multiple select dropdowns.");
|
|
@@ -5893,6 +5990,7 @@ var Dropdown = function (props) {
|
|
|
5893
5990
|
}
|
|
5894
5991
|
}
|
|
5895
5992
|
function handleClick(event) {
|
|
5993
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
5896
5994
|
if (open) {
|
|
5897
5995
|
if (!shouldShowButtons) {
|
|
5898
5996
|
if (multiple) {
|
package/dist/index.esm.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AccordionProps as RawAccordionProps } from "@mui/material";
|
|
|
4
4
|
import { AccordionSummaryProps as RawAccordionSummaryProps } from "@mui/material";
|
|
5
5
|
import { AutocompleteChangeDetails as AutocompleteChangeDetails$0 } from "@mui/material";
|
|
6
6
|
import { AutocompleteChangeReason as AutocompleteChangeReason$0 } from "@mui/material";
|
|
7
|
+
import { AutocompleteCloseReason as AutocompleteCloseReason$0 } from "@mui/material";
|
|
7
8
|
import { AutocompleteValue as AutocompleteValue$0 } from "@mui/material";
|
|
8
9
|
import { AutocompleteProps as MuiAutocompleteProps } from "@mui/material";
|
|
9
10
|
import { TextFieldProps as RawTextFieldSearchProps } from "@mui/material";
|
|
@@ -35,7 +36,7 @@ import { CSSProperties, ReactElement, ReactNode, SyntheticEvent, ComponentType }
|
|
|
35
36
|
import { Theme, ThemeOptions, TypographyStyle, PaletteOptions } from "@mui/material/styles";
|
|
36
37
|
import { SerializedStyles } from "@emotion/react";
|
|
37
38
|
import { AlertProps } from "@mui/lab";
|
|
38
|
-
import { AutocompleteChangeDetails, AutocompleteChangeReason, AutocompleteValue } from "@mui/base";
|
|
39
|
+
import { AutocompleteChangeDetails, AutocompleteChangeReason, AutocompleteCloseReason, AutocompleteValue } from "@mui/base";
|
|
39
40
|
import { AlertTitleProps } from "@mui/material/AlertTitle";
|
|
40
41
|
import { AutocompleteValue as AutocompleteValue$1 } from "@mui/material/useAutocomplete";
|
|
41
42
|
declare const AccordionDetails: (props: AccordionDetailsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -791,6 +792,8 @@ interface ExtraAutocompleteProps<T, Multiple, DisableClearable, FreeSolo> extend
|
|
|
791
792
|
onChange?: (event: React.SyntheticEvent, value: AutocompleteValue$0<T, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason$0, details?: AutocompleteChangeDetails$0<T>) => void;
|
|
792
793
|
InputBaseProps?: Partial<InputSearchProps>;
|
|
793
794
|
label?: string;
|
|
795
|
+
onClickAway?: (event?: MouseEvent | TouchEvent, reason?: AutocompleteCloseReason$0) => void;
|
|
796
|
+
onClick?: (event?: TouchEvent | MouseEvent) => void;
|
|
794
797
|
}
|
|
795
798
|
type CustomAutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined> = Omit<MuiAutocompleteProps<T, Multiple, DisableClearable, FreeSolo>, "renderInput" | "nonce" | "rev" | "rel" | "autoFocus" | "content">;
|
|
796
799
|
type AutocompleteBaseProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined> = CustomAutocompleteProps<T, Multiple, DisableClearable, FreeSolo> & ExtraAutocompleteProps<T, Multiple, DisableClearable, FreeSolo>;
|
|
@@ -824,7 +827,8 @@ interface ExtraAutocompleteMultiColumnProps<T, Multiple extends boolean | undefi
|
|
|
824
827
|
PopperComponent?: React.JSXElementConstructor<PopperProps>;
|
|
825
828
|
PopperPlacement?: "bottom-start" | "top-start" | "bottom-end" | "top-end";
|
|
826
829
|
children?: JSX.Element | null;
|
|
827
|
-
onClickAway?: (event
|
|
830
|
+
onClickAway?: (event?: MouseEvent | TouchEvent, reason?: AutocompleteCloseReason$0) => void;
|
|
831
|
+
onClick?: (event?: TouchEvent | MouseEvent) => void;
|
|
828
832
|
ClickAwayListenerProps?: Partial<MUIClickAwayListenerProps>;
|
|
829
833
|
options: AutocompleteMultiColumnOption<T, Multiple, DisableClearable, FreeSolo>[];
|
|
830
834
|
value?: AutocompleteMultiColumnValue<T, Multiple, DisableClearable, FreeSolo>;
|
|
@@ -851,7 +855,8 @@ interface ExtraAutocompleteProps$0<T, Multiple extends boolean | undefined, Disa
|
|
|
851
855
|
options: SDSAutocompleteOptions<T, Multiple, DisableClearable, FreeSolo>;
|
|
852
856
|
PopperBaseProps?: Partial<PopperProps>;
|
|
853
857
|
value?: SDSAutocompleteValue<T, Multiple, DisableClearable, FreeSolo>;
|
|
854
|
-
onClickAway?: (event
|
|
858
|
+
onClickAway?: (event?: MouseEvent | TouchEvent, reason?: AutocompleteCloseReason) => void;
|
|
859
|
+
onClick?: (event?: TouchEvent | MouseEvent) => void;
|
|
855
860
|
onChange?: SDSAutocompleteOnChange<T, Multiple, DisableClearable, FreeSolo>;
|
|
856
861
|
count?: number;
|
|
857
862
|
icon?: ReactElement;
|
package/dist/index.esm.js
CHANGED
|
@@ -4238,25 +4238,37 @@ var StyledMenuItemText = styled("div")(templateObject_6$7 || (templateObject_6$7
|
|
|
4238
4238
|
var templateObject_1$K, templateObject_2$s, templateObject_3$k, templateObject_4$h, templateObject_5$b, templateObject_6$7;
|
|
4239
4239
|
|
|
4240
4240
|
var AutocompleteBase = function (props) {
|
|
4241
|
-
var multiple = props.multiple, _a = props.disableCloseOnSelect, disableCloseOnSelect = _a === void 0 ? multiple : _a, _b = props.getOptionLabel, getOptionLabel = _b === void 0 ? defaultGetOptionLabel : _b, _c = props.InputBaseProps, InputBaseProps = _c === void 0 ? EMPTY_OBJECT : _c, _d = props.isOptionEqualToValue, isOptionEqualToValue = _d === void 0 ? defaultIsOptionEqualToValue : _d, _e = props.keepSearchOnSelect, keepSearchOnSelect = _e === void 0 ? false : _e, _f = props.label, label = _f === void 0 ? "Label" : _f, _g = props.loading, loading = _g === void 0 ? false : _g, _h = props.loadingText, loadingText = _h === void 0 ? "" : _h, _j = props.noOptionsText, noOptionsText = _j === void 0 ? "No options" : _j, _k = props.onInputChange, onInputChange = _k === void 0 ? noop : _k, _l = props.renderOption, renderOption = _l === void 0 ? defaultRenderOption : _l, _m = props.renderTags, renderTags = _m === void 0 ? defaultRenderTags : _m, _o = props.search, search = _o === void 0 ? false : _o, _p = props.clearOnBlur, clearOnBlur = _p === void 0 ? false : _p, _q = props.blurOnSelect, blurOnSelect = _q === void 0 ? !multiple : _q;
|
|
4241
|
+
var multiple = props.multiple, _a = props.disableCloseOnSelect, disableCloseOnSelect = _a === void 0 ? multiple : _a, _b = props.getOptionLabel, getOptionLabel = _b === void 0 ? defaultGetOptionLabel : _b, _c = props.InputBaseProps, InputBaseProps = _c === void 0 ? EMPTY_OBJECT : _c, _d = props.isOptionEqualToValue, isOptionEqualToValue = _d === void 0 ? defaultIsOptionEqualToValue : _d, _e = props.keepSearchOnSelect, keepSearchOnSelect = _e === void 0 ? false : _e, _f = props.label, label = _f === void 0 ? "Label" : _f, _g = props.loading, loading = _g === void 0 ? false : _g, _h = props.loadingText, loadingText = _h === void 0 ? "" : _h, _j = props.noOptionsText, noOptionsText = _j === void 0 ? "No options" : _j, _k = props.onInputChange, onInputChange = _k === void 0 ? noop : _k, _l = props.renderOption, renderOption = _l === void 0 ? defaultRenderOption : _l, _m = props.renderTags, renderTags = _m === void 0 ? defaultRenderTags : _m, _o = props.search, search = _o === void 0 ? false : _o, _p = props.clearOnBlur, clearOnBlur = _p === void 0 ? false : _p, _q = props.blurOnSelect, blurOnSelect = _q === void 0 ? !multiple : _q, onClickAway = props.onClickAway, onClick = props.onClick, onOpen = props.onOpen, onClose = props.onClose;
|
|
4242
4242
|
var theme = useTheme();
|
|
4243
4243
|
var _r = useState(""), inputValue = _r[0], setInputValue = _r[1];
|
|
4244
|
-
return (jsx(StyledAutocompleteBase, __assign({ clearOnBlur: clearOnBlur, disableCloseOnSelect: disableCloseOnSelect, disablePortal: true, renderTags: renderTags, loading: loading, loadingText: loadingText, noOptionsText: noOptionsText, PaperComponent: StyledPaper$3, PopperComponent: useDefaultPopperComponent(), renderOption: renderOption, getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue, inputValue: inputValue, renderInput: defaultRenderInput, multiple: multiple
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4244
|
+
return (jsx(StyledAutocompleteBase, __assign({ clearOnBlur: clearOnBlur, disableCloseOnSelect: disableCloseOnSelect, disablePortal: true, renderTags: renderTags, loading: loading, loadingText: loadingText, noOptionsText: noOptionsText, PaperComponent: StyledPaper$3, PopperComponent: useDefaultPopperComponent(), renderOption: renderOption, getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue, inputValue: inputValue, renderInput: defaultRenderInput, multiple: multiple,
|
|
4245
|
+
/**
|
|
4246
|
+
* (masoudmanson): Overrides the onOpen and onClose handlers to ensure that
|
|
4247
|
+
* the onClick and onClickAway handlers are triggered when a controlled dropdown
|
|
4248
|
+
* is opened or closed, respectively.
|
|
4249
|
+
*/
|
|
4250
|
+
onOpen: defaultOnOpen, onClose: defaultOnClose }, props, {
|
|
4251
|
+
/**
|
|
4252
|
+
* (masoudmanson): For multiple options (multiple = true), setting blurOnSelect to false
|
|
4253
|
+
* keeps the dropdown open after selecting an option. This feature enhances user experience
|
|
4254
|
+
* by preventing the dropdown from closing, enabling users to select multiple options
|
|
4255
|
+
* without having to reopen the menu repeatedly.
|
|
4256
|
+
*/
|
|
4249
4257
|
blurOnSelect: multiple ? false : blurOnSelect,
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4258
|
+
/**
|
|
4259
|
+
* (masoudmanson): Given the necessity of maintaining consistent onBlur functionality,
|
|
4260
|
+
* and clearing the input value on blur, it's crucial to include the onBlur handler
|
|
4261
|
+
* after spreading other props. Furthermore, within the defaultOnBlur function, the
|
|
4262
|
+
* actual onBlur function is invoked for completeness.
|
|
4263
|
+
*/
|
|
4254
4264
|
onBlur: defaultOnBlur,
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4265
|
+
/**
|
|
4266
|
+
* (masoudmanson): To ensure component-level actions (changing the input field value)
|
|
4267
|
+
* trigger upon input changes, it's crucial to position the onInputChange handler after
|
|
4268
|
+
* spreading the other props. Furthermore, within the defaultOnInputChange function,
|
|
4269
|
+
* the provided onInputChange from props is called at the end to emit the input changes
|
|
4270
|
+
* to the user.
|
|
4271
|
+
*/
|
|
4260
4272
|
onInputChange: defaultOnInputChange })));
|
|
4261
4273
|
/**
|
|
4262
4274
|
* (masoudmanson): Using a custom Popper or Paper with the Autocomplete
|
|
@@ -4300,6 +4312,24 @@ var AutocompleteBase = function (props) {
|
|
|
4300
4312
|
setInputValue("");
|
|
4301
4313
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
4302
4314
|
}
|
|
4315
|
+
/**
|
|
4316
|
+
* (masoudmanson): The default onOpen handler is the Callback fired when the popup
|
|
4317
|
+
* requests to be opened. This function is responsible for invoking the onOpen and onClick
|
|
4318
|
+
* handlers when a controlled dropdown is opening.
|
|
4319
|
+
*/
|
|
4320
|
+
function defaultOnOpen(event) {
|
|
4321
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen(event);
|
|
4322
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
4323
|
+
}
|
|
4324
|
+
/**
|
|
4325
|
+
* (masoudmanson): The default onClose handler is the callback fired when the popup
|
|
4326
|
+
* requests to be closed. This function is responsible for invoking the onClose and onClickAway
|
|
4327
|
+
* handlers when a controlled dropdown is closing.
|
|
4328
|
+
*/
|
|
4329
|
+
function defaultOnClose(event, reason) {
|
|
4330
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(event, reason);
|
|
4331
|
+
onClickAway === null || onClickAway === void 0 ? void 0 : onClickAway(event, reason);
|
|
4332
|
+
}
|
|
4303
4333
|
function defaultOnInputChange(event, value, reason) {
|
|
4304
4334
|
if (!multiple) {
|
|
4305
4335
|
if (reason === "input") {
|
|
@@ -4460,16 +4490,26 @@ var templateObject_1$I, templateObject_2$q, templateObject_3$i, templateObject_4
|
|
|
4460
4490
|
|
|
4461
4491
|
var AutocompleteMultiColumn = function (props) {
|
|
4462
4492
|
var _a;
|
|
4463
|
-
var InputBaseProps = props.InputBaseProps,
|
|
4493
|
+
var InputBaseProps = props.InputBaseProps, open = props.open, _b = props.PopperPlacement, PopperPlacement = _b === void 0 ? "bottom-start" : _b, PopperBaseProps = props.PopperBaseProps, _c = props.search, search = _c === void 0 ? false : _c, _d = props.label, label = _d === void 0 ? "Search" : _d, onClickAway = props.onClickAway, onClick = props.onClick, ClickAwayListenerProps = props.ClickAwayListenerProps, options = props.options, onInputChange = props.onInputChange, onBlur = props.onBlur, multiple = props.multiple, parentInitialValue = props.value, onChange = props.onChange, _e = props.PopperComponent, PopperComponent = _e === void 0 ? StyledPopper$2 : _e, rest = __rest(props, ["InputBaseProps", "open", "PopperPlacement", "PopperBaseProps", "search", "label", "onClickAway", "onClick", "ClickAwayListenerProps", "options", "onInputChange", "onBlur", "multiple", "value", "onChange", "PopperComponent"]);
|
|
4464
4494
|
var theme = useTheme();
|
|
4465
|
-
var
|
|
4466
|
-
var
|
|
4495
|
+
var isOpenControlled = open !== undefined;
|
|
4496
|
+
var _f = useState(""), inputValue = _f[0], setInputValue = _f[1];
|
|
4497
|
+
var _g = useState(isOpenControlled ? open : false), popperOpen = _g[0], setPopperOpen = _g[1];
|
|
4498
|
+
/**
|
|
4499
|
+
* (masoudmanson): This useEffect is used to update the popperOpen state
|
|
4500
|
+
* when the open prop is controlled.
|
|
4501
|
+
*/
|
|
4502
|
+
useEffect(function () {
|
|
4503
|
+
if (isOpenControlled) {
|
|
4504
|
+
setPopperOpen(open);
|
|
4505
|
+
}
|
|
4506
|
+
}, [isOpenControlled, open]);
|
|
4467
4507
|
var anchorRef = useRef(null);
|
|
4468
|
-
var
|
|
4508
|
+
var _h = React__default.useState(null), anchorEl = _h[0], setAnchorEl = _h[1];
|
|
4469
4509
|
useEffect(function () {
|
|
4470
4510
|
setAnchorEl(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current);
|
|
4471
4511
|
}, [anchorRef]);
|
|
4472
|
-
var
|
|
4512
|
+
var _j = useState({}), autocompleteMultiColumnValue = _j[0], setAutocompleteMultiColumnValue = _j[1];
|
|
4473
4513
|
useEffect(function () {
|
|
4474
4514
|
if (parentInitialValue !== undefined) {
|
|
4475
4515
|
setAutocompleteMultiColumnValue(parentInitialValue);
|
|
@@ -4483,7 +4523,7 @@ var AutocompleteMultiColumn = function (props) {
|
|
|
4483
4523
|
});
|
|
4484
4524
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, __assign(__assign({}, autocompleteMultiColumnValue), (_a = {}, _a[column] = val, _a)), reason, details);
|
|
4485
4525
|
};
|
|
4486
|
-
return (jsx(ClickAwayListener, __assign({ onClickAway:
|
|
4526
|
+
return (jsx(ClickAwayListener, __assign({ onClickAway: defaultOnClickAway }, ClickAwayListenerProps, { children: jsxs("div", { children: [jsx(StyledAutocompleteInput, __assign({ id: "location-search", label: label, placeholder: label, value: inputValue, onChange: handleInputChange, onClick: handleInputClick, onBlur: handleInputBlur, ref: anchorRef, search: search, onKeyDown: handleInputKeyDown, InputProps: __assign(__assign({}, InputBaseProps === null || InputBaseProps === void 0 ? void 0 : InputBaseProps.ref), { endAdornment: (jsx(StyledInputAdornment, { position: "end", children: inputValue && (jsx(Button, { "aria-label": "clear-button", className: "input-search-clear-icon", sdsType: "tertiary", sdsSize: "small", sdsStyle: "icon", sdsIconProps: {
|
|
4487
4527
|
sdsType: "iconButton",
|
|
4488
4528
|
}, icon: "XMarkCircle", onClick: clearInput })) })),
|
|
4489
4529
|
/**
|
|
@@ -4510,7 +4550,22 @@ var AutocompleteMultiColumn = function (props) {
|
|
|
4510
4550
|
*/
|
|
4511
4551
|
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange({ target: { value: "" } }, "", "clear");
|
|
4512
4552
|
}
|
|
4513
|
-
function handleInputClick(
|
|
4553
|
+
function handleInputClick(event) {
|
|
4554
|
+
/**
|
|
4555
|
+
* (masoudmanson): Because the Autocomplete component overrides the
|
|
4556
|
+
* InputSearch's onClick, we must also include the parent onClick here.
|
|
4557
|
+
*/
|
|
4558
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
4559
|
+
/**
|
|
4560
|
+
* (masoudmanson): If the dropdown is controlled, we call the onClick prop to allow the parent
|
|
4561
|
+
* to handle the opening and closing of the dropdown.
|
|
4562
|
+
*/
|
|
4563
|
+
if (isOpenControlled) {
|
|
4564
|
+
return;
|
|
4565
|
+
}
|
|
4566
|
+
/**
|
|
4567
|
+
* (masoudmanson): If the dropdown is not controlled, we toggle the dropdown open and closed.
|
|
4568
|
+
*/
|
|
4514
4569
|
if (popperOpen) {
|
|
4515
4570
|
setPopperOpen(false);
|
|
4516
4571
|
}
|
|
@@ -4534,13 +4589,55 @@ var AutocompleteMultiColumn = function (props) {
|
|
|
4534
4589
|
setInputValue("");
|
|
4535
4590
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
4536
4591
|
}
|
|
4537
|
-
|
|
4538
|
-
|
|
4592
|
+
/**
|
|
4593
|
+
* (masoudmanson): This is the default onClickAway handler for the Autocomplete component.
|
|
4594
|
+
* It is used to close the dropdown when the user clicks away from the dropdown. It also
|
|
4595
|
+
* calls the parent onClickAway prop if it is provided.
|
|
4596
|
+
*/
|
|
4597
|
+
function defaultOnClickAway(event) {
|
|
4598
|
+
/**
|
|
4599
|
+
* (masoudmanson): We only want to close the dropdown if it is open.
|
|
4600
|
+
* This may sound unnecessary, but it is to prevent the dropdown from
|
|
4601
|
+
* calling the parent onClickAway prop when the dropdown is closed.
|
|
4602
|
+
*/
|
|
4603
|
+
if (popperOpen) {
|
|
4604
|
+
onClickAway === null || onClickAway === void 0 ? void 0 : onClickAway(event, "blur");
|
|
4605
|
+
/**
|
|
4606
|
+
* (masoudmanson): If the dropdown is controlled, we call the onClickAway prop to allow the parent
|
|
4607
|
+
* to handle the closing of the dropdown.
|
|
4608
|
+
*/
|
|
4609
|
+
if (isOpenControlled)
|
|
4610
|
+
return;
|
|
4611
|
+
// (masoudmanson): If the dropdown is not controlled, we close the dropdown.
|
|
4612
|
+
setPopperOpen(false);
|
|
4613
|
+
}
|
|
4539
4614
|
}
|
|
4540
4615
|
function handleInputKeyDown(event) {
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4616
|
+
var _a;
|
|
4617
|
+
/**
|
|
4618
|
+
* (masoudmanson): Because the Autocomplete component overrides the
|
|
4619
|
+
* InputSearch's onKeyDown, we must also include the user defined onKeyDown here.
|
|
4620
|
+
*/
|
|
4621
|
+
if (props === null || props === void 0 ? void 0 : props.onKeyDown) {
|
|
4622
|
+
(_a = props === null || props === void 0 ? void 0 : props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
4623
|
+
}
|
|
4624
|
+
else {
|
|
4625
|
+
// (masoudmanson): This prevents Backspace from deselecting selected dropdown options.
|
|
4626
|
+
if (event.key === "Backspace") {
|
|
4627
|
+
event.stopPropagation();
|
|
4628
|
+
}
|
|
4629
|
+
/**
|
|
4630
|
+
* (masoudmanson): This is to handle the Escape key to close the dropdown.
|
|
4631
|
+
* If the dropdown is controlled, we call the onClick prop to allow the parent
|
|
4632
|
+
* to handle the closing of the dropdown.
|
|
4633
|
+
*/
|
|
4634
|
+
if (event.key === "Escape") {
|
|
4635
|
+
if (isOpenControlled) {
|
|
4636
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
4637
|
+
return;
|
|
4638
|
+
}
|
|
4639
|
+
setPopperOpen(false);
|
|
4640
|
+
}
|
|
4544
4641
|
}
|
|
4545
4642
|
}
|
|
4546
4643
|
};
|
|
@@ -4552,7 +4649,7 @@ var Autocomplete = function (props) {
|
|
|
4552
4649
|
if (options.length > 1) {
|
|
4553
4650
|
return (jsx(AutocompleteMultiColumn, __assign({ options: options, value: value, onChange: onChange }, rest, {
|
|
4554
4651
|
// (masoudmanson): groupBy option is disabled on MultiColumn dropdowns
|
|
4555
|
-
groupBy: undefined
|
|
4652
|
+
groupBy: undefined })));
|
|
4556
4653
|
}
|
|
4557
4654
|
else {
|
|
4558
4655
|
return (jsx(AutocompleteBase, __assign({ options: options[0].options, value: value, onChange: onChange }, rest)));
|
|
@@ -5226,7 +5323,7 @@ var DropdownMenu = function (props) {
|
|
|
5226
5323
|
], open: open, anchorEl: anchorEl, placement: PopperPlacement }, PopperBaseProps, {
|
|
5227
5324
|
// (masoudmanson): To override the width of the Popper,
|
|
5228
5325
|
// the sx prop's value must be set after spreading the PopperBaseProps.
|
|
5229
|
-
sx: dropdownMenuPopperSx, children: jsx(PaperComponent, { children: jsx(ClickAwayListener, __assign({ onClickAway: onClickAway }, ClickAwayListenerProps, { children: jsxs(StyledDropdownMenuAutocompleteWrapper, { children: [title && (jsx(StyledHeaderTitle, { search: search, children: title })), anchorEl && (jsx(Autocomplete, __assign({ label: label, search: search, title: title, open: open, options: options, PopperBaseProps: DEFAULT_POPPER_BASE_PROPS, disablePortal: true, onClickAway: noop }, rest, { InputBaseProps: DefaultInputBaseProps }))), children] }) })) }) })));
|
|
5326
|
+
sx: dropdownMenuPopperSx, children: jsx(PaperComponent, { children: jsx(ClickAwayListener, __assign({ onClickAway: onClickAway }, ClickAwayListenerProps, { children: jsxs(StyledDropdownMenuAutocompleteWrapper, { children: [title && (jsx(StyledHeaderTitle, { search: search, children: title })), anchorEl && (jsx(Autocomplete, __assign({ label: label, search: search, title: title, open: open, options: options, PopperBaseProps: DEFAULT_POPPER_BASE_PROPS, disablePortal: true, onClickAway: noop, onClick: noop }, rest, { InputBaseProps: DefaultInputBaseProps }))), children] }) })) }) })));
|
|
5230
5327
|
};
|
|
5231
5328
|
|
|
5232
5329
|
var doNotForwardProps$e = [
|
|
@@ -5823,7 +5920,7 @@ var Dropdown = function (props) {
|
|
|
5823
5920
|
// which by default will not close on blur. If closeOnBlur is enabled, clicking out
|
|
5824
5921
|
// is equivalent to clicking the Cancel button, closing the dropdown and losing
|
|
5825
5922
|
// unapplied changes.
|
|
5826
|
-
closeOnBlur = _f === void 0 ? !buttons : _f, onClose = props.onClose, onChange = props.onChange, _g = props.DropdownMenuProps, DropdownMenuProps = _g === void 0 ? {} : _g, _h = props.InputDropdownProps, InputDropdownProps = _h === void 0 ? { sdsStyle: "minimal" } : _h, _j = props.InputDropdownComponent, InputDropdownComponent = _j === void 0 ? InputDropdown : _j, _k = props.isTriggerChangeOnOptionClick, isTriggerChangeOnOptionClick = _k === void 0 ? false : _k, _l = props.disabled, disabled = _l === void 0 ? false : _l, propValue = props.value, rest = __rest(props, ["options", "label", "multiple", "search", "buttonPosition", "buttons", "closeOnBlur", "onClose", "onChange", "DropdownMenuProps", "InputDropdownProps", "InputDropdownComponent", "isTriggerChangeOnOptionClick", "disabled", "value"]);
|
|
5923
|
+
closeOnBlur = _f === void 0 ? !buttons : _f, onClose = props.onClose, onChange = props.onChange, _g = props.DropdownMenuProps, DropdownMenuProps = _g === void 0 ? {} : _g, _h = props.InputDropdownProps, InputDropdownProps = _h === void 0 ? { sdsStyle: "minimal" } : _h, _j = props.InputDropdownComponent, InputDropdownComponent = _j === void 0 ? InputDropdown : _j, _k = props.isTriggerChangeOnOptionClick, isTriggerChangeOnOptionClick = _k === void 0 ? false : _k, _l = props.disabled, disabled = _l === void 0 ? false : _l, propValue = props.value, onClick = props.onClick, rest = __rest(props, ["options", "label", "multiple", "search", "buttonPosition", "buttons", "closeOnBlur", "onClose", "onChange", "DropdownMenuProps", "InputDropdownProps", "InputDropdownComponent", "isTriggerChangeOnOptionClick", "disabled", "value", "onClick"]);
|
|
5827
5924
|
if (buttons && !multiple) {
|
|
5828
5925
|
// eslint-disable-next-line no-console
|
|
5829
5926
|
console.warn("Warning: buttons are only supported for multiple select dropdowns.");
|
|
@@ -5873,6 +5970,7 @@ var Dropdown = function (props) {
|
|
|
5873
5970
|
}
|
|
5874
5971
|
}
|
|
5875
5972
|
function handleClick(event) {
|
|
5973
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
5876
5974
|
if (open) {
|
|
5877
5975
|
if (!shouldShowButtons) {
|
|
5878
5976
|
if (multiple) {
|