fix clrf to lf

This commit is contained in:
namushka 2024-04-18 11:31:58 +03:00
parent 4a5890fd6f
commit cef915143d
3 changed files with 522 additions and 521 deletions

View File

@ -1,322 +1,322 @@
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import React from "react";
import equal from "fast-deep-equal/react";
import { DropDown } from "../drop-down";
import { DropDownItem } from "../drop-down-item";
import { ComboButton } from "./sub-components/ComboButton";
import { StyledComboBox } from "./Combobox.styled";
import { ComboBoxSize } from "./Combobox.enums";
import type { ComboboxProps, TOption } from "./Combobox.types";
const compare = (prevProps: ComboboxProps, nextProps: ComboboxProps) => {
const needUpdate = equal(prevProps, nextProps);
return needUpdate;
};
const ComboBoxPure = (props: ComboboxProps) => {
const { selectedOption: selectedOptionProps } = props;
const [isOpen, setIsOpen] = React.useState(false);
const [selectedOption, setSelectedOption] =
React.useState(selectedOptionProps);
const ref = React.useRef<null | HTMLDivElement>(null);
// const stopAction = (e: any) => e.preventDefault();
// const setIsOpenAction = (value: boolean) => {
// const { setIsOpenItemAccess } = props;
// setIsOpen(value);
// setIsOpenItemAccess?.(value);
// };
const handleClickOutside = (e: Event) => {
const { withBackdrop, onBackdropClick, setIsOpenItemAccess, onToggle } =
props;
const target = e.target as HTMLElement;
if (ref.current && ref.current.contains(target)) return;
if (onToggle) return;
// onToggle?.(e, !isOpen);
setIsOpenItemAccess?.(!isOpen);
setIsOpen((v) => {
return !v;
});
if (withBackdrop && onBackdropClick) onBackdropClick();
};
const comboBoxClick = (e: React.MouseEvent) => {
const {
disableIconClick = true,
disableItemClick,
isDisabled,
onToggle,
isLoading,
setIsOpenItemAccess,
} = props;
const target = e.target as HTMLElement;
if (
isDisabled ||
disableItemClick ||
isLoading ||
(disableIconClick && e && target.closest(".optionalBlock")) ||
target.classList.contains("ScrollbarsCustom") ||
target.classList.contains("ScrollbarsCustom-Thumb") ||
target.classList.contains("ScrollbarsCustom-Track") ||
target.classList.contains("backdrop-active")
)
return;
onToggle?.(e, !isOpen);
setIsOpenItemAccess?.(!isOpen);
setIsOpen((v) => {
return !v;
});
};
const optionClick = (option: TOption) => {
const { onSelect } = props;
setSelectedOption({ ...option });
// setIsOpen((v) => {
// setIsOpenItemAccess?.(!v);
// return !v;
// });
onSelect?.(option);
};
const {
dropDownMaxHeight,
directionX,
directionY,
scaled = true,
size = ComboBoxSize.base,
type,
options,
advancedOptions,
isDisabled,
children,
noBorder,
scaledOptions,
displayType = "default",
textOverflow,
showDisabledItems,
comboIcon,
manualY,
manualX,
isDefaultMode = true,
manualWidth = "200px",
displaySelectedOption,
fixedDirection,
withBlur,
fillIcon,
offsetLeft,
modernView,
withBackdrop = true,
isAside,
withBackground,
advancedOptionsCount,
isMobileView,
withoutPadding,
isLoading,
isNoFixedHeightOptions,
hideMobileView,
forceCloseClickOutside,
withoutBackground,
opened,
setIsOpenItemAccess,
dropDownId,
title,
className,
plusBadgeValue,
} = props;
const { tabIndex, onClickSelectedItem } = props;
React.useEffect(() => {
setIsOpen(opened || false);
setIsOpenItemAccess?.(opened || false);
}, [opened, setIsOpenItemAccess, setIsOpen]);
React.useEffect(() => {
setSelectedOption(selectedOptionProps);
}, [selectedOptionProps]);
const dropDownMaxHeightProp = dropDownMaxHeight
? { maxHeight: dropDownMaxHeight }
: {};
const dropDownManualWidthProp =
scaledOptions && !isDefaultMode
? { manualWidth: "100%" }
: scaledOptions && ref.current
? { manualWidth: `${ref.current.clientWidth}px` }
: { manualWidth };
const optionsLength = options.length
? options.length
: displayType !== "toggle"
? 0
: 1;
const withAdvancedOptions =
React.isValidElement(advancedOptions) && !!advancedOptions?.props.children;
let optionsCount = optionsLength;
if (withAdvancedOptions) {
const advancedOptionsWithoutSeparator: TOption[] =
React.isValidElement(advancedOptions) && advancedOptions.props
? (advancedOptions.props as { children: TOption[] }).children.filter(
(option: TOption) => option.key !== "s1",
)
: [];
const advancedOptionsWithoutSeparatorLength =
advancedOptionsWithoutSeparator.length;
optionsCount =
advancedOptionsCount || advancedOptionsWithoutSeparatorLength
? advancedOptionsWithoutSeparatorLength
: 6;
}
const disableMobileView = optionsCount < 4 || hideMobileView;
const dropDownBody =
(advancedOptions as React.ReactNode) ||
(options.map((option: TOption) => {
const disabled =
option.disabled ||
(!displaySelectedOption && option.label === selectedOption.label);
const isActive =
displaySelectedOption && option.label === selectedOption.label;
const isSelected = option.label === selectedOption.label;
return (
<DropDownItem
{...option}
className="drop-down-item"
textOverflow={textOverflow}
key={option.key}
disabled={disabled}
onClick={() => optionClick(option)}
onClickSelectedItem={() => onClickSelectedItem?.(option)}
fillIcon={fillIcon}
isModern={noBorder}
isActive={isActive}
isSelected={isSelected}
/>
);
}) as React.ReactNode);
return (
<StyledComboBox
ref={ref}
scaled={scaled}
size={size}
onClick={comboBoxClick}
isOpen={isOpen}
disableMobileView={disableMobileView}
withoutPadding={withoutPadding}
data-testid="combobox"
title={title}
className={className}
// {...rest}
>
<ComboButton
noBorder={noBorder}
isDisabled={isDisabled}
selectedOption={selectedOption}
withOptions={optionsLength > 0}
optionsLength={optionsLength}
withAdvancedOptions={withAdvancedOptions}
innerContainer={children}
innerContainerClassName="optionalBlock"
isOpen={isOpen}
size={size}
scaled={scaled}
comboIcon={comboIcon}
modernView={modernView}
fillIcon={fillIcon}
tabIndex={tabIndex}
isLoading={isLoading}
type={type}
plusBadgeValue={plusBadgeValue}
/>
{displayType !== "toggle" && (
<DropDown
id={dropDownId}
className="dropdown-container not-selectable"
directionX={directionX}
directionY={directionY}
manualY={manualY}
manualX={manualX}
open={isOpen}
forwardedRef={ref}
clickOutsideAction={handleClickOutside}
style={advancedOptions ? { padding: "6px 0px" } : {}}
{...dropDownMaxHeightProp}
{...dropDownManualWidthProp}
showDisabledItems={showDisabledItems}
isDefaultMode={isDefaultMode}
fixedDirection={fixedDirection}
withBlur={withBlur}
offsetLeft={offsetLeft}
withBackdrop={withBackdrop}
isAside={isAside}
withBackground={withBackground}
isMobileView={isMobileView && !disableMobileView}
isNoFixedHeightOptions={isNoFixedHeightOptions}
forceCloseClickOutside={forceCloseClickOutside}
withoutBackground={withoutBackground}
eventTypes={["mousedown"]}
>
{dropDownBody}
</DropDown>
)}
</StyledComboBox>
);
};
export { ComboBoxPure };
export const ComboBox = React.memo(ComboBoxPure, compare);
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import React from "react";
import equal from "fast-deep-equal/react";
import { DropDown } from "../drop-down";
import { DropDownItem } from "../drop-down-item";
import { ComboButton } from "./sub-components/ComboButton";
import { StyledComboBox } from "./Combobox.styled";
import { ComboBoxSize } from "./Combobox.enums";
import type { ComboboxProps, TOption } from "./Combobox.types";
const compare = (prevProps: ComboboxProps, nextProps: ComboboxProps) => {
const needUpdate = equal(prevProps, nextProps);
return needUpdate;
};
const ComboBoxPure = (props: ComboboxProps) => {
const { selectedOption: selectedOptionProps } = props;
const [isOpen, setIsOpen] = React.useState(false);
const [selectedOption, setSelectedOption] =
React.useState(selectedOptionProps);
const ref = React.useRef<null | HTMLDivElement>(null);
// const stopAction = (e: any) => e.preventDefault();
// const setIsOpenAction = (value: boolean) => {
// const { setIsOpenItemAccess } = props;
// setIsOpen(value);
// setIsOpenItemAccess?.(value);
// };
const handleClickOutside = (e: Event) => {
const { withBackdrop, onBackdropClick, setIsOpenItemAccess, onToggle } =
props;
const target = e.target as HTMLElement;
if (ref.current && ref.current.contains(target)) return;
if (onToggle) return;
// onToggle?.(e, !isOpen);
setIsOpenItemAccess?.(!isOpen);
setIsOpen((v) => {
return !v;
});
if (withBackdrop && onBackdropClick) onBackdropClick();
};
const comboBoxClick = (e: React.MouseEvent) => {
const {
disableIconClick = true,
disableItemClick,
isDisabled,
onToggle,
isLoading,
setIsOpenItemAccess,
} = props;
const target = e.target as HTMLElement;
if (
isDisabled ||
disableItemClick ||
isLoading ||
(disableIconClick && e && target.closest(".optionalBlock")) ||
target.classList.contains("ScrollbarsCustom") ||
target.classList.contains("ScrollbarsCustom-Thumb") ||
target.classList.contains("ScrollbarsCustom-Track") ||
target.classList.contains("backdrop-active")
)
return;
onToggle?.(e, !isOpen);
setIsOpenItemAccess?.(!isOpen);
setIsOpen((v) => {
return !v;
});
};
const optionClick = (option: TOption) => {
const { onSelect } = props;
setSelectedOption({ ...option });
// setIsOpen((v) => {
// setIsOpenItemAccess?.(!v);
// return !v;
// });
onSelect?.(option);
};
const {
dropDownMaxHeight,
directionX,
directionY,
scaled = true,
size = ComboBoxSize.base,
type,
options,
advancedOptions,
isDisabled,
children,
noBorder,
scaledOptions,
displayType = "default",
textOverflow,
showDisabledItems,
comboIcon,
manualY,
manualX,
isDefaultMode = true,
manualWidth = "200px",
displaySelectedOption,
fixedDirection,
withBlur,
fillIcon,
offsetLeft,
modernView,
withBackdrop = true,
isAside,
withBackground,
advancedOptionsCount,
isMobileView,
withoutPadding,
isLoading,
isNoFixedHeightOptions,
hideMobileView,
forceCloseClickOutside,
withoutBackground,
opened,
setIsOpenItemAccess,
dropDownId,
title,
className,
plusBadgeValue,
} = props;
const { tabIndex, onClickSelectedItem } = props;
React.useEffect(() => {
setIsOpen(opened || false);
setIsOpenItemAccess?.(opened || false);
}, [opened, setIsOpenItemAccess, setIsOpen]);
React.useEffect(() => {
setSelectedOption(selectedOptionProps);
}, [selectedOptionProps]);
const dropDownMaxHeightProp = dropDownMaxHeight
? { maxHeight: dropDownMaxHeight }
: {};
const dropDownManualWidthProp =
scaledOptions && !isDefaultMode
? { manualWidth: "100%" }
: scaledOptions && ref.current
? { manualWidth: `${ref.current.clientWidth}px` }
: { manualWidth };
const optionsLength = options.length
? options.length
: displayType !== "toggle"
? 0
: 1;
const withAdvancedOptions =
React.isValidElement(advancedOptions) && !!advancedOptions?.props.children;
let optionsCount = optionsLength;
if (withAdvancedOptions) {
const advancedOptionsWithoutSeparator: TOption[] =
React.isValidElement(advancedOptions) && advancedOptions.props
? (advancedOptions.props as { children: TOption[] }).children.filter(
(option: TOption) => option.key !== "s1",
)
: [];
const advancedOptionsWithoutSeparatorLength =
advancedOptionsWithoutSeparator.length;
optionsCount =
advancedOptionsCount || advancedOptionsWithoutSeparatorLength
? advancedOptionsWithoutSeparatorLength
: 6;
}
const disableMobileView = optionsCount < 4 || hideMobileView;
const dropDownBody =
(advancedOptions as React.ReactNode) ||
(options.map((option: TOption) => {
const disabled =
option.disabled ||
(!displaySelectedOption && option.label === selectedOption.label);
const isActive =
displaySelectedOption && option.label === selectedOption.label;
const isSelected = option.label === selectedOption.label;
return (
<DropDownItem
{...option}
className="drop-down-item"
textOverflow={textOverflow}
key={option.key}
disabled={disabled}
onClick={() => optionClick(option)}
onClickSelectedItem={() => onClickSelectedItem?.(option)}
fillIcon={fillIcon}
isModern={noBorder}
isActive={isActive}
isSelected={isSelected}
/>
);
}) as React.ReactNode);
return (
<StyledComboBox
ref={ref}
scaled={scaled}
size={size}
onClick={comboBoxClick}
isOpen={isOpen}
disableMobileView={disableMobileView}
withoutPadding={withoutPadding}
data-testid="combobox"
title={title}
className={className}
// {...rest}
>
<ComboButton
noBorder={noBorder}
isDisabled={isDisabled}
selectedOption={selectedOption}
withOptions={optionsLength > 0}
optionsLength={optionsLength}
withAdvancedOptions={withAdvancedOptions}
innerContainer={children}
innerContainerClassName="optionalBlock"
isOpen={isOpen}
size={size}
scaled={scaled}
comboIcon={comboIcon}
modernView={modernView}
fillIcon={fillIcon}
tabIndex={tabIndex}
isLoading={isLoading}
type={type}
plusBadgeValue={plusBadgeValue}
/>
{displayType !== "toggle" && (
<DropDown
id={dropDownId}
className="dropdown-container not-selectable"
directionX={directionX}
directionY={directionY}
manualY={manualY}
manualX={manualX}
open={isOpen}
forwardedRef={ref}
clickOutsideAction={handleClickOutside}
style={advancedOptions ? { padding: "6px 0px" } : {}}
{...dropDownMaxHeightProp}
{...dropDownManualWidthProp}
showDisabledItems={showDisabledItems}
isDefaultMode={isDefaultMode}
fixedDirection={fixedDirection}
withBlur={withBlur}
offsetLeft={offsetLeft}
withBackdrop={withBackdrop}
isAside={isAside}
withBackground={withBackground}
isMobileView={isMobileView && !disableMobileView}
isNoFixedHeightOptions={isNoFixedHeightOptions}
forceCloseClickOutside={forceCloseClickOutside}
withoutBackground={withoutBackground}
eventTypes={["mousedown"]}
>
{dropDownBody}
</DropDown>
)}
</StyledComboBox>
);
};
export { ComboBoxPure };
export const ComboBox = React.memo(ComboBoxPure, compare);

View File

@ -1,198 +1,198 @@
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import { ShareAccessRights } from "../../enums";
import { TColorScheme } from "../../themes";
import { TDirectionX, TDirectionY } from "../../types";
import { ComboBoxDisplayType, ComboBoxSize } from "./Combobox.enums";
export type TCombobox = null | "badge" | "onlyIcon";
export type TOption =
| {
key: string | number;
icon?: string;
label: string;
color?: string;
backgroundColor?: string;
border?: string;
default?: boolean;
disabled?: boolean;
description?: string;
quota?: "free" | "paid";
isSeparator?: boolean;
isSelected?: boolean;
internal?: boolean;
access?: ShareAccessRights;
}
| {
key: string | number;
icon?: undefined;
label?: undefined;
color?: undefined;
backgroundColor?: undefined;
border?: undefined;
default?: undefined;
disabled?: undefined;
description?: undefined;
quota?: undefined;
isSeparator: true;
isSelected?: undefined;
internal?: undefined;
access?: ShareAccessRights;
};
export interface ComboboxProps {
/** Displays advanced options */
advancedOptions?: React.ReactNode;
/** Children elements */
children?: React.ReactNode;
/** Accepts class */
className?: string;
/** X direction position */
directionX?: TDirectionX;
/** Y direction position */
directionY?: TDirectionY;
/** Component Display Type */
displayType?: ComboBoxDisplayType;
/** Height of Dropdown */
dropDownMaxHeight?: number;
/** Displays disabled items when displayType !== toggle */
showDisabledItems?: boolean;
/** Accepts id */
id?: string;
/** Accepts id for dropdown container */
dropDownId?: string;
/** Indicates that component contains a backdrop */
withBackdrop?: boolean;
/** Indicates that component is disabled */
isDisabled?: boolean;
/** Indicates that component is displayed without borders */
noBorder?: boolean;
/** Is triggered whenever ComboBox is a selected option */
onSelect: (option: TOption) => void;
/** Sets the component open */
opened?: boolean;
/** Combo box options */
options: TOption[];
/** Indicates that component is scaled by parent */
scaled?: boolean;
/** Indicates that component`s options are scaled by ComboButton */
scaledOptions?: boolean;
/** Selected option */
selectedOption: TOption;
/** Sets the component's width from the default settings */
size?: ComboBoxSize;
/** Accepts css style */
style?: React.CSSProperties;
/** The event is triggered by clicking on a component when `displayType: toggle` */
onToggle?: (e: Event | React.MouseEvent, isOpen: boolean) => void;
/** Accepts css text-overflow */
textOverflow?: boolean;
/** Disables clicking on the icon */
disableIconClick?: boolean;
/** Sets the operation mode of the component. The default option is set to portal mode */
isDefaultMode?: boolean;
/** Y offset */
offsetDropDownY?: string;
/** Sets an icon that is displayed in the combo button */
comboIcon?: string;
/** Sets the precise distance from the parent */
manualY?: string;
/** Sets the precise distance from the parent */
manualX?: string;
/** Dropdown manual width */
manualWidth?: string;
/** Displays the selected option */
displaySelectedOption?: boolean;
/** Disables position checking. Used for explicit direction setting */
fixedDirection?: boolean;
/** Disables clicking on the item */
disableItemClick?: boolean;
/** Indicates that component will fill selected item icon */
fillIcon?: boolean;
/** Sets the left offset for the dropdown */
offsetLeft?: number;
/** Sets the combo-box to be displayed in modern view */
modernView?: boolean;
/** Count of advanced options */
advancedOptionsCount?: number;
/** Accepts css tab-index style */
tabIndex?: number;
/** Disables the combo box padding */
withoutPadding?: boolean;
/** Indicates when the component is loading */
isLoading?: boolean;
/** Type ComboBox */
type?: TCombobox;
setIsOpenItemAccess?: (value: boolean) => void;
onClickSelectedItem?: (option: TOption) => void;
withoutBackground?: boolean;
forceCloseClickOutside?: boolean;
/** The event is triggered by clicking outside the component when `withBackdrop === true` */
onBackdropClick?: () => void;
hideMobileView?: boolean;
isNoFixedHeightOptions?: boolean;
isMobileView?: boolean;
withBackground?: boolean;
isAside?: boolean;
withBlur?: boolean;
title?: string;
plusBadgeValue?: number;
}
export interface ComboButtonProps {
noBorder?: boolean;
isDisabled?: boolean;
selectedOption: TOption;
withOptions?: boolean;
optionsLength?: number;
withAdvancedOptions?: boolean;
innerContainer?: React.ReactNode;
innerContainerClassName?: string;
isOpen?: boolean;
size?: ComboBoxSize;
scaled?: boolean;
onClick?: () => void;
comboIcon?: string;
fillIcon?: boolean;
modernView?: boolean;
tabIndex?: number;
isLoading?: boolean;
type?: TCombobox;
plusBadgeValue?: number;
}
export interface ComboButtonThemeProps extends ComboButtonProps {
ref: React.LegacyRef<HTMLDivElement>;
$currentColorScheme?: TColorScheme;
interfaceDirection?: string;
containOptions?: number;
isSelected?: boolean;
className?: string;
displayArrow?: boolean;
children?: React.ReactNode;
}
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import { ShareAccessRights } from "../../enums";
import { TColorScheme } from "../../themes";
import { TDirectionX, TDirectionY } from "../../types";
import { ComboBoxDisplayType, ComboBoxSize } from "./Combobox.enums";
export type TCombobox = null | "badge" | "onlyIcon";
export type TOption =
| {
key: string | number;
icon?: string;
label: string;
color?: string;
backgroundColor?: string;
border?: string;
default?: boolean;
disabled?: boolean;
description?: string;
quota?: "free" | "paid";
isSeparator?: boolean;
isSelected?: boolean;
internal?: boolean;
access?: ShareAccessRights;
}
| {
key: string | number;
icon?: undefined;
label?: undefined;
color?: undefined;
backgroundColor?: undefined;
border?: undefined;
default?: undefined;
disabled?: undefined;
description?: undefined;
quota?: undefined;
isSeparator: true;
isSelected?: undefined;
internal?: undefined;
access?: ShareAccessRights;
};
export interface ComboboxProps {
/** Displays advanced options */
advancedOptions?: React.ReactNode;
/** Children elements */
children?: React.ReactNode;
/** Accepts class */
className?: string;
/** X direction position */
directionX?: TDirectionX;
/** Y direction position */
directionY?: TDirectionY;
/** Component Display Type */
displayType?: ComboBoxDisplayType;
/** Height of Dropdown */
dropDownMaxHeight?: number;
/** Displays disabled items when displayType !== toggle */
showDisabledItems?: boolean;
/** Accepts id */
id?: string;
/** Accepts id for dropdown container */
dropDownId?: string;
/** Indicates that component contains a backdrop */
withBackdrop?: boolean;
/** Indicates that component is disabled */
isDisabled?: boolean;
/** Indicates that component is displayed without borders */
noBorder?: boolean;
/** Is triggered whenever ComboBox is a selected option */
onSelect: (option: TOption) => void;
/** Sets the component open */
opened?: boolean;
/** Combo box options */
options: TOption[];
/** Indicates that component is scaled by parent */
scaled?: boolean;
/** Indicates that component`s options are scaled by ComboButton */
scaledOptions?: boolean;
/** Selected option */
selectedOption: TOption;
/** Sets the component's width from the default settings */
size?: ComboBoxSize;
/** Accepts css style */
style?: React.CSSProperties;
/** The event is triggered by clicking on a component when `displayType: toggle` */
onToggle?: (e: Event | React.MouseEvent, isOpen: boolean) => void;
/** Accepts css text-overflow */
textOverflow?: boolean;
/** Disables clicking on the icon */
disableIconClick?: boolean;
/** Sets the operation mode of the component. The default option is set to portal mode */
isDefaultMode?: boolean;
/** Y offset */
offsetDropDownY?: string;
/** Sets an icon that is displayed in the combo button */
comboIcon?: string;
/** Sets the precise distance from the parent */
manualY?: string;
/** Sets the precise distance from the parent */
manualX?: string;
/** Dropdown manual width */
manualWidth?: string;
/** Displays the selected option */
displaySelectedOption?: boolean;
/** Disables position checking. Used for explicit direction setting */
fixedDirection?: boolean;
/** Disables clicking on the item */
disableItemClick?: boolean;
/** Indicates that component will fill selected item icon */
fillIcon?: boolean;
/** Sets the left offset for the dropdown */
offsetLeft?: number;
/** Sets the combo-box to be displayed in modern view */
modernView?: boolean;
/** Count of advanced options */
advancedOptionsCount?: number;
/** Accepts css tab-index style */
tabIndex?: number;
/** Disables the combo box padding */
withoutPadding?: boolean;
/** Indicates when the component is loading */
isLoading?: boolean;
/** Type ComboBox */
type?: TCombobox;
setIsOpenItemAccess?: (value: boolean) => void;
onClickSelectedItem?: (option: TOption) => void;
withoutBackground?: boolean;
forceCloseClickOutside?: boolean;
/** The event is triggered by clicking outside the component when `withBackdrop === true` */
onBackdropClick?: () => void;
hideMobileView?: boolean;
isNoFixedHeightOptions?: boolean;
isMobileView?: boolean;
withBackground?: boolean;
isAside?: boolean;
withBlur?: boolean;
title?: string;
plusBadgeValue?: number;
}
export interface ComboButtonProps {
noBorder?: boolean;
isDisabled?: boolean;
selectedOption: TOption;
withOptions?: boolean;
optionsLength?: number;
withAdvancedOptions?: boolean;
innerContainer?: React.ReactNode;
innerContainerClassName?: string;
isOpen?: boolean;
size?: ComboBoxSize;
scaled?: boolean;
onClick?: () => void;
comboIcon?: string;
fillIcon?: boolean;
modernView?: boolean;
tabIndex?: number;
isLoading?: boolean;
type?: TCombobox;
plusBadgeValue?: number;
}
export interface ComboButtonThemeProps extends ComboButtonProps {
ref: React.LegacyRef<HTMLDivElement>;
$currentColorScheme?: TColorScheme;
interfaceDirection?: string;
containOptions?: number;
isSelected?: boolean;
className?: string;
displayArrow?: boolean;
children?: React.ReactNode;
}

View File

@ -47,7 +47,8 @@ Options have options:
- disabled - Make option disabled
- onClick - On click function
ComboBox perceives all property`s for positioning from DropDown!
ComboBox perceives all property`s for positioning from DropDown!
If you need to display a custom list of options, you must use advancedOptions property. Like this:
```js