@itcase/ui 1.8.149 → 1.8.151
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/{Avatar_cjs_D-M9sW20.js → Avatar_cjs_Dv_yLG9O.js} +1 -1
- package/dist/{Avatar_es_BTvbT36l.js → Avatar_es_Cp4-nxIj.js} +1 -1
- package/dist/{Button_cjs_CrbH_HYn.js → Button_cjs_CGIzPuXo.js} +4 -4
- package/dist/{Button_es_qNbDsXQg.js → Button_es_CtAnUzZA.js} +4 -4
- package/dist/{ChipsGroup_cjs_BNfzAmhc.js → ChipsGroup_cjs_DVizkQ4v.js} +1 -1
- package/dist/{ChipsGroup_es_UTiUhYs7.js → ChipsGroup_es_D3eiXGyK.js} +1 -1
- package/dist/{DatePicker_cjs_YWv3CCNF.js → DatePicker_cjs_D0iBBPU9.js} +3 -3
- package/dist/{DatePicker_es_CqKPt0Nw.js → DatePicker_es_DtBOEq-Q.js} +3 -3
- package/dist/{DropdownItem_cjs_FsiEMPDs.js → DropdownItem_cjs_u6-29C8x.js} +97 -60
- package/dist/{DropdownItem_es_BBKtNngp.js → DropdownItem_es_D2P4zJJ-.js} +97 -60
- package/dist/{Icon_cjs_DKzT-zmQ.js → Icon_cjs_B5o0K55R.js} +7 -7
- package/dist/{Icon_es_5JUPM7bP.js → Icon_es_BEhzKfrD.js} +7 -7
- package/dist/{Label_cjs_D2YMjCoS.js → Label_cjs_DRIwteHh.js} +1 -1
- package/dist/{Label_es_B5uGQwNN.js → Label_es_DYd2RwDK.js} +1 -1
- package/dist/cjs/components/Accordion.js +1 -1
- package/dist/cjs/components/Avatar.js +2 -2
- package/dist/cjs/components/AvatarStack.js +2 -2
- package/dist/cjs/components/Badge.js +1 -1
- package/dist/cjs/components/Breadcrumbs.js +1 -1
- package/dist/cjs/components/Button.js +2 -2
- package/dist/cjs/components/Cell.js +2 -2
- package/dist/cjs/components/Chips.js +2 -2
- package/dist/cjs/components/Choice.js +1 -1
- package/dist/cjs/components/CookiesWarning.js +2 -2
- package/dist/cjs/components/DatePeriod.js +5 -5
- package/dist/cjs/components/DatePicker.js +4 -4
- package/dist/cjs/components/Drawer.js +1 -1
- package/dist/cjs/components/Dropdown.js +3 -3
- package/dist/cjs/components/HeroTitle.js +1 -1
- package/dist/cjs/components/Icon.js +1 -1
- package/dist/cjs/components/InputPassword.js +1 -1
- package/dist/cjs/components/Label.js +2 -2
- package/dist/cjs/components/MenuItem.js +3 -3
- package/dist/cjs/components/Modal.js +1 -1
- package/dist/cjs/components/ModalSheetBottom.js +1 -1
- package/dist/cjs/components/Notification.js +2 -2
- package/dist/cjs/components/Pagination.js +2 -2
- package/dist/cjs/components/Response.js +8 -13
- package/dist/cjs/components/Search.js +1 -1
- package/dist/cjs/components/Segmented.js +1 -1
- package/dist/cjs/components/Select.js +1 -1
- package/dist/cjs/components/Swiper.js +1 -1
- package/dist/cjs/components/Tab.js +1 -1
- package/dist/cjs/components/Tile.js +1 -1
- package/dist/cjs/components/Title.js +1 -1
- package/dist/cjs/components/Tooltip.js +1 -1
- package/dist/cjs/components/Warning.js +1 -1
- package/dist/components/Accordion.js +1 -1
- package/dist/components/Avatar.js +2 -2
- package/dist/components/AvatarStack.js +2 -2
- package/dist/components/Badge.js +1 -1
- package/dist/components/Breadcrumbs.js +1 -1
- package/dist/components/Button.js +2 -2
- package/dist/components/Cell.js +2 -2
- package/dist/components/Chips.js +2 -2
- package/dist/components/Choice.js +1 -1
- package/dist/components/CookiesWarning.js +2 -2
- package/dist/components/DatePeriod.js +5 -5
- package/dist/components/DatePicker.js +4 -4
- package/dist/components/Drawer.js +1 -1
- package/dist/components/Dropdown.js +3 -3
- package/dist/components/HeroTitle.js +1 -1
- package/dist/components/Icon.js +1 -1
- package/dist/components/InputPassword.js +1 -1
- package/dist/components/Label.js +2 -2
- package/dist/components/MenuItem.js +3 -3
- package/dist/components/Modal.js +1 -1
- package/dist/components/ModalSheetBottom.js +1 -1
- package/dist/components/Notification.js +2 -2
- package/dist/components/Pagination.js +2 -2
- package/dist/components/Response.js +8 -13
- package/dist/components/Search.js +1 -1
- package/dist/components/Segmented.js +1 -1
- package/dist/components/Select.js +1 -1
- package/dist/components/Swiper.js +1 -1
- package/dist/components/Tab.js +1 -1
- package/dist/components/Tile.js +1 -1
- package/dist/components/Title.js +1 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/Warning.js +1 -1
- package/dist/css/components/Button/Button.css +56 -50
- package/dist/css/components/Dropdown/Dropdown.css +1 -9
- package/dist/types/components/Dropdown/Dropdown.appearance.d.ts +2 -0
- package/dist/types/components/Dropdown/appearance/dropdownShape.d.ts +3 -0
- package/dist/types/components/Response/Response.constant.d.ts +5 -10
- package/dist/types/config/forms/datepicker.d.ts +5 -5
- package/package.json +4 -4
|
@@ -5,7 +5,7 @@ var React = require('react');
|
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
var useAppearanceConfig = require('./cjs/hooks/useAppearanceConfig/useAppearanceConfig.js');
|
|
7
7
|
var useDevicePropsGenerator = require('./cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js');
|
|
8
|
-
var Icon = require('./
|
|
8
|
+
var Icon = require('./Icon_cjs_B5o0K55R.js');
|
|
9
9
|
var Image = require('./Image_cjs_BUM81t4Y.js');
|
|
10
10
|
var Text = require('./Text_cjs_DaH5tVvz.js');
|
|
11
11
|
|
|
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { useAppearanceConfig } from './hooks/useAppearanceConfig/useAppearanceConfig.js';
|
|
5
5
|
import { useDevicePropsGenerator } from './hooks/useDevicePropsGenerator/useDevicePropsGenerator.js';
|
|
6
|
-
import { I as Icon, B as Badge } from './
|
|
6
|
+
import { I as Icon, B as Badge } from './Icon_es_BEhzKfrD.js';
|
|
7
7
|
import { I as Image } from './Image_es_C-IjVkKX.js';
|
|
8
8
|
import { T as Text } from './Text_es_RDU9GLCV.js';
|
|
9
9
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var clsx = require('clsx');
|
|
6
|
-
var Icon = require('./
|
|
6
|
+
var Icon = require('./Icon_cjs_B5o0K55R.js');
|
|
7
7
|
var Link = require('./Link_cjs_qKXVfU8e.js');
|
|
8
8
|
var Loader = require('./Loader_cjs_CRiUlTC3.js');
|
|
9
9
|
var Text = require('./Text_cjs_DaH5tVvz.js');
|
|
@@ -386,7 +386,7 @@ const buttonAppearanceSurface = {
|
|
|
386
386
|
},
|
|
387
387
|
surfaceSecondary: {
|
|
388
388
|
fill: 'surfaceSecondary',
|
|
389
|
-
fillHover: '
|
|
389
|
+
fillHover: 'surfaceTertiary',
|
|
390
390
|
labelTextColor: 'surfaceTextPrimary',
|
|
391
391
|
borderColor: 'surfaceBorderTertiary',
|
|
392
392
|
iconAfterFillIcon: 'surfaceItemPrimary',
|
|
@@ -477,10 +477,10 @@ const Button = React.forwardRef(function Button(props, ref) {
|
|
|
477
477
|
return (jsxRuntime.jsx(Link.LinkWrapper, { className: clsx(className, 'button', label && buttonTypeClass
|
|
478
478
|
? 'button_type_default'
|
|
479
479
|
: label
|
|
480
|
-
? '
|
|
480
|
+
? 'button_type_label'
|
|
481
481
|
: buttonTypeClass
|
|
482
482
|
? 'button_type_icon'
|
|
483
|
-
: '', borderWidthClass && `border-width_${borderWidthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderTypeClass && `border_type_${borderTypeClass}`, fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, sizeClass && `button_size_${sizeClass}`, widthClass && `button_width_${widthClass}`, elevationClass && `elevation_${elevationClass}`, onClick && 'cursor_type_pointer', isDisabled && 'cursor_type_default', Badge && 'button_type_badge', zeroPadding && 'button_reset-padding', zeroGap && 'button_reset-gap', isLoading && 'button_state_loading', isSkeleton && `button_skeleton`), type: htmlType, "data-test-id": dataTestId && `${dataTestId}Button`, "data-tour": dataTour, disabled: isDisabled, href: link || href, LinkComponent: "button", rel: rel, style: buttonStyles, target: target, onClick: onClick, onMouseDown: onMouseDown, children: jsxRuntime.jsxs("div", { className: "button__wrapper", ref: ref, children: [isLoading && (jsxRuntime.jsx(Loader.Loader, { appearance: `${loaderAppearance} ${loaderAppearanceSize}`, className: clsx(className, 'button__loader'), type: loaderType, size: loaderSize, fill: loaderFill, itemFill: loaderItemFill })), before, (iconBefore || iconBeforeSrc) && (jsxRuntime.jsx(Icon.Icon, { className: "button__icon_before", fill: iconBeforeFill, fillSize: iconBeforeFillSize, iconFill: iconBeforeFillIcon, iconSize: iconBeforeSize, imageSrc: iconBeforeSrc, shape: iconBeforeShape, SvgImage: iconBefore })), (icon || iconSrc) && (jsxRuntime.jsx(Icon.Icon, { className: "button__icon", fill: iconFill, fillSize: iconFillSize, iconFill: iconFillIcon, iconSize: iconSize, imageSrc: iconSrc, shape: iconShape, SvgImage: icon })), (children || label) && (jsxRuntime.jsx(Text.Text, { className: "button__label", width: labelTextWidth, size: labelTextSize, textColor: labelTextColor, textColorHover: labelTextColorHover, textTruncate: labelTextTruncate, textWeight: labelTextWeight, textWrap: labelTextWrap, style: labelStyles, children: children || label })), (iconAfter || iconAfterSrc) && (jsxRuntime.jsx(Icon.Icon, { className: "button__icon_after", fill: iconAfterFill, fillSize: iconAfterFillSize, iconFill: iconAfterFillIcon, iconSize: iconAfterSize, imageSrc: iconAfterSrc, shape: iconAfterShape, SvgImage: iconAfter })), Badge, after] }) }));
|
|
483
|
+
: '', borderWidthClass && `border-width_${borderWidthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderTypeClass && `border_type_${borderTypeClass}`, fillClass && `fill_${fillClass}`, fillHoverClass && !isDisabled && `fill_hover_${fillHoverClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, sizeClass && `button_size_${sizeClass}`, widthClass && `button_width_${widthClass}`, elevationClass && `elevation_${elevationClass}`, onClick && 'cursor_type_pointer', isDisabled && 'button_state_disabled cursor_type_default', Badge && 'button_type_badge', zeroPadding && 'button_reset-padding', zeroGap && 'button_reset-gap', isLoading && 'button_state_loading', isSkeleton && `button_skeleton`), type: htmlType, "data-test-id": dataTestId && `${dataTestId}Button`, "data-tour": dataTour, disabled: isDisabled, href: link || href, LinkComponent: "button", rel: rel, style: buttonStyles, target: target, onClick: onClick, onMouseDown: onMouseDown, children: jsxRuntime.jsxs("div", { className: "button__wrapper", ref: ref, children: [isLoading && (jsxRuntime.jsx(Loader.Loader, { appearance: `${loaderAppearance} ${loaderAppearanceSize}`, className: clsx(className, 'button__loader'), type: loaderType, size: loaderSize, fill: loaderFill, itemFill: loaderItemFill })), before, (iconBefore || iconBeforeSrc) && (jsxRuntime.jsx(Icon.Icon, { className: "button__icon_before", fill: iconBeforeFill, fillSize: iconBeforeFillSize, iconFill: iconBeforeFillIcon, iconSize: iconBeforeSize, imageSrc: iconBeforeSrc, shape: iconBeforeShape, SvgImage: iconBefore })), (icon || iconSrc) && (jsxRuntime.jsx(Icon.Icon, { className: "button__icon", fill: iconFill, fillSize: iconFillSize, iconFill: iconFillIcon, iconSize: iconSize, imageSrc: iconSrc, shape: iconShape, SvgImage: icon })), (children || label) && (jsxRuntime.jsx(Text.Text, { className: "button__label", width: labelTextWidth, size: labelTextSize, textColor: labelTextColor, textColorHover: labelTextColorHover, textTruncate: labelTextTruncate, textWeight: labelTextWeight, textWrap: labelTextWrap, style: labelStyles, children: children || label })), (iconAfter || iconAfterSrc) && (jsxRuntime.jsx(Icon.Icon, { className: "button__icon_after", fill: iconAfterFill, fillSize: iconAfterFillSize, iconFill: iconAfterFillIcon, iconSize: iconAfterSize, imageSrc: iconAfterSrc, shape: iconAfterShape, SvgImage: iconAfter })), Badge, after] }) }));
|
|
484
484
|
});
|
|
485
485
|
|
|
486
486
|
exports.Button = Button;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { I as Icon } from './
|
|
4
|
+
import { I as Icon } from './Icon_es_BEhzKfrD.js';
|
|
5
5
|
import { a as LinkWrapper } from './Link_es_P2b6ya7P.js';
|
|
6
6
|
import { L as Loader } from './Loader_es_Dq2-7sn2.js';
|
|
7
7
|
import { T as Text } from './Text_es_RDU9GLCV.js';
|
|
@@ -384,7 +384,7 @@ const buttonAppearanceSurface = {
|
|
|
384
384
|
},
|
|
385
385
|
surfaceSecondary: {
|
|
386
386
|
fill: 'surfaceSecondary',
|
|
387
|
-
fillHover: '
|
|
387
|
+
fillHover: 'surfaceTertiary',
|
|
388
388
|
labelTextColor: 'surfaceTextPrimary',
|
|
389
389
|
borderColor: 'surfaceBorderTertiary',
|
|
390
390
|
iconAfterFillIcon: 'surfaceItemPrimary',
|
|
@@ -475,10 +475,10 @@ const Button = React.forwardRef(function Button(props, ref) {
|
|
|
475
475
|
return (jsx(LinkWrapper, { className: clsx(className, 'button', label && buttonTypeClass
|
|
476
476
|
? 'button_type_default'
|
|
477
477
|
: label
|
|
478
|
-
? '
|
|
478
|
+
? 'button_type_label'
|
|
479
479
|
: buttonTypeClass
|
|
480
480
|
? 'button_type_icon'
|
|
481
|
-
: '', borderWidthClass && `border-width_${borderWidthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderTypeClass && `border_type_${borderTypeClass}`, fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, sizeClass && `button_size_${sizeClass}`, widthClass && `button_width_${widthClass}`, elevationClass && `elevation_${elevationClass}`, onClick && 'cursor_type_pointer', isDisabled && 'cursor_type_default', Badge && 'button_type_badge', zeroPadding && 'button_reset-padding', zeroGap && 'button_reset-gap', isLoading && 'button_state_loading', isSkeleton && `button_skeleton`), type: htmlType, "data-test-id": dataTestId && `${dataTestId}Button`, "data-tour": dataTour, disabled: isDisabled, href: link || href, LinkComponent: "button", rel: rel, style: buttonStyles, target: target, onClick: onClick, onMouseDown: onMouseDown, children: jsxs("div", { className: "button__wrapper", ref: ref, children: [isLoading && (jsx(Loader, { appearance: `${loaderAppearance} ${loaderAppearanceSize}`, className: clsx(className, 'button__loader'), type: loaderType, size: loaderSize, fill: loaderFill, itemFill: loaderItemFill })), before, (iconBefore || iconBeforeSrc) && (jsx(Icon, { className: "button__icon_before", fill: iconBeforeFill, fillSize: iconBeforeFillSize, iconFill: iconBeforeFillIcon, iconSize: iconBeforeSize, imageSrc: iconBeforeSrc, shape: iconBeforeShape, SvgImage: iconBefore })), (icon || iconSrc) && (jsx(Icon, { className: "button__icon", fill: iconFill, fillSize: iconFillSize, iconFill: iconFillIcon, iconSize: iconSize, imageSrc: iconSrc, shape: iconShape, SvgImage: icon })), (children || label) && (jsx(Text, { className: "button__label", width: labelTextWidth, size: labelTextSize, textColor: labelTextColor, textColorHover: labelTextColorHover, textTruncate: labelTextTruncate, textWeight: labelTextWeight, textWrap: labelTextWrap, style: labelStyles, children: children || label })), (iconAfter || iconAfterSrc) && (jsx(Icon, { className: "button__icon_after", fill: iconAfterFill, fillSize: iconAfterFillSize, iconFill: iconAfterFillIcon, iconSize: iconAfterSize, imageSrc: iconAfterSrc, shape: iconAfterShape, SvgImage: iconAfter })), Badge, after] }) }));
|
|
481
|
+
: '', borderWidthClass && `border-width_${borderWidthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderTypeClass && `border_type_${borderTypeClass}`, fillClass && `fill_${fillClass}`, fillHoverClass && !isDisabled && `fill_hover_${fillHoverClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, sizeClass && `button_size_${sizeClass}`, widthClass && `button_width_${widthClass}`, elevationClass && `elevation_${elevationClass}`, onClick && 'cursor_type_pointer', isDisabled && 'button_state_disabled cursor_type_default', Badge && 'button_type_badge', zeroPadding && 'button_reset-padding', zeroGap && 'button_reset-gap', isLoading && 'button_state_loading', isSkeleton && `button_skeleton`), type: htmlType, "data-test-id": dataTestId && `${dataTestId}Button`, "data-tour": dataTour, disabled: isDisabled, href: link || href, LinkComponent: "button", rel: rel, style: buttonStyles, target: target, onClick: onClick, onMouseDown: onMouseDown, children: jsxs("div", { className: "button__wrapper", ref: ref, children: [isLoading && (jsx(Loader, { appearance: `${loaderAppearance} ${loaderAppearanceSize}`, className: clsx(className, 'button__loader'), type: loaderType, size: loaderSize, fill: loaderFill, itemFill: loaderItemFill })), before, (iconBefore || iconBeforeSrc) && (jsx(Icon, { className: "button__icon_before", fill: iconBeforeFill, fillSize: iconBeforeFillSize, iconFill: iconBeforeFillIcon, iconSize: iconBeforeSize, imageSrc: iconBeforeSrc, shape: iconBeforeShape, SvgImage: iconBefore })), (icon || iconSrc) && (jsx(Icon, { className: "button__icon", fill: iconFill, fillSize: iconFillSize, iconFill: iconFillIcon, iconSize: iconSize, imageSrc: iconSrc, shape: iconShape, SvgImage: icon })), (children || label) && (jsx(Text, { className: "button__label", width: labelTextWidth, size: labelTextSize, textColor: labelTextColor, textColorHover: labelTextColorHover, textTruncate: labelTextTruncate, textWeight: labelTextWeight, textWrap: labelTextWrap, style: labelStyles, children: children || label })), (iconAfter || iconAfterSrc) && (jsx(Icon, { className: "button__icon_after", fill: iconAfterFill, fillSize: iconAfterFillSize, iconFill: iconAfterFillIcon, iconSize: iconAfterSize, imageSrc: iconAfterSrc, shape: iconAfterShape, SvgImage: iconAfter })), Badge, after] }) }));
|
|
482
482
|
});
|
|
483
483
|
|
|
484
484
|
export { Button as B, buttonAppearance as a, buttonConfig as b };
|
|
@@ -5,7 +5,7 @@ var clsx = require('clsx');
|
|
|
5
5
|
var useAppearanceConfig = require('./cjs/hooks/useAppearanceConfig/useAppearanceConfig.js');
|
|
6
6
|
var useDevicePropsGenerator = require('./cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js');
|
|
7
7
|
var useStyles = require('./cjs/hooks/useStyles/useStyles.js');
|
|
8
|
-
var Icon = require('./
|
|
8
|
+
var Icon = require('./Icon_cjs_B5o0K55R.js');
|
|
9
9
|
var Text = require('./Text_cjs_DaH5tVvz.js');
|
|
10
10
|
|
|
11
11
|
const chipsAppearanceAccent = {
|
|
@@ -3,7 +3,7 @@ import clsx from 'clsx';
|
|
|
3
3
|
import { useAppearanceConfig } from './hooks/useAppearanceConfig/useAppearanceConfig.js';
|
|
4
4
|
import { useDevicePropsGenerator } from './hooks/useDevicePropsGenerator/useDevicePropsGenerator.js';
|
|
5
5
|
import { useStyles } from './hooks/useStyles/useStyles.js';
|
|
6
|
-
import { I as Icon, B as Badge } from './
|
|
6
|
+
import { I as Icon, B as Badge } from './Icon_es_BEhzKfrD.js';
|
|
7
7
|
import { T as Text } from './Text_es_RDU9GLCV.js';
|
|
8
8
|
|
|
9
9
|
const chipsAppearanceAccent = {
|
|
@@ -8,10 +8,10 @@ var DatePicker = require('react-datepicker');
|
|
|
8
8
|
var useAppearanceConfig = require('./cjs/hooks/useAppearanceConfig/useAppearanceConfig.js');
|
|
9
9
|
var useDevicePropsGenerator = require('./cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js');
|
|
10
10
|
var useStyles = require('./cjs/hooks/useStyles/useStyles.js');
|
|
11
|
-
var Button = require('./
|
|
12
|
-
var Icon = require('./
|
|
11
|
+
var Button = require('./Button_cjs_CGIzPuXo.js');
|
|
12
|
+
var Icon = require('./Icon_cjs_B5o0K55R.js');
|
|
13
13
|
var Input = require('./Input_cjs_DDi5JVAV.js');
|
|
14
|
-
var Label = require('./
|
|
14
|
+
var Label = require('./Label_cjs_DRIwteHh.js');
|
|
15
15
|
var Text = require('./Text_cjs_DaH5tVvz.js');
|
|
16
16
|
var _default = require('@itcase/icons/default');
|
|
17
17
|
|
|
@@ -6,10 +6,10 @@ import DatePicker from 'react-datepicker';
|
|
|
6
6
|
import { useAppearanceConfig } from './hooks/useAppearanceConfig/useAppearanceConfig.js';
|
|
7
7
|
import { useDevicePropsGenerator } from './hooks/useDevicePropsGenerator/useDevicePropsGenerator.js';
|
|
8
8
|
import { useStyles } from './hooks/useStyles/useStyles.js';
|
|
9
|
-
import { B as Button } from './
|
|
10
|
-
import { I as Icon } from './
|
|
9
|
+
import { B as Button } from './Button_es_CtAnUzZA.js';
|
|
10
|
+
import { I as Icon } from './Icon_es_BEhzKfrD.js';
|
|
11
11
|
import { I as Input } from './Input_es_BnCXATnh.js';
|
|
12
|
-
import { L as Label } from './
|
|
12
|
+
import { L as Label } from './Label_es_DYd2RwDK.js';
|
|
13
13
|
import { T as Text } from './Text_es_RDU9GLCV.js';
|
|
14
14
|
import { icons14 } from '@itcase/icons/default';
|
|
15
15
|
|
|
@@ -3,68 +3,13 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var clsx = require('clsx');
|
|
6
|
+
var useAppearanceConfig = require('./cjs/hooks/useAppearanceConfig/useAppearanceConfig.js');
|
|
6
7
|
var useDevicePropsGenerator = require('./cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js');
|
|
7
8
|
var useStyles = require('./cjs/hooks/useStyles/useStyles.js');
|
|
8
|
-
var Icon = require('./
|
|
9
|
-
var useAppearanceConfig = require('./cjs/hooks/useAppearanceConfig/useAppearanceConfig.js');
|
|
9
|
+
var Icon = require('./Icon_cjs_B5o0K55R.js');
|
|
10
10
|
var Divider = require('./Divider_cjs_DrmV2ezS.js');
|
|
11
11
|
var Text = require('./Text_cjs_DaH5tVvz.js');
|
|
12
12
|
|
|
13
|
-
function Dropdown(props) {
|
|
14
|
-
const { className, appearance, animationClose = 'dropdown_animation_close', animationOpen = 'dropdown_animation_open', dropdownList, before, after, isOpen, isSkeleton, setIsOpen, onClickItem, children, } = props;
|
|
15
|
-
const dropdownRef = React.useRef(null);
|
|
16
|
-
// const [isOpen, setIsOpen] = useState(false)
|
|
17
|
-
const [animationState, setAnimationState] = React.useState({
|
|
18
|
-
className: '',
|
|
19
|
-
});
|
|
20
|
-
const onAnimationEnd = React.useCallback(() => {
|
|
21
|
-
// When component is change his visibility(display) in DOM,
|
|
22
|
-
// animation of close can run unnecessary on showing element.
|
|
23
|
-
// const dropdownElement = dropdownRef.current
|
|
24
|
-
setAnimationState((prevState) => ({
|
|
25
|
-
className: isOpen ? prevState.className : '',
|
|
26
|
-
}));
|
|
27
|
-
}, [isOpen]);
|
|
28
|
-
React.useEffect(() => {
|
|
29
|
-
if (animationOpen && animationClose) {
|
|
30
|
-
setAnimationState(() => ({
|
|
31
|
-
className: isOpen ? animationOpen : animationClose,
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
}, [isOpen, animationOpen, animationClose]);
|
|
35
|
-
// Close dropdown by click outside
|
|
36
|
-
React.useEffect(() => {
|
|
37
|
-
// Add a handler to keep track of the click target.
|
|
38
|
-
function onClickWindow(event) {
|
|
39
|
-
const dropdownElement = dropdownRef.current;
|
|
40
|
-
if (dropdownElement && animationOpen) {
|
|
41
|
-
// Is event target inside of dropdown element
|
|
42
|
-
const isContainsTarget = dropdownElement.contains(event.target);
|
|
43
|
-
// Is dropdown element has "open" class
|
|
44
|
-
const hasOpenClass = dropdownElement.classList.contains(animationOpen);
|
|
45
|
-
if (!isContainsTarget && hasOpenClass) {
|
|
46
|
-
// Trigger close event with animation
|
|
47
|
-
// dropdownElement.click() - trigger "onClickWindow" again
|
|
48
|
-
setIsOpen(false);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Add event listener for current dropdown on first render
|
|
53
|
-
window.addEventListener('click', onClickWindow);
|
|
54
|
-
return () => {
|
|
55
|
-
// Remove event listener for current dropdown on unmount
|
|
56
|
-
window.removeEventListener('click', onClickWindow);
|
|
57
|
-
};
|
|
58
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
-
}, []);
|
|
60
|
-
const propsGenerator = useDevicePropsGenerator.useDevicePropsGenerator(props);
|
|
61
|
-
const { alignmentClass, fillClass, fillHoverClass, elevationClass, shapeClass, shapeStrengthClass, } = propsGenerator;
|
|
62
|
-
const { styles } = useStyles.useStyles(props);
|
|
63
|
-
return (jsxRuntime.jsxs("div", { className: clsx(className, 'dropdown', alignmentClass && `alignment_${alignmentClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, elevationClass && `elevation_${elevationClass}`, isOpen ? 'dropdown_state_open' : 'dropdown_state_close', animationState.className), ref: dropdownRef, style: styles, children: [before, (children || dropdownList) && (jsxRuntime.jsxs("div", { className: clsx('dropdown__wrapper', fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`),
|
|
64
|
-
// Add "onAnimationEnd" only for wrapper for ignore dropdown button
|
|
65
|
-
onAnimationEnd: onAnimationEnd, children: [dropdownList?.map((item) => (jsxRuntime.jsx(DropdownItem, { appearance: appearance, label: item.label, badgeValue: item.badgeValue, emptyMessage: item.emptyMessage, iconAfter: item.iconAfter, iconBefore: item.iconBefore, iconSrc: item.icon, isActive: item.isActive, isSkeleton: isSkeleton, onClick: item.onClick || ((event) => onClickItem?.(item, event)) }, item.key))), children] })), after] }));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
13
|
const dropdownAppearanceAccent = {
|
|
69
14
|
accentPrimary: {
|
|
70
15
|
fill: 'accentPrimary',
|
|
@@ -90,6 +35,31 @@ const dropdownAppearanceAccent = {
|
|
|
90
35
|
},
|
|
91
36
|
};
|
|
92
37
|
|
|
38
|
+
const dropdownAppearanceShape = {
|
|
39
|
+
circular: {
|
|
40
|
+
shape: 'circular',
|
|
41
|
+
},
|
|
42
|
+
rounded: {
|
|
43
|
+
shape: 'rounded',
|
|
44
|
+
},
|
|
45
|
+
roundedXL: {
|
|
46
|
+
shape: 'rounded',
|
|
47
|
+
shapeStrength: '2m',
|
|
48
|
+
},
|
|
49
|
+
roundedL: {
|
|
50
|
+
shape: 'rounded',
|
|
51
|
+
shapeStrength: '1_5m',
|
|
52
|
+
},
|
|
53
|
+
roundedM: {
|
|
54
|
+
shape: 'rounded',
|
|
55
|
+
shapeStrength: '1m',
|
|
56
|
+
},
|
|
57
|
+
roundedS: {
|
|
58
|
+
shape: 'rounded',
|
|
59
|
+
shapeStrength: '0_5m',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
93
63
|
const dropdownAppearanceSize = {
|
|
94
64
|
sizeL: {
|
|
95
65
|
size: 'l',
|
|
@@ -177,9 +147,76 @@ const dropdownAppearanceSurface = {
|
|
|
177
147
|
},
|
|
178
148
|
};
|
|
179
149
|
|
|
150
|
+
const dropdownAppearance = {
|
|
151
|
+
...dropdownAppearanceSurface,
|
|
152
|
+
...dropdownAppearanceStyle,
|
|
153
|
+
...dropdownAppearanceShape,
|
|
154
|
+
...dropdownAppearanceAccent,
|
|
155
|
+
...dropdownAppearanceSize,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const dropdownConfig = {
|
|
159
|
+
appearance: dropdownAppearance};
|
|
160
|
+
function Dropdown(props) {
|
|
161
|
+
const { appearance, className, animationClose = 'dropdown_animation_close', animationOpen = 'dropdown_animation_open', dropdownList, showDivider, before, after, isSkeleton, isOpen, setIsOpen, onClickItem, children, } = props;
|
|
162
|
+
const dropdownRef = React.useRef(null);
|
|
163
|
+
const appearanceConfig = useAppearanceConfig.useAppearanceConfig(appearance, dropdownConfig);
|
|
164
|
+
// const [isOpen, setIsOpen] = useState(false)
|
|
165
|
+
const [animationState, setAnimationState] = React.useState({
|
|
166
|
+
className: '',
|
|
167
|
+
});
|
|
168
|
+
const onAnimationEnd = React.useCallback(() => {
|
|
169
|
+
// When component is change his visibility(display) in DOM,
|
|
170
|
+
// animation of close can run unnecessary on showing element.
|
|
171
|
+
// const dropdownElement = dropdownRef.current
|
|
172
|
+
setAnimationState((prevState) => ({
|
|
173
|
+
className: isOpen ? prevState.className : '',
|
|
174
|
+
}));
|
|
175
|
+
}, [isOpen]);
|
|
176
|
+
React.useEffect(() => {
|
|
177
|
+
if (animationOpen && animationClose) {
|
|
178
|
+
setAnimationState(() => ({
|
|
179
|
+
className: isOpen ? animationOpen : animationClose,
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
}, [isOpen, animationOpen, animationClose]);
|
|
183
|
+
// Close dropdown by click outside
|
|
184
|
+
React.useEffect(() => {
|
|
185
|
+
// Add a handler to keep track of the click target.
|
|
186
|
+
function onClickWindow(event) {
|
|
187
|
+
const dropdownElement = dropdownRef.current;
|
|
188
|
+
if (dropdownElement && animationOpen) {
|
|
189
|
+
// Is event target inside of dropdown element
|
|
190
|
+
const isContainsTarget = dropdownElement.contains(event.target);
|
|
191
|
+
// Is dropdown element has "open" class
|
|
192
|
+
const hasOpenClass = dropdownElement.classList.contains(animationOpen);
|
|
193
|
+
if (!isContainsTarget && hasOpenClass) {
|
|
194
|
+
// Trigger close event with animation
|
|
195
|
+
// dropdownElement.click() - trigger "onClickWindow" again
|
|
196
|
+
setIsOpen(false);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// Add event listener for current dropdown on first render
|
|
201
|
+
window.addEventListener('click', onClickWindow);
|
|
202
|
+
return () => {
|
|
203
|
+
// Remove event listener for current dropdown on unmount
|
|
204
|
+
window.removeEventListener('click', onClickWindow);
|
|
205
|
+
};
|
|
206
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
207
|
+
}, []);
|
|
208
|
+
const propsGenerator = useDevicePropsGenerator.useDevicePropsGenerator(props, appearanceConfig);
|
|
209
|
+
const { alignmentClass, fillClass, elevationClass, shapeClass, shapeStrengthClass, } = propsGenerator;
|
|
210
|
+
const { styles } = useStyles.useStyles(props);
|
|
211
|
+
return (jsxRuntime.jsxs("div", { className: clsx(className, 'dropdown', alignmentClass && `alignment_${alignmentClass}`, fillClass && `fill_${fillClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, elevationClass && `elevation_${elevationClass}`, isOpen ? 'dropdown_state_open' : 'dropdown_state_close', animationState.className), ref: dropdownRef, style: styles, children: [before, (children || dropdownList) && (jsxRuntime.jsxs("div", { className: clsx('dropdown__wrapper'),
|
|
212
|
+
// Add "onAnimationEnd" only for wrapper for ignore dropdown button
|
|
213
|
+
onAnimationEnd: onAnimationEnd, children: [dropdownList?.map((item) => (jsxRuntime.jsx(DropdownItem, { appearance: appearance, label: item.label, badgeValue: item.badgeValue, emptyMessage: item.emptyMessage, iconAfter: item.iconAfter, iconBefore: item.iconBefore, iconSrc: item.icon, showDivider: showDivider, isActive: item.isActive, isSkeleton: isSkeleton, onClick: item.onClick || ((event) => onClickItem?.(item, event)) }, item.key))), children] })), after] }));
|
|
214
|
+
}
|
|
215
|
+
|
|
180
216
|
const dropdownItemAppearance = {
|
|
181
217
|
...dropdownAppearanceSurface,
|
|
182
218
|
...dropdownAppearanceStyle,
|
|
219
|
+
...dropdownAppearanceShape,
|
|
183
220
|
...dropdownAppearanceAccent,
|
|
184
221
|
...dropdownAppearanceSize,
|
|
185
222
|
};
|
|
@@ -191,17 +228,17 @@ const dropdownItemConfig = {
|
|
|
191
228
|
},
|
|
192
229
|
};
|
|
193
230
|
function DropdownItem(props) {
|
|
194
|
-
const {
|
|
231
|
+
const { appearance, className, label, desc, badgeValue, emptyMessage, showDivider, before, after, isActive, isDisabled, isSkeleton, isHover, onClick, onMouseEnter, children, } = props;
|
|
195
232
|
const appearanceConfig = useAppearanceConfig.useAppearanceConfig(appearance, dropdownItemConfig);
|
|
196
233
|
const propsGenerator = useDevicePropsGenerator.useDevicePropsGenerator(props, appearanceConfig);
|
|
197
|
-
const { directionClass, justifyContentClass, fillActiveClass, fillActiveHoverClass, fillClass, fillDisabledClass, fillHoverClass, labelTextAlign, labelTextColor, labelTextColorActive, labelTextColorActiveHover, labelTextColorHover, labelTextSize, labelTextStyle, labelTextWeight, labelTextWrap, descTextColor, descTextColorHover, descTextGradient, descTextSize, descTextStyle, descTextWeight, descTextWrap, badgeAppearance, badgeShape, badgeSize, badgeTextColor, badgeTextSize, dividerDirection, dividerFill, dividerSize, emptyMessageTextColor, emptyMessageTextColorHover, emptyMessageTextSize, emptyMessageTextStyle, emptyMessageTextWeight, emptyMessageTextWrap, iconAfter, iconAfterFill, iconAfterFillIcon, iconAfterFillSize, iconAfterShape, iconAfterSize, iconAfterSrc, iconBadgeAppearance, iconBadgeShape, iconBadgeSize, iconBadgeTextColor, iconBadgeTextSize, iconBadgeValue, iconBefore, iconBeforeFill, iconBeforeFillIcon, iconBeforeFillSize, iconBeforeShape, iconBeforeSize, iconBeforeSrc, shapeClass, sizeClass, widthClass, } = propsGenerator;
|
|
234
|
+
const { directionClass, justifyContentClass, fillActiveClass, fillActiveHoverClass, fillClass, fillDisabledClass, fillHoverClass, labelTextAlign, labelTextColor, labelTextColorActive, labelTextColorActiveHover, labelTextColorHover, labelTextSize, labelTextStyle, labelTextWeight, labelTextWrap, descTextColor, descTextColorHover, descTextGradient, descTextSize, descTextStyle, descTextWeight, descTextWrap, badgeAppearance, badgeShape, badgeSize, badgeTextColor, badgeTextSize, dividerDirection, dividerFill, dividerSize, emptyMessageTextColor, emptyMessageTextColorHover, emptyMessageTextSize, emptyMessageTextStyle, emptyMessageTextWeight, emptyMessageTextWrap, iconAfter, iconAfterFill, iconAfterFillIcon, iconAfterFillSize, iconAfterShape, iconAfterSize, iconAfterSrc, iconBadgeAppearance, iconBadgeShape, iconBadgeSize, iconBadgeTextColor, iconBadgeTextSize, iconBadgeValue, iconBefore, iconBeforeFill, iconBeforeFillIcon, iconBeforeFillSize, iconBeforeShape, iconBeforeSize, iconBeforeSrc, shapeClass, shapeStrengthClass, sizeClass, widthClass, } = propsGenerator;
|
|
198
235
|
// @ts-expect-error
|
|
199
236
|
const { styles: dropdownItem } = useStyles.useStyles(props);
|
|
200
237
|
return (jsxRuntime.jsxs("div", { className: clsx('dropdown__item', isActive && 'dropdown__item_state_active', isHover && 'dropdown__item_state_hover', directionClass && `dropdown__item_direction_${directionClass}`, className, !isActive
|
|
201
238
|
? fillClass && `fill_${fillClass}`
|
|
202
239
|
: fillActiveClass && `fill_active_${fillActiveClass}`, !isActive
|
|
203
240
|
? fillHoverClass && `fill_hover_${fillHoverClass}`
|
|
204
|
-
: fillActiveHoverClass && `fill_active_hover_${fillActiveHoverClass}`, fillDisabledClass && `fill_disabled_${fillDisabledClass}`, sizeClass && `dropdown__item_size_${sizeClass}`, shapeClass && `
|
|
241
|
+
: fillActiveHoverClass && `fill_active_hover_${fillActiveHoverClass}`, fillDisabledClass && `fill_disabled_${fillDisabledClass}`, sizeClass && `dropdown__item_size_${sizeClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, widthClass && `dropdown__item_width_${widthClass}`, isDisabled && `dropdown__item_state_disabled`, onClick && 'cursor_type_pointer', isSkeleton && `dropdown__item_skeleton`, justifyContentClass &&
|
|
205
242
|
`dropdown__item_justify-content_${justifyContentClass}`), style: dropdownItem, onClick: onClick, onMouseEnter: onMouseEnter, children: [jsxRuntime.jsx("div", { className: "dropdown__item-wrapper", children: jsxRuntime.jsxs(React.Fragment, { children: [before, (iconBefore || iconBeforeSrc) && (jsxRuntime.jsx(Icon.Icon, { className: clsx('dropdown__item_before', iconBadgeValue && 'dropdown__item_before-badge'), fill: iconBeforeFill, fillSize: iconBeforeFillSize, badgeAppearance: iconBadgeAppearance, badgeClass: 'dropdown__item_before_badge', badgeShape: iconBadgeShape, badgeSize: iconBadgeSize, badgeTextColor: iconBadgeTextColor, badgeTextSize: iconBadgeTextSize, badgeValue: iconBadgeValue, iconFill: iconBeforeFillIcon, iconSize: iconBeforeSize, imageSrc: iconBeforeSrc, shape: iconBeforeShape, SvgImage: iconBefore })), children || (jsxRuntime.jsxs(React.Fragment, { children: [label && (jsxRuntime.jsx(Text.Text, { className: "dropdown__item-label", size: labelTextSize, textAlign: labelTextAlign, textColor: !isActive && labelTextColor, textColorActive: "accentTextPrimary", textColorActive: isActive && labelTextColorActive, textColorHover: !isActive && labelTextColorHover, textColorHoverActive: isActive && labelTextColorActiveHover, textStyle: labelTextStyle, textWeight: labelTextWeight, textWrap: labelTextWrap, isActive: isActive, children: label })), badgeValue && (jsxRuntime.jsx(Icon.Badge, { appearance: badgeAppearance, size: badgeSize, textColor: badgeTextColor, textSize: badgeTextSize, shape: badgeShape, value: badgeValue })), desc && (jsxRuntime.jsx(Text.Text, { className: "dropdown__item-desc", size: descTextSize, textColor: descTextColor, textColorGradient: descTextGradient, textColorHover: descTextColorHover, textStyle: descTextStyle, textWeight: descTextWeight, textWrap: descTextWrap, isActive: isActive, children: desc })), emptyMessage && (jsxRuntime.jsx(Text.Text, { className: "dropdown__item", size: emptyMessageTextSize, textColor: emptyMessageTextColor, textColorHover: emptyMessageTextColorHover, textStyle: emptyMessageTextStyle, textWeight: emptyMessageTextWeight, textWrap: emptyMessageTextWrap, isActive: isActive, children: emptyMessage }))] })), after, (iconAfter || iconAfterSrc) && (jsxRuntime.jsx(Icon.Icon, { className: clsx('dropdown__item_after', iconBadgeValue && 'dropdown__item_after-badge'), fill: iconAfterFill, fillSize: iconAfterFillSize, badgeAppearance: iconBadgeAppearance, badgeClass: 'dropdown__item_after_badge', badgeShape: iconBadgeShape, badgeSize: iconBadgeSize, badgeTextColor: iconBadgeTextColor, badgeTextSize: iconBadgeTextSize, badgeValue: iconBadgeValue, iconFill: iconAfterFillIcon, iconSize: iconAfterSize, imageSrc: iconAfterSrc, shape: iconAfterShape, SvgImage: iconAfter }))] }) }), showDivider && (jsxRuntime.jsx(Divider.Divider, { width: "fill", direction: dividerDirection, size: dividerSize, fill: dividerFill }))] }));
|
|
206
243
|
}
|
|
207
244
|
|
|
@@ -1,68 +1,13 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
+
import { useAppearanceConfig } from './hooks/useAppearanceConfig/useAppearanceConfig.js';
|
|
4
5
|
import { useDevicePropsGenerator } from './hooks/useDevicePropsGenerator/useDevicePropsGenerator.js';
|
|
5
6
|
import { useStyles } from './hooks/useStyles/useStyles.js';
|
|
6
|
-
import { I as Icon, B as Badge } from './
|
|
7
|
-
import { useAppearanceConfig } from './hooks/useAppearanceConfig/useAppearanceConfig.js';
|
|
7
|
+
import { I as Icon, B as Badge } from './Icon_es_BEhzKfrD.js';
|
|
8
8
|
import { D as Divider } from './Divider_es_BiYozVBS.js';
|
|
9
9
|
import { T as Text } from './Text_es_RDU9GLCV.js';
|
|
10
10
|
|
|
11
|
-
function Dropdown(props) {
|
|
12
|
-
const { className, appearance, animationClose = 'dropdown_animation_close', animationOpen = 'dropdown_animation_open', dropdownList, before, after, isOpen, isSkeleton, setIsOpen, onClickItem, children, } = props;
|
|
13
|
-
const dropdownRef = useRef(null);
|
|
14
|
-
// const [isOpen, setIsOpen] = useState(false)
|
|
15
|
-
const [animationState, setAnimationState] = useState({
|
|
16
|
-
className: '',
|
|
17
|
-
});
|
|
18
|
-
const onAnimationEnd = useCallback(() => {
|
|
19
|
-
// When component is change his visibility(display) in DOM,
|
|
20
|
-
// animation of close can run unnecessary on showing element.
|
|
21
|
-
// const dropdownElement = dropdownRef.current
|
|
22
|
-
setAnimationState((prevState) => ({
|
|
23
|
-
className: isOpen ? prevState.className : '',
|
|
24
|
-
}));
|
|
25
|
-
}, [isOpen]);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (animationOpen && animationClose) {
|
|
28
|
-
setAnimationState(() => ({
|
|
29
|
-
className: isOpen ? animationOpen : animationClose,
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
}, [isOpen, animationOpen, animationClose]);
|
|
33
|
-
// Close dropdown by click outside
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
// Add a handler to keep track of the click target.
|
|
36
|
-
function onClickWindow(event) {
|
|
37
|
-
const dropdownElement = dropdownRef.current;
|
|
38
|
-
if (dropdownElement && animationOpen) {
|
|
39
|
-
// Is event target inside of dropdown element
|
|
40
|
-
const isContainsTarget = dropdownElement.contains(event.target);
|
|
41
|
-
// Is dropdown element has "open" class
|
|
42
|
-
const hasOpenClass = dropdownElement.classList.contains(animationOpen);
|
|
43
|
-
if (!isContainsTarget && hasOpenClass) {
|
|
44
|
-
// Trigger close event with animation
|
|
45
|
-
// dropdownElement.click() - trigger "onClickWindow" again
|
|
46
|
-
setIsOpen(false);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Add event listener for current dropdown on first render
|
|
51
|
-
window.addEventListener('click', onClickWindow);
|
|
52
|
-
return () => {
|
|
53
|
-
// Remove event listener for current dropdown on unmount
|
|
54
|
-
window.removeEventListener('click', onClickWindow);
|
|
55
|
-
};
|
|
56
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
-
}, []);
|
|
58
|
-
const propsGenerator = useDevicePropsGenerator(props);
|
|
59
|
-
const { alignmentClass, fillClass, fillHoverClass, elevationClass, shapeClass, shapeStrengthClass, } = propsGenerator;
|
|
60
|
-
const { styles } = useStyles(props);
|
|
61
|
-
return (jsxs("div", { className: clsx(className, 'dropdown', alignmentClass && `alignment_${alignmentClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, elevationClass && `elevation_${elevationClass}`, isOpen ? 'dropdown_state_open' : 'dropdown_state_close', animationState.className), ref: dropdownRef, style: styles, children: [before, (children || dropdownList) && (jsxs("div", { className: clsx('dropdown__wrapper', fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`),
|
|
62
|
-
// Add "onAnimationEnd" only for wrapper for ignore dropdown button
|
|
63
|
-
onAnimationEnd: onAnimationEnd, children: [dropdownList?.map((item) => (jsx(DropdownItem, { appearance: appearance, label: item.label, badgeValue: item.badgeValue, emptyMessage: item.emptyMessage, iconAfter: item.iconAfter, iconBefore: item.iconBefore, iconSrc: item.icon, isActive: item.isActive, isSkeleton: isSkeleton, onClick: item.onClick || ((event) => onClickItem?.(item, event)) }, item.key))), children] })), after] }));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
11
|
const dropdownAppearanceAccent = {
|
|
67
12
|
accentPrimary: {
|
|
68
13
|
fill: 'accentPrimary',
|
|
@@ -88,6 +33,31 @@ const dropdownAppearanceAccent = {
|
|
|
88
33
|
},
|
|
89
34
|
};
|
|
90
35
|
|
|
36
|
+
const dropdownAppearanceShape = {
|
|
37
|
+
circular: {
|
|
38
|
+
shape: 'circular',
|
|
39
|
+
},
|
|
40
|
+
rounded: {
|
|
41
|
+
shape: 'rounded',
|
|
42
|
+
},
|
|
43
|
+
roundedXL: {
|
|
44
|
+
shape: 'rounded',
|
|
45
|
+
shapeStrength: '2m',
|
|
46
|
+
},
|
|
47
|
+
roundedL: {
|
|
48
|
+
shape: 'rounded',
|
|
49
|
+
shapeStrength: '1_5m',
|
|
50
|
+
},
|
|
51
|
+
roundedM: {
|
|
52
|
+
shape: 'rounded',
|
|
53
|
+
shapeStrength: '1m',
|
|
54
|
+
},
|
|
55
|
+
roundedS: {
|
|
56
|
+
shape: 'rounded',
|
|
57
|
+
shapeStrength: '0_5m',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
91
61
|
const dropdownAppearanceSize = {
|
|
92
62
|
sizeL: {
|
|
93
63
|
size: 'l',
|
|
@@ -175,9 +145,76 @@ const dropdownAppearanceSurface = {
|
|
|
175
145
|
},
|
|
176
146
|
};
|
|
177
147
|
|
|
148
|
+
const dropdownAppearance = {
|
|
149
|
+
...dropdownAppearanceSurface,
|
|
150
|
+
...dropdownAppearanceStyle,
|
|
151
|
+
...dropdownAppearanceShape,
|
|
152
|
+
...dropdownAppearanceAccent,
|
|
153
|
+
...dropdownAppearanceSize,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const dropdownConfig = {
|
|
157
|
+
appearance: dropdownAppearance};
|
|
158
|
+
function Dropdown(props) {
|
|
159
|
+
const { appearance, className, animationClose = 'dropdown_animation_close', animationOpen = 'dropdown_animation_open', dropdownList, showDivider, before, after, isSkeleton, isOpen, setIsOpen, onClickItem, children, } = props;
|
|
160
|
+
const dropdownRef = useRef(null);
|
|
161
|
+
const appearanceConfig = useAppearanceConfig(appearance, dropdownConfig);
|
|
162
|
+
// const [isOpen, setIsOpen] = useState(false)
|
|
163
|
+
const [animationState, setAnimationState] = useState({
|
|
164
|
+
className: '',
|
|
165
|
+
});
|
|
166
|
+
const onAnimationEnd = useCallback(() => {
|
|
167
|
+
// When component is change his visibility(display) in DOM,
|
|
168
|
+
// animation of close can run unnecessary on showing element.
|
|
169
|
+
// const dropdownElement = dropdownRef.current
|
|
170
|
+
setAnimationState((prevState) => ({
|
|
171
|
+
className: isOpen ? prevState.className : '',
|
|
172
|
+
}));
|
|
173
|
+
}, [isOpen]);
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (animationOpen && animationClose) {
|
|
176
|
+
setAnimationState(() => ({
|
|
177
|
+
className: isOpen ? animationOpen : animationClose,
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
}, [isOpen, animationOpen, animationClose]);
|
|
181
|
+
// Close dropdown by click outside
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
// Add a handler to keep track of the click target.
|
|
184
|
+
function onClickWindow(event) {
|
|
185
|
+
const dropdownElement = dropdownRef.current;
|
|
186
|
+
if (dropdownElement && animationOpen) {
|
|
187
|
+
// Is event target inside of dropdown element
|
|
188
|
+
const isContainsTarget = dropdownElement.contains(event.target);
|
|
189
|
+
// Is dropdown element has "open" class
|
|
190
|
+
const hasOpenClass = dropdownElement.classList.contains(animationOpen);
|
|
191
|
+
if (!isContainsTarget && hasOpenClass) {
|
|
192
|
+
// Trigger close event with animation
|
|
193
|
+
// dropdownElement.click() - trigger "onClickWindow" again
|
|
194
|
+
setIsOpen(false);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Add event listener for current dropdown on first render
|
|
199
|
+
window.addEventListener('click', onClickWindow);
|
|
200
|
+
return () => {
|
|
201
|
+
// Remove event listener for current dropdown on unmount
|
|
202
|
+
window.removeEventListener('click', onClickWindow);
|
|
203
|
+
};
|
|
204
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
205
|
+
}, []);
|
|
206
|
+
const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
|
|
207
|
+
const { alignmentClass, fillClass, elevationClass, shapeClass, shapeStrengthClass, } = propsGenerator;
|
|
208
|
+
const { styles } = useStyles(props);
|
|
209
|
+
return (jsxs("div", { className: clsx(className, 'dropdown', alignmentClass && `alignment_${alignmentClass}`, fillClass && `fill_${fillClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, elevationClass && `elevation_${elevationClass}`, isOpen ? 'dropdown_state_open' : 'dropdown_state_close', animationState.className), ref: dropdownRef, style: styles, children: [before, (children || dropdownList) && (jsxs("div", { className: clsx('dropdown__wrapper'),
|
|
210
|
+
// Add "onAnimationEnd" only for wrapper for ignore dropdown button
|
|
211
|
+
onAnimationEnd: onAnimationEnd, children: [dropdownList?.map((item) => (jsx(DropdownItem, { appearance: appearance, label: item.label, badgeValue: item.badgeValue, emptyMessage: item.emptyMessage, iconAfter: item.iconAfter, iconBefore: item.iconBefore, iconSrc: item.icon, showDivider: showDivider, isActive: item.isActive, isSkeleton: isSkeleton, onClick: item.onClick || ((event) => onClickItem?.(item, event)) }, item.key))), children] })), after] }));
|
|
212
|
+
}
|
|
213
|
+
|
|
178
214
|
const dropdownItemAppearance = {
|
|
179
215
|
...dropdownAppearanceSurface,
|
|
180
216
|
...dropdownAppearanceStyle,
|
|
217
|
+
...dropdownAppearanceShape,
|
|
181
218
|
...dropdownAppearanceAccent,
|
|
182
219
|
...dropdownAppearanceSize,
|
|
183
220
|
};
|
|
@@ -189,17 +226,17 @@ const dropdownItemConfig = {
|
|
|
189
226
|
},
|
|
190
227
|
};
|
|
191
228
|
function DropdownItem(props) {
|
|
192
|
-
const {
|
|
229
|
+
const { appearance, className, label, desc, badgeValue, emptyMessage, showDivider, before, after, isActive, isDisabled, isSkeleton, isHover, onClick, onMouseEnter, children, } = props;
|
|
193
230
|
const appearanceConfig = useAppearanceConfig(appearance, dropdownItemConfig);
|
|
194
231
|
const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
|
|
195
|
-
const { directionClass, justifyContentClass, fillActiveClass, fillActiveHoverClass, fillClass, fillDisabledClass, fillHoverClass, labelTextAlign, labelTextColor, labelTextColorActive, labelTextColorActiveHover, labelTextColorHover, labelTextSize, labelTextStyle, labelTextWeight, labelTextWrap, descTextColor, descTextColorHover, descTextGradient, descTextSize, descTextStyle, descTextWeight, descTextWrap, badgeAppearance, badgeShape, badgeSize, badgeTextColor, badgeTextSize, dividerDirection, dividerFill, dividerSize, emptyMessageTextColor, emptyMessageTextColorHover, emptyMessageTextSize, emptyMessageTextStyle, emptyMessageTextWeight, emptyMessageTextWrap, iconAfter, iconAfterFill, iconAfterFillIcon, iconAfterFillSize, iconAfterShape, iconAfterSize, iconAfterSrc, iconBadgeAppearance, iconBadgeShape, iconBadgeSize, iconBadgeTextColor, iconBadgeTextSize, iconBadgeValue, iconBefore, iconBeforeFill, iconBeforeFillIcon, iconBeforeFillSize, iconBeforeShape, iconBeforeSize, iconBeforeSrc, shapeClass, sizeClass, widthClass, } = propsGenerator;
|
|
232
|
+
const { directionClass, justifyContentClass, fillActiveClass, fillActiveHoverClass, fillClass, fillDisabledClass, fillHoverClass, labelTextAlign, labelTextColor, labelTextColorActive, labelTextColorActiveHover, labelTextColorHover, labelTextSize, labelTextStyle, labelTextWeight, labelTextWrap, descTextColor, descTextColorHover, descTextGradient, descTextSize, descTextStyle, descTextWeight, descTextWrap, badgeAppearance, badgeShape, badgeSize, badgeTextColor, badgeTextSize, dividerDirection, dividerFill, dividerSize, emptyMessageTextColor, emptyMessageTextColorHover, emptyMessageTextSize, emptyMessageTextStyle, emptyMessageTextWeight, emptyMessageTextWrap, iconAfter, iconAfterFill, iconAfterFillIcon, iconAfterFillSize, iconAfterShape, iconAfterSize, iconAfterSrc, iconBadgeAppearance, iconBadgeShape, iconBadgeSize, iconBadgeTextColor, iconBadgeTextSize, iconBadgeValue, iconBefore, iconBeforeFill, iconBeforeFillIcon, iconBeforeFillSize, iconBeforeShape, iconBeforeSize, iconBeforeSrc, shapeClass, shapeStrengthClass, sizeClass, widthClass, } = propsGenerator;
|
|
196
233
|
// @ts-expect-error
|
|
197
234
|
const { styles: dropdownItem } = useStyles(props);
|
|
198
235
|
return (jsxs("div", { className: clsx('dropdown__item', isActive && 'dropdown__item_state_active', isHover && 'dropdown__item_state_hover', directionClass && `dropdown__item_direction_${directionClass}`, className, !isActive
|
|
199
236
|
? fillClass && `fill_${fillClass}`
|
|
200
237
|
: fillActiveClass && `fill_active_${fillActiveClass}`, !isActive
|
|
201
238
|
? fillHoverClass && `fill_hover_${fillHoverClass}`
|
|
202
|
-
: fillActiveHoverClass && `fill_active_hover_${fillActiveHoverClass}`, fillDisabledClass && `fill_disabled_${fillDisabledClass}`, sizeClass && `dropdown__item_size_${sizeClass}`, shapeClass && `
|
|
239
|
+
: fillActiveHoverClass && `fill_active_hover_${fillActiveHoverClass}`, fillDisabledClass && `fill_disabled_${fillDisabledClass}`, sizeClass && `dropdown__item_size_${sizeClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, widthClass && `dropdown__item_width_${widthClass}`, isDisabled && `dropdown__item_state_disabled`, onClick && 'cursor_type_pointer', isSkeleton && `dropdown__item_skeleton`, justifyContentClass &&
|
|
203
240
|
`dropdown__item_justify-content_${justifyContentClass}`), style: dropdownItem, onClick: onClick, onMouseEnter: onMouseEnter, children: [jsx("div", { className: "dropdown__item-wrapper", children: jsxs(React.Fragment, { children: [before, (iconBefore || iconBeforeSrc) && (jsx(Icon, { className: clsx('dropdown__item_before', iconBadgeValue && 'dropdown__item_before-badge'), fill: iconBeforeFill, fillSize: iconBeforeFillSize, badgeAppearance: iconBadgeAppearance, badgeClass: 'dropdown__item_before_badge', badgeShape: iconBadgeShape, badgeSize: iconBadgeSize, badgeTextColor: iconBadgeTextColor, badgeTextSize: iconBadgeTextSize, badgeValue: iconBadgeValue, iconFill: iconBeforeFillIcon, iconSize: iconBeforeSize, imageSrc: iconBeforeSrc, shape: iconBeforeShape, SvgImage: iconBefore })), children || (jsxs(React.Fragment, { children: [label && (jsx(Text, { className: "dropdown__item-label", size: labelTextSize, textAlign: labelTextAlign, textColor: !isActive && labelTextColor, textColorActive: "accentTextPrimary", textColorActive: isActive && labelTextColorActive, textColorHover: !isActive && labelTextColorHover, textColorHoverActive: isActive && labelTextColorActiveHover, textStyle: labelTextStyle, textWeight: labelTextWeight, textWrap: labelTextWrap, isActive: isActive, children: label })), badgeValue && (jsx(Badge, { appearance: badgeAppearance, size: badgeSize, textColor: badgeTextColor, textSize: badgeTextSize, shape: badgeShape, value: badgeValue })), desc && (jsx(Text, { className: "dropdown__item-desc", size: descTextSize, textColor: descTextColor, textColorGradient: descTextGradient, textColorHover: descTextColorHover, textStyle: descTextStyle, textWeight: descTextWeight, textWrap: descTextWrap, isActive: isActive, children: desc })), emptyMessage && (jsx(Text, { className: "dropdown__item", size: emptyMessageTextSize, textColor: emptyMessageTextColor, textColorHover: emptyMessageTextColorHover, textStyle: emptyMessageTextStyle, textWeight: emptyMessageTextWeight, textWrap: emptyMessageTextWrap, isActive: isActive, children: emptyMessage }))] })), after, (iconAfter || iconAfterSrc) && (jsx(Icon, { className: clsx('dropdown__item_after', iconBadgeValue && 'dropdown__item_after-badge'), fill: iconAfterFill, fillSize: iconAfterFillSize, badgeAppearance: iconBadgeAppearance, badgeClass: 'dropdown__item_after_badge', badgeShape: iconBadgeShape, badgeSize: iconBadgeSize, badgeTextColor: iconBadgeTextColor, badgeTextSize: iconBadgeTextSize, badgeValue: iconBadgeValue, iconFill: iconAfterFillIcon, iconSize: iconAfterSize, imageSrc: iconAfterSrc, shape: iconAfterShape, SvgImage: iconAfter }))] }) }), showDivider && (jsx(Divider, { width: "fill", direction: dividerDirection, size: dividerSize, fill: dividerFill }))] }));
|
|
204
241
|
}
|
|
205
242
|
|
|
@@ -1004,10 +1004,16 @@ const iconAppearanceSurface = {
|
|
|
1004
1004
|
badgeAppearance: 'surfacePrimary',
|
|
1005
1005
|
iconFill: 'surfaceItemPrimary',
|
|
1006
1006
|
},
|
|
1007
|
+
surfaceQuaternary: {
|
|
1008
|
+
fill: 'surfaceQuaternary',
|
|
1009
|
+
fillHover: 'surfaceHover',
|
|
1010
|
+
badgeAppearance: 'accentPrimary',
|
|
1011
|
+
iconFill: 'surfaceItemPrimary',
|
|
1012
|
+
},
|
|
1007
1013
|
surfaceSecondary: {
|
|
1008
1014
|
fill: 'surfaceSecondary',
|
|
1009
1015
|
fillHover: 'surfaceSecondaryHover',
|
|
1010
|
-
badgeAppearance: 'accentPrimary',
|
|
1016
|
+
badgeAppearance: 'accentPrimary solid rounded',
|
|
1011
1017
|
iconFill: 'surfaceItemPrimary',
|
|
1012
1018
|
},
|
|
1013
1019
|
surfaceTertiary: {
|
|
@@ -1016,12 +1022,6 @@ const iconAppearanceSurface = {
|
|
|
1016
1022
|
badgeAppearance: 'accentPrimary',
|
|
1017
1023
|
iconFill: 'surfaceItemPrimary',
|
|
1018
1024
|
},
|
|
1019
|
-
surfaceQuaternary: {
|
|
1020
|
-
fill: 'surfaceQuaternary',
|
|
1021
|
-
fillHover: 'surfaceHover',
|
|
1022
|
-
badgeAppearance: 'accentPrimary',
|
|
1023
|
-
iconFill: 'surfaceItemPrimary',
|
|
1024
|
-
},
|
|
1025
1025
|
};
|
|
1026
1026
|
|
|
1027
1027
|
const iconAppearanceWarning = {
|
|
@@ -1002,10 +1002,16 @@ const iconAppearanceSurface = {
|
|
|
1002
1002
|
badgeAppearance: 'surfacePrimary',
|
|
1003
1003
|
iconFill: 'surfaceItemPrimary',
|
|
1004
1004
|
},
|
|
1005
|
+
surfaceQuaternary: {
|
|
1006
|
+
fill: 'surfaceQuaternary',
|
|
1007
|
+
fillHover: 'surfaceHover',
|
|
1008
|
+
badgeAppearance: 'accentPrimary',
|
|
1009
|
+
iconFill: 'surfaceItemPrimary',
|
|
1010
|
+
},
|
|
1005
1011
|
surfaceSecondary: {
|
|
1006
1012
|
fill: 'surfaceSecondary',
|
|
1007
1013
|
fillHover: 'surfaceSecondaryHover',
|
|
1008
|
-
badgeAppearance: 'accentPrimary',
|
|
1014
|
+
badgeAppearance: 'accentPrimary solid rounded',
|
|
1009
1015
|
iconFill: 'surfaceItemPrimary',
|
|
1010
1016
|
},
|
|
1011
1017
|
surfaceTertiary: {
|
|
@@ -1014,12 +1020,6 @@ const iconAppearanceSurface = {
|
|
|
1014
1020
|
badgeAppearance: 'accentPrimary',
|
|
1015
1021
|
iconFill: 'surfaceItemPrimary',
|
|
1016
1022
|
},
|
|
1017
|
-
surfaceQuaternary: {
|
|
1018
|
-
fill: 'surfaceQuaternary',
|
|
1019
|
-
fillHover: 'surfaceHover',
|
|
1020
|
-
badgeAppearance: 'accentPrimary',
|
|
1021
|
-
iconFill: 'surfaceItemPrimary',
|
|
1022
|
-
},
|
|
1023
1023
|
};
|
|
1024
1024
|
|
|
1025
1025
|
const iconAppearanceWarning = {
|