@mailstep/design-system 0.8.46 → 0.8.48
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/package.json +7 -7
- package/ui/Blocks/Header/components/MenuItems/components/MenuItem/index.d.ts +1 -0
- package/ui/Blocks/Header/components/MenuItems/components/MenuItem/index.js +16 -6
- package/ui/Blocks/Header/components/MenuItems/index.d.ts +1 -0
- package/ui/Blocks/Header/components/MenuItems/index.js +3 -2
- package/ui/Blocks/Header/components/MenuItems/styles.d.ts +3 -0
- package/ui/Blocks/Header/components/MenuItems/styles.js +15 -2
- package/ui/Blocks/Header/index.d.ts +1 -0
- package/ui/Blocks/Header/index.js +5 -3
- package/ui/Blocks/Header/stories/Header.stories.d.ts +1 -0
- package/ui/Elements/Avatar/Avatar.js +2 -2
- package/ui/Elements/Avatar/types.d.ts +2 -0
- package/ui/Elements/HighlightBox/HighlightBox.d.ts +1 -3
- package/ui/Elements/HighlightBox/HighlightBox.js +0 -2
- package/ui/Elements/Icon/Icon.js +4 -2
- package/ui/Elements/Icon/icons/Inventory.d.ts +1 -1
- package/ui/Elements/Icon/icons/Inventory.js +1 -1
- package/ui/Elements/Icon/icons/Return.d.ts +1 -1
- package/ui/Elements/Icon/icons/Return.js +1 -1
- package/ui/Elements/Link/stories/Link.stories.d.ts +1 -0
- package/ui/Elements/Select/Select.js +37 -11
- package/ui/Blocks/HidePrint/stories/HidePrint.stories.d.ts +0 -12
- package/ui/Blocks/Popover/stories/Popover.stories.d.ts +0 -16
- package/ui/Elements/DatePicker/stories/DatePicker.stories.d.ts +0 -11
- package/ui/Elements/DropdownMenu/stories/DropdownMenu.stories.d.ts +0 -10
- package/ui/Elements/DropdownSelect/stories/DropdownSelect.stories.d.ts +0 -22
- package/ui/Elements/HighlightBox/stories/HighlightBox.stories.d.ts +0 -31
- package/ui/Elements/Portal/stories/Portal.stories.d.ts +0 -11
- package/ui/Elements/SimpleLink/stories/SimpleLink.stories.d.ts +0 -13
- package/ui/Elements/SingleSelect/stories/SingleSelect.stories.d.ts +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailstep/design-system",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.48",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./ui/index.js",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@lingui/core": "^5.0.0",
|
|
41
41
|
"@lingui/react": "^5.0.0",
|
|
42
42
|
"@popperjs/core": "^2.11.8",
|
|
43
|
-
"@storybook/addon-designs": "^11.1.
|
|
44
|
-
"@storybook/addon-docs": "10.
|
|
45
|
-
"@storybook/addon-links": "10.
|
|
46
|
-
"@storybook/react-webpack5": "10.
|
|
43
|
+
"@storybook/addon-designs": "^11.1.2",
|
|
44
|
+
"@storybook/addon-docs": "10.2.8",
|
|
45
|
+
"@storybook/addon-links": "10.2.8",
|
|
46
|
+
"@storybook/react-webpack5": "10.2.8",
|
|
47
47
|
"@svgr/rollup": "^8.0.1",
|
|
48
48
|
"@swc/core": "^1.15.30",
|
|
49
49
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"eslint-plugin-react": "^7.35.0",
|
|
74
74
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
75
75
|
"eslint-plugin-react-perf": "^3.3.2",
|
|
76
|
-
"eslint-plugin-storybook": "10.
|
|
76
|
+
"eslint-plugin-storybook": "10.2.8",
|
|
77
77
|
"faker": "^5.1.0",
|
|
78
78
|
"husky": "^9.1.7",
|
|
79
79
|
"immer": "^9.0.19",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"react-use-draggable-scroll": "^0.4.7",
|
|
97
97
|
"redux": ">=4.0.5",
|
|
98
98
|
"reselect": "5.0.0-alpha.2",
|
|
99
|
-
"storybook": "10.
|
|
99
|
+
"storybook": "10.2.8",
|
|
100
100
|
"string-width": "6.1.0",
|
|
101
101
|
"styled-components": "^5.3.10",
|
|
102
102
|
"swiper": "^11.0.3",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Icon from "../../../../../../Elements/Icon/Icon.js";
|
|
2
|
-
import { MenuItemDropdownArrow, MenuItemLabel, MenuItemsListItem, SubMenuItemRow, SubMenuList } from "../../styles.js";
|
|
2
|
+
import { MenuItemDropdownArrow, MenuItemIcon, MenuItemLabel, MenuItemsListItem, SubMenuItemRow, SubMenuList } from "../../styles.js";
|
|
3
3
|
import { isItemActive, isLinkExactActive } from "./utils/isItemActive.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { Link, useLocation } from "react-router-dom";
|
|
6
6
|
//#region packages/ui/Blocks/Header/components/MenuItems/components/MenuItem/index.tsx
|
|
7
|
-
const MenuItem = ({ item, variant = "light" }) => {
|
|
7
|
+
const MenuItem = ({ item, variant = "light", iconsBreakpoint }) => {
|
|
8
8
|
const hasSubmenu = Array.isArray(item.items) && item.items.length > 0;
|
|
9
9
|
const { pathname, search } = useLocation();
|
|
10
10
|
const isActive = isItemActive(pathname, item);
|
|
@@ -14,10 +14,20 @@ const MenuItem = ({ item, variant = "light" }) => {
|
|
|
14
14
|
$isActive: isActive,
|
|
15
15
|
children: [/* @__PURE__ */ jsxs(MenuItemLabel, {
|
|
16
16
|
onClick: item.onClick,
|
|
17
|
-
children: [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
children: [
|
|
18
|
+
item.icon && /* @__PURE__ */ jsx(MenuItemIcon, {
|
|
19
|
+
$iconsBreakpoint: iconsBreakpoint,
|
|
20
|
+
children: typeof item.icon === "string" ? /* @__PURE__ */ jsx(Icon, {
|
|
21
|
+
icon: item.icon,
|
|
22
|
+
size: 18
|
|
23
|
+
}) : item.icon
|
|
24
|
+
}),
|
|
25
|
+
item.link && !hasSubmenu ? /* @__PURE__ */ jsx(Link, {
|
|
26
|
+
to: item.link,
|
|
27
|
+
children: item.title
|
|
28
|
+
}) : /* @__PURE__ */ jsx("span", { children: item.title }),
|
|
29
|
+
hasSubmenu && /* @__PURE__ */ jsx(MenuItemDropdownArrow, { children: /* @__PURE__ */ jsx(Icon, { icon: "goDown" }) })
|
|
30
|
+
]
|
|
21
31
|
}), hasSubmenu && /* @__PURE__ */ jsx(SubMenuList, { children: item.items?.map((subItem, key) => /* @__PURE__ */ jsx(SubMenuItemRow, {
|
|
22
32
|
pointer: !!subItem.onClick,
|
|
23
33
|
onClick: subItem.onClick,
|
|
@@ -2,10 +2,11 @@ import { MenuItemsList } from "./styles.js";
|
|
|
2
2
|
import { MenuItem } from "./components/MenuItem/index.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region packages/ui/Blocks/Header/components/MenuItems/index.tsx
|
|
5
|
-
const MenuItems = ({ items, variant = "light" }) => {
|
|
5
|
+
const MenuItems = ({ items, variant = "light", iconsBreakpoint }) => {
|
|
6
6
|
return /* @__PURE__ */ jsx(MenuItemsList, { children: items?.map((item, key) => /* @__PURE__ */ jsx(MenuItem, {
|
|
7
7
|
item,
|
|
8
|
-
variant
|
|
8
|
+
variant,
|
|
9
|
+
iconsBreakpoint
|
|
9
10
|
}, key)) });
|
|
10
11
|
};
|
|
11
12
|
//#endregion
|
|
@@ -7,6 +7,9 @@ export declare const MenuItemsListItem: import("styled-components").StyledCompon
|
|
|
7
7
|
$isActive?: boolean;
|
|
8
8
|
}, never>;
|
|
9
9
|
export declare const MenuItemLabel: import("styled-components").StyledComponent<"div", import("@xstyled/styled-components").Theme, {}, never>;
|
|
10
|
+
export declare const MenuItemIcon: import("styled-components").StyledComponent<"span", import("@xstyled/styled-components").Theme, {
|
|
11
|
+
$iconsBreakpoint?: string;
|
|
12
|
+
}, never>;
|
|
10
13
|
export declare const MenuItemDropdownArrow: import("styled-components").StyledComponent<"span", import("@xstyled/styled-components").Theme, {}, never>;
|
|
11
14
|
export declare const SubMenuItemRow: import("styled-components").StyledComponent<"li", import("@xstyled/styled-components").Theme, {
|
|
12
15
|
pointer?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled$1, { th } from "@xstyled/styled-components";
|
|
1
|
+
import styled$1, { css, th } from "@xstyled/styled-components";
|
|
2
2
|
//#region packages/ui/Blocks/Header/components/MenuItems/styles.ts
|
|
3
3
|
const MenuItemsList = styled$1.ul`
|
|
4
4
|
display: flex;
|
|
@@ -76,6 +76,19 @@ const MenuItemLabel = styled$1.div`
|
|
|
76
76
|
user-select: none;
|
|
77
77
|
height: 100%;
|
|
78
78
|
`;
|
|
79
|
+
const MenuItemIcon = styled$1.span`
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
${({ $iconsBreakpoint }) => $iconsBreakpoint && css`
|
|
85
|
+
display: none;
|
|
86
|
+
|
|
87
|
+
@media (min-width: ${$iconsBreakpoint}) {
|
|
88
|
+
display: inline-flex;
|
|
89
|
+
}
|
|
90
|
+
`}
|
|
91
|
+
`;
|
|
79
92
|
const MenuItemDropdownArrow = styled$1.span`
|
|
80
93
|
display: inline-flex;
|
|
81
94
|
align-items: center;
|
|
@@ -121,4 +134,4 @@ const SubMenuItemRow = styled$1.li`
|
|
|
121
134
|
}
|
|
122
135
|
`;
|
|
123
136
|
//#endregion
|
|
124
|
-
export { MenuItemDropdownArrow, MenuItemLabel, MenuItemsList, MenuItemsListItem, SubMenuItemRow, SubMenuList };
|
|
137
|
+
export { MenuItemDropdownArrow, MenuItemIcon, MenuItemLabel, MenuItemsList, MenuItemsListItem, SubMenuItemRow, SubMenuList };
|
|
@@ -11,7 +11,7 @@ import { useCallback, useState } from "react";
|
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { Link } from "react-router-dom";
|
|
13
13
|
//#region packages/ui/Blocks/Header/index.tsx
|
|
14
|
-
const Header = ({ isMobileMenuOpen, homeLink, logo, logoVariant, logoVariantSmall, logoWidth = "145px", logoSmallWidth = "45px", logoSrc, logoSrcWidth, user, currentLanguage, hasUserMenu = false, leftMenuItems, rightMenuItems, rightSideStart, userMenuOverride, withInitials = false, withChevron = false, withName = false, variant = "light", height = "60px", smallLogoBreakpoint = "1801px", mobileMenuBreakpoint = "1024px", showLanguageWithTitle, languageFlagWrapBackgroundColor, languageItems: languageItems$1 = languageItems, withLanguageSwitch = true, ignoreClickOutsideClosest, onOpenMobileSideMenu, onChangeLanguage, onLogout }) => {
|
|
14
|
+
const Header = ({ isMobileMenuOpen, homeLink, logo, logoVariant, logoVariantSmall, logoWidth = "145px", logoSmallWidth = "45px", logoSrc, logoSrcWidth, user, currentLanguage, hasUserMenu = false, leftMenuItems, rightMenuItems, rightSideStart, userMenuOverride, withInitials = false, withChevron = false, withName = false, variant = "light", height = "60px", smallLogoBreakpoint = "1801px", mobileMenuBreakpoint = "1024px", menuIconsBreakpoint, showLanguageWithTitle, languageFlagWrapBackgroundColor, languageItems: languageItems$1 = languageItems, withLanguageSwitch = true, ignoreClickOutsideClosest, onOpenMobileSideMenu, onChangeLanguage, onLogout }) => {
|
|
15
15
|
const { handleChangeLanguage } = useChangeLanguage({ onChangeLanguage });
|
|
16
16
|
const hasLeftMenu = Array.isArray(leftMenuItems) && leftMenuItems.length > 0;
|
|
17
17
|
const hasInternalMobileMenu = hasLeftMenu && !onOpenMobileSideMenu;
|
|
@@ -62,14 +62,16 @@ const Header = ({ isMobileMenuOpen, homeLink, logo, logoVariant, logoVariantSmal
|
|
|
62
62
|
$mobileMenuBreakpoint: mobileMenuBreakpoint,
|
|
63
63
|
children: /* @__PURE__ */ jsx(MenuItems, {
|
|
64
64
|
items: leftMenuItems,
|
|
65
|
-
variant
|
|
65
|
+
variant,
|
|
66
|
+
iconsBreakpoint: menuIconsBreakpoint
|
|
66
67
|
})
|
|
67
68
|
})
|
|
68
69
|
] }), /* @__PURE__ */ jsxs(RightSide, { children: [
|
|
69
70
|
rightSideStart,
|
|
70
71
|
!!rightMenuItems?.length && /* @__PURE__ */ jsx(MenuItems, {
|
|
71
72
|
items: rightMenuItems,
|
|
72
|
-
variant
|
|
73
|
+
variant,
|
|
74
|
+
iconsBreakpoint: menuIconsBreakpoint
|
|
73
75
|
}),
|
|
74
76
|
withLanguageSwitch && /* @__PURE__ */ jsx(LanguageWrapper, { children: /* @__PURE__ */ jsx(LanguageSwitch_default, {
|
|
75
77
|
languageItems: languageItems$1,
|
|
@@ -25,6 +25,7 @@ declare const meta: {
|
|
|
25
25
|
height?: string;
|
|
26
26
|
smallLogoBreakpoint?: string;
|
|
27
27
|
mobileMenuBreakpoint?: string;
|
|
28
|
+
menuIconsBreakpoint?: string;
|
|
28
29
|
languageItems?: import("../../LanguageSwitch").LanguageItem[];
|
|
29
30
|
showLanguageWithTitle?: boolean;
|
|
30
31
|
languageFlagWrapBackgroundColor?: string;
|
|
@@ -9,7 +9,7 @@ const getInitials = (user) => {
|
|
|
9
9
|
if (initials) return initials;
|
|
10
10
|
return (user?.username ?? "?").slice(0, 2).toUpperCase();
|
|
11
11
|
};
|
|
12
|
-
const Avatar = ({ user, src, size = 34, colorFront, colorBack, className, hoverColorBack, onClick, withInitials, withChevron, withName }) => {
|
|
12
|
+
const Avatar = ({ user, src, size = 34, colorFront, colorBack, className, hoverColorBack, onClick, withInitials, withChevron, withName, children }) => {
|
|
13
13
|
return /* @__PURE__ */ jsxs(AvatarWrap, {
|
|
14
14
|
onClick,
|
|
15
15
|
children: [
|
|
@@ -29,7 +29,7 @@ const Avatar = ({ user, src, size = 34, colorFront, colorBack, className, hoverC
|
|
|
29
29
|
!src && !withInitials && /* @__PURE__ */ jsx(Profile, { stroke: colorFront })
|
|
30
30
|
]
|
|
31
31
|
}),
|
|
32
|
-
withName && user?.username,
|
|
32
|
+
/* @__PURE__ */ jsxs("div", { children: [withName && user?.username, children] }),
|
|
33
33
|
withChevron && /* @__PURE__ */ jsx(Chevron, { children: /* @__PURE__ */ jsx(Icon, {
|
|
34
34
|
icon: "goDown",
|
|
35
35
|
fill: "white",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export type FlagAppearanceType = 'neutralBold' | '
|
|
2
|
+
export type FlagAppearanceType = 'neutralBold' | 'neutralSubtle' | 'blueBold' | 'blueSubtle' | 'tealBold' | 'tealSubtle' | 'greenBold' | 'greenSubtle' | 'orangeBold' | 'orangeSubtle' | 'yellowBold' | 'yellowSubtle' | 'pinkBold' | 'pinkSubtle' | 'purpleBold' | 'purpleSubtle' | 'redBold' | 'redSubtle';
|
|
3
3
|
export declare const flagAppearanceToColorMap: {
|
|
4
4
|
neutralBold: string;
|
|
5
|
-
neutralMedium: string;
|
|
6
5
|
neutralSubtle: string;
|
|
7
6
|
blueBold: string;
|
|
8
7
|
blueSubtle: string;
|
|
@@ -23,7 +22,6 @@ export declare const flagAppearanceToColorMap: {
|
|
|
23
22
|
};
|
|
24
23
|
export declare const flagAppearanceToFontColorMap: {
|
|
25
24
|
neutralBold: string;
|
|
26
|
-
neutralMedium: string;
|
|
27
25
|
neutralSubtle: string;
|
|
28
26
|
blueBold: string;
|
|
29
27
|
blueSubtle: string;
|
|
@@ -48,7 +48,6 @@ const OverflowWrap = styled$1.span`
|
|
|
48
48
|
`;
|
|
49
49
|
const flagAppearanceToColorMap = {
|
|
50
50
|
neutralBold: "neutral300",
|
|
51
|
-
neutralMedium: "#D2D8DF",
|
|
52
51
|
neutralSubtle: "bgLightGray2",
|
|
53
52
|
blueBold: "blue70",
|
|
54
53
|
blueSubtle: "blue20",
|
|
@@ -69,7 +68,6 @@ const flagAppearanceToColorMap = {
|
|
|
69
68
|
};
|
|
70
69
|
const flagAppearanceToFontColorMap = {
|
|
71
70
|
neutralBold: "white",
|
|
72
|
-
neutralMedium: "#22394E",
|
|
73
71
|
neutralSubtle: "#22394E",
|
|
74
72
|
blueBold: "#ffffff",
|
|
75
73
|
blueSubtle: "blue80",
|
package/ui/Elements/Icon/Icon.js
CHANGED
|
@@ -14,6 +14,7 @@ import { faPaperclip } from "@fortawesome/pro-light-svg-icons/faPaperclip";
|
|
|
14
14
|
import { faStopwatch } from "@fortawesome/pro-light-svg-icons/faStopwatch";
|
|
15
15
|
import { faArrowRightToBracket } from "@fortawesome/pro-regular-svg-icons/faArrowRightToBracket";
|
|
16
16
|
import { faBell } from "@fortawesome/pro-regular-svg-icons/faBell";
|
|
17
|
+
import { faBolt } from "@fortawesome/pro-regular-svg-icons/faBolt";
|
|
17
18
|
import { faBox } from "@fortawesome/pro-regular-svg-icons/faBox";
|
|
18
19
|
import { faCalendar } from "@fortawesome/pro-regular-svg-icons/faCalendar";
|
|
19
20
|
import { faCalendarPlus } from "@fortawesome/pro-regular-svg-icons/faCalendarPlus";
|
|
@@ -143,6 +144,7 @@ const iconDictionary = {
|
|
|
143
144
|
paperPlane: faPaperPlane,
|
|
144
145
|
flaskRoundPotion: faFlaskRoundPotion,
|
|
145
146
|
batteryBolt: faBatteryBolt,
|
|
147
|
+
bolt: faBolt,
|
|
146
148
|
ellipsisVertical: faEllipsisVertical,
|
|
147
149
|
greaterThanEqual: faGreaterThanEqual,
|
|
148
150
|
home: faHome,
|
|
@@ -265,8 +267,8 @@ const Icon = ({ icon, fill, stroke, style = "normal", size, width, height, class
|
|
|
265
267
|
$colorSecondary: colorSecondary,
|
|
266
268
|
$fixedWidth: fixedWidth,
|
|
267
269
|
children: IconComponent ? /* @__PURE__ */ jsx(IconComponent, {
|
|
268
|
-
fill: colorFill,
|
|
269
|
-
stroke: colorStroke,
|
|
270
|
+
...colorFill ? { fill: colorFill } : {},
|
|
271
|
+
...colorStroke ? { stroke: colorStroke } : {},
|
|
270
272
|
onClick,
|
|
271
273
|
cursor: cursor ?? (onClick ? "pointer" : void 0),
|
|
272
274
|
...width ?? size ? { width: width ?? size } : {},
|
|
@@ -5,7 +5,7 @@ const Return = (props) => /* @__PURE__ */ jsxs("svg", {
|
|
|
5
5
|
height: "22",
|
|
6
6
|
viewBox: "0 0 22 22",
|
|
7
7
|
fill: "none",
|
|
8
|
-
stroke: "
|
|
8
|
+
stroke: "currentColor",
|
|
9
9
|
...props,
|
|
10
10
|
children: [/* @__PURE__ */ jsx("path", {
|
|
11
11
|
d: "M6 8.78947V13.7105L11.1 15.5M6 8.78947L11.1 10.5789M6 8.78947L11.1 7L16.2 8.34211M11.1 15.5V10.5789M11.1 15.5L16.2 13.7105V8.34211M11.1 10.5789L16.2 8.34211",
|
|
@@ -5,7 +5,7 @@ import "../Label/index.js";
|
|
|
5
5
|
import SpaceAround_default from "../SpaceAround/index.js";
|
|
6
6
|
import { StyledAsyncSelect, StyledReactSelect, Wrapper } from "./styles.js";
|
|
7
7
|
import { useStylesAndComponents } from "./themes/index.js";
|
|
8
|
-
import { useCallback, useMemo } from "react";
|
|
8
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
9
9
|
import { useTheme } from "@xstyled/styled-components";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { i18n } from "@lingui/core";
|
|
@@ -22,9 +22,41 @@ const loadingMessage = () => i18n._({
|
|
|
22
22
|
const Select = ({ label, name, value = "", options = emptyOptions, defaultOptions, loadOptions, onChange, onBlur, error, isInvalid, isLoading, isDarkPlaceholderText, spaceAround = false, disabled, onInputChange, isSearchable, isMulti, className, useSimplifiedOptions = false, showSelectAllButton = false, shortValues = true, shortVariant = "block", style, optionVariant, multiLabelVariant, containerVariant, placeholder, placeholderIcon, innerRef, maxMenuHeight, getOptionValue, onIconClick, title, ...passTroughProps }) => {
|
|
23
23
|
const isAsync = !!loadOptions;
|
|
24
24
|
if (showSelectAllButton && !isMulti) console.error("CheckboxSelect incompatible props");
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const localGetOptionValue = useMemo(() => getOptionValue || ((option) => option?.value), [getOptionValue]);
|
|
26
|
+
const availableOptionsByValue = useMemo(() => {
|
|
27
|
+
const map = /* @__PURE__ */ new Map();
|
|
28
|
+
for (const option of [...defaultOptions || [], ...options || []]) map.set(localGetOptionValue(option), option);
|
|
29
|
+
return map;
|
|
30
|
+
}, [
|
|
31
|
+
defaultOptions,
|
|
32
|
+
options,
|
|
33
|
+
localGetOptionValue
|
|
34
|
+
]);
|
|
35
|
+
const selectedHistoryRef = useRef(/* @__PURE__ */ new Map());
|
|
36
|
+
const resolveOption = useCallback((optionValue) => availableOptionsByValue.get(optionValue) || selectedHistoryRef.current.get(optionValue), [availableOptionsByValue]);
|
|
37
|
+
let selectedOption = null;
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
const resolved = value.map(resolveOption).filter((option) => Boolean(option));
|
|
40
|
+
selectedOption = resolved.length ? resolved : null;
|
|
41
|
+
} else if (value !== void 0) selectedOption = resolveOption(value) || null;
|
|
42
|
+
const handleChange = useCallback((newValue) => {
|
|
43
|
+
(Array.isArray(newValue) ? newValue : newValue ? [newValue] : []).forEach((option) => option && selectedHistoryRef.current.set(localGetOptionValue(option), option));
|
|
44
|
+
onChange?.(newValue);
|
|
45
|
+
}, [onChange, localGetOptionValue]);
|
|
46
|
+
const setAllOptions = useCallback(({ options: optionsToAdd }) => {
|
|
47
|
+
const merged = [...Array.isArray(selectedOption) ? selectedOption : selectedOption ? [selectedOption] : []];
|
|
48
|
+
const visibleOptions = optionsToAdd || [];
|
|
49
|
+
for (const option of visibleOptions) {
|
|
50
|
+
const optionValue = localGetOptionValue(option);
|
|
51
|
+
if (!merged.some((selected) => localGetOptionValue(selected) === optionValue)) merged.push(resolveOption(optionValue) || option);
|
|
52
|
+
}
|
|
53
|
+
handleChange(merged);
|
|
54
|
+
}, [
|
|
55
|
+
handleChange,
|
|
56
|
+
selectedOption,
|
|
57
|
+
localGetOptionValue,
|
|
58
|
+
resolveOption
|
|
59
|
+
]);
|
|
28
60
|
const unsetAllOptions = useCallback(() => {
|
|
29
61
|
if (typeof onChange === "function") onChange?.(emptyOptions);
|
|
30
62
|
}, [onChange]);
|
|
@@ -32,12 +64,6 @@ const Select = ({ label, name, value = "", options = emptyOptions, defaultOption
|
|
|
32
64
|
const modifiedMaxMenuHeight = showSelectAllButton && maxMenuHeight ? maxMenuHeight - 30 : maxMenuHeight;
|
|
33
65
|
const [customComponents, customTheme, customStyles] = useStylesAndComponents(style, optionVariant, multiLabelVariant, containerVariant, useSimplifiedOptions, showSelectAllButton);
|
|
34
66
|
const RenderComponent = isAsync ? StyledAsyncSelect : StyledReactSelect;
|
|
35
|
-
let selectedOption;
|
|
36
|
-
const localGetOptionValue = useMemo(() => getOptionValue || ((option) => option?.value), [getOptionValue]);
|
|
37
|
-
if (Array.isArray(value)) {
|
|
38
|
-
selectedOption = (defaultOptions || options).filter((option) => value.includes(localGetOptionValue(option)));
|
|
39
|
-
selectedOption = selectedOption?.length ? selectedOption : null;
|
|
40
|
-
} else if (value !== void 0) selectedOption = (defaultOptions || options).find((option) => localGetOptionValue(option) === value) || null;
|
|
41
67
|
const theme = useTheme();
|
|
42
68
|
const handleLoadOptions = useMemo(() => {
|
|
43
69
|
return loadOptions ? async (fulltext) => await loadOptions(fulltext) : void 0;
|
|
@@ -56,7 +82,7 @@ const Select = ({ label, name, value = "", options = emptyOptions, defaultOption
|
|
|
56
82
|
loadOptions: handleLoadOptions,
|
|
57
83
|
defaultOptions,
|
|
58
84
|
value: selectedOption,
|
|
59
|
-
onChange,
|
|
85
|
+
onChange: handleChange,
|
|
60
86
|
onBlur,
|
|
61
87
|
isDisabled: disabled || isLoading,
|
|
62
88
|
isLoading,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").FC<{
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
}>;
|
|
7
|
-
tags: string[];
|
|
8
|
-
argTypes: {};
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const Default: Story;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type FC } from 'react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: FC<{
|
|
5
|
-
parentRef: React.MutableRefObject<HTMLDivElement | null | undefined>;
|
|
6
|
-
onClose?: () => void;
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
placement?: import("@popperjs/core").Placement;
|
|
9
|
-
wrapper?: import("styled-components").StyledComponent<any, any>;
|
|
10
|
-
ignoreClickOutsideClosest?: string;
|
|
11
|
-
}>;
|
|
12
|
-
tags: string[];
|
|
13
|
-
argTypes: {};
|
|
14
|
-
};
|
|
15
|
-
export default meta;
|
|
16
|
-
export declare const Default: FC;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type FC } from 'react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").NamedExoticComponent<import("../DatePicker").DatePickerType>;
|
|
5
|
-
tags: string[];
|
|
6
|
-
argTypes: {};
|
|
7
|
-
};
|
|
8
|
-
export default meta;
|
|
9
|
-
export declare const Default: FC;
|
|
10
|
-
export declare const WithTime: FC;
|
|
11
|
-
export declare const Disabled: FC;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type FC } from 'react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: <T extends import("../types").Item>({ items, showMenu, className, ItemComponent, header, footer, ...rest }: import("../types").DropdownMenuProps<T>) => import("react").ReactElement;
|
|
5
|
-
tags: string[];
|
|
6
|
-
argTypes: {};
|
|
7
|
-
};
|
|
8
|
-
export default meta;
|
|
9
|
-
export declare const Default: FC;
|
|
10
|
-
export declare const WithCounts: FC;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").FC<{
|
|
5
|
-
label: string | import("react").ReactNode;
|
|
6
|
-
appearance?: import("../../Button").AppearanceValue;
|
|
7
|
-
variant?: import("../../Button/types").VariantValue;
|
|
8
|
-
options: import("../DropdownSelect").DropdownSelectItem[];
|
|
9
|
-
showChevron?: boolean;
|
|
10
|
-
onSelect?: (value: import("../DropdownSelect").DropdownSelectItem["value"]) => void;
|
|
11
|
-
icon?: import("react").ReactNode;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
ButtonComponent?: React.FC;
|
|
14
|
-
}>;
|
|
15
|
-
tags: string[];
|
|
16
|
-
argTypes: {};
|
|
17
|
-
};
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof meta>;
|
|
20
|
-
export declare const Default: Story;
|
|
21
|
-
export declare const WithoutChevron: Story;
|
|
22
|
-
export declare const Disabled: Story;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").FC<{
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
appearance: import("../HighlightBox").FlagAppearanceType;
|
|
7
|
-
size?: "default" | "small" | "wide" | "fitContent";
|
|
8
|
-
className?: string;
|
|
9
|
-
cursor?: string;
|
|
10
|
-
prefix?: string;
|
|
11
|
-
}>;
|
|
12
|
-
tags: string[];
|
|
13
|
-
argTypes: {
|
|
14
|
-
appearance: {
|
|
15
|
-
control: "select";
|
|
16
|
-
options: string[];
|
|
17
|
-
};
|
|
18
|
-
size: {
|
|
19
|
-
control: "select";
|
|
20
|
-
options: string[];
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export default meta;
|
|
25
|
-
type Story = StoryObj<typeof meta>;
|
|
26
|
-
export declare const Default: Story;
|
|
27
|
-
export declare const Subtle: Story;
|
|
28
|
-
export declare const Small: Story;
|
|
29
|
-
export declare const Wide: Story;
|
|
30
|
-
export declare const FitContent: Story;
|
|
31
|
-
export declare const AllAppearances: Story;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("styled-components").StyledComponent<typeof import("react-router-dom").Link, import("@xstyled/styled-components").Theme, import("../SimpleLink").Props, never>;
|
|
5
|
-
tags: string[];
|
|
6
|
-
argTypes: {};
|
|
7
|
-
};
|
|
8
|
-
export default meta;
|
|
9
|
-
type Story = StoryObj<typeof meta>;
|
|
10
|
-
export declare const Default: Story;
|
|
11
|
-
export declare const Decorated: Story;
|
|
12
|
-
export declare const Disabled: Story;
|
|
13
|
-
export declare const External: Story;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type FC } from 'react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: FC<import("../SingleSelect").Props>;
|
|
5
|
-
tags: string[];
|
|
6
|
-
argTypes: {};
|
|
7
|
-
};
|
|
8
|
-
export default meta;
|
|
9
|
-
export declare const Default: FC;
|
|
10
|
-
export declare const Searchable: FC;
|