@ftdata/ui 0.0.8 → 0.0.10

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.
Files changed (90) hide show
  1. package/dist/assets/fonts/Inter-Italic.js +2 -0
  2. package/dist/assets/fonts/Inter.js +2 -0
  3. package/dist/components/DoubleList/DoubleList.stories.d.ts +2 -2
  4. package/dist/components/DoubleList/DoubleList.stories.js +43 -43
  5. package/dist/components/DoubleList/Row/index.d.ts +4 -0
  6. package/dist/components/DoubleList/Row/index.js +12 -0
  7. package/dist/components/DoubleList/Row/style.d.ts +1 -0
  8. package/dist/components/DoubleList/Row/style.js +31 -0
  9. package/dist/components/DoubleList/index.js +27 -35
  10. package/dist/components/DoubleList/style.d.ts +0 -1
  11. package/dist/components/DoubleList/style.js +2 -31
  12. package/dist/components/Menu/Menu.stories.d.ts +6 -0
  13. package/dist/components/Menu/Menu.stories.js +116 -0
  14. package/dist/components/Menu/index.js +29 -14
  15. package/dist/components/Menu/styles.d.ts +1 -0
  16. package/dist/components/Menu/styles.js +44 -28
  17. package/dist/components/MultiSelect/MultiSelectList/Row/index.d.ts +7 -0
  18. package/dist/components/MultiSelect/MultiSelectList/Row/index.js +26 -0
  19. package/dist/components/MultiSelect/MultiSelectList/Row/style.d.ts +6 -0
  20. package/dist/components/MultiSelect/MultiSelectList/Row/style.js +48 -0
  21. package/dist/components/MultiSelect/MultiSelectList/index.d.ts +4 -3
  22. package/dist/components/MultiSelect/MultiSelectList/index.js +51 -41
  23. package/dist/components/MultiSelect/MultiSelectList/style.d.ts +0 -1
  24. package/dist/components/MultiSelect/MultiSelectList/style.js +2 -31
  25. package/dist/components/MultiSelect/helpers/addOption.d.ts +5 -0
  26. package/dist/components/MultiSelect/helpers/addOption.js +14 -0
  27. package/dist/components/MultiSelect/helpers/computeUnselected.d.ts +2 -0
  28. package/dist/components/MultiSelect/helpers/computeUnselected.js +2 -0
  29. package/dist/components/MultiSelect/helpers/feedbackText.d.ts +5 -0
  30. package/dist/components/MultiSelect/helpers/feedbackText.js +30 -0
  31. package/dist/components/MultiSelect/helpers/filterOptions.d.ts +2 -0
  32. package/dist/components/MultiSelect/helpers/filterOptions.js +5 -0
  33. package/dist/components/MultiSelect/helpers/removeOptions.d.ts +5 -0
  34. package/dist/components/MultiSelect/helpers/removeOptions.js +9 -0
  35. package/dist/components/MultiSelect/index.d.ts +29 -14
  36. package/dist/components/MultiSelect/index.js +149 -215
  37. package/dist/components/MultiSelect/styles.d.ts +6 -5
  38. package/dist/components/MultiSelect/styles.js +20 -66
  39. package/dist/components/Select/List/Row/index.d.ts +11 -0
  40. package/dist/components/Select/List/Row/index.js +29 -0
  41. package/dist/components/{CustomSelect/CustomSelectList → Select/List/Row}/style.d.ts +0 -2
  42. package/dist/components/{CustomSelect/CustomSelectList → Select/List/Row}/style.js +1 -54
  43. package/dist/components/Select/List/index.d.ts +12 -0
  44. package/dist/components/Select/List/index.js +63 -0
  45. package/dist/components/Select/List/style.d.ts +2 -0
  46. package/dist/components/Select/List/style.js +56 -0
  47. package/dist/components/Select/index.d.ts +34 -0
  48. package/dist/components/{CustomSelect → Select}/index.js +11 -9
  49. package/dist/components/{CustomSelect → Select}/styles.d.ts +2 -2
  50. package/dist/components/{CustomSelect → Select}/styles.js +6 -8
  51. package/dist/components/fields/components/HelpText/index.d.ts +8 -0
  52. package/dist/components/fields/components/HelpText/index.js +35 -0
  53. package/dist/components/fields/components/HelpText/modifiers/colors.d.ts +4 -0
  54. package/dist/components/fields/components/HelpText/modifiers/colors.js +9 -0
  55. package/dist/components/fields/components/HelpText/styles.d.ts +2 -0
  56. package/dist/components/fields/components/HelpText/styles.js +19 -0
  57. package/dist/components/fields/components/Label/index.d.ts +8 -0
  58. package/dist/components/fields/components/Label/index.js +22 -0
  59. package/dist/components/fields/components/Label/styles.d.ts +5 -0
  60. package/dist/components/fields/components/Label/styles.js +28 -0
  61. package/dist/components/fields/components/RotateButton/index.d.ts +6 -0
  62. package/dist/components/fields/components/RotateButton/index.js +13 -0
  63. package/dist/components/fields/components/RotateButton/styles.d.ts +5 -0
  64. package/dist/components/fields/components/RotateButton/styles.js +10 -0
  65. package/dist/components/fields/helpers/getFeedbackType.d.ts +2 -0
  66. package/dist/components/fields/helpers/getFeedbackType.js +11 -0
  67. package/dist/components/fields/modifiers/color_modifiers.d.ts +2 -0
  68. package/dist/components/fields/modifiers/color_modifiers.js +7 -0
  69. package/dist/components/fields/modifiers/inputColorModifier.d.ts +2 -0
  70. package/dist/components/fields/modifiers/inputColorModifier.js +14 -0
  71. package/dist/components/fields/modifiers/selectColorModifier.d.ts +2 -0
  72. package/dist/components/fields/modifiers/selectColorModifier.js +10 -0
  73. package/dist/index.d.ts +2 -2
  74. package/dist/index.js +2 -2
  75. package/dist/static/font/Inter-Italic.ttf +0 -0
  76. package/dist/static/font/Inter.ttf +0 -0
  77. package/dist/style/base.css +11 -4
  78. package/dist/types/feedback.d.ts +1 -0
  79. package/package.json +2 -2
  80. package/dist/assets/fonts/Inter-Regular.js +0 -2
  81. package/dist/components/CustomSelect/CustomSelect.stories.d.ts +0 -73
  82. package/dist/components/CustomSelect/CustomSelect.stories.js +0 -477
  83. package/dist/components/CustomSelect/CustomSelectList/index.d.ts +0 -10
  84. package/dist/components/CustomSelect/CustomSelectList/index.js +0 -66
  85. package/dist/components/CustomSelect/index.d.ts +0 -30
  86. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -61
  87. package/dist/components/MultiSelect/MultiSelect.stories.js +0 -336
  88. package/dist/static/font/Inter-Regular.ttf +0 -0
  89. /package/dist/components/MultiSelect/{calcTextSize.d.ts → helpers/calcTextSize.d.ts} +0 -0
  90. /package/dist/components/MultiSelect/{calcTextSize.js → helpers/calcTextSize.js} +0 -0
@@ -1,26 +1,6 @@
1
1
  import styled_components, { keyframes } from "styled-components";
2
2
  import { generateColorScale } from "./helpers/generateColorScale.js";
3
3
  import { getLuminance } from "./helpers/getLuminance.js";
4
- const shrinkToRight = keyframes`
5
- from {
6
- transform: scaleX(1);
7
- opacity: 1;
8
- }
9
- to {
10
- transform: scaleX(0);
11
- opacity: 0;
12
- }
13
- `;
14
- const growFromRight = keyframes`
15
- from {
16
- transform: scaleX(0);
17
- opacity: 0;
18
- }
19
- to {
20
- transform: scaleX(1);
21
- opacity: 1;
22
- }
23
- `;
24
4
  const fadeOutAndHide = keyframes`
25
5
  0% {
26
6
  opacity: 1;
@@ -53,6 +33,26 @@ const fadeInAndShow = keyframes`
53
33
  display: flex;
54
34
  }
55
35
  `;
36
+ const submenuEnter = keyframes`
37
+ from {
38
+ width: 0;
39
+ opacity: 0;
40
+ }
41
+ to {
42
+ width: 15.25rem;
43
+ opacity: 1;
44
+ }
45
+ `;
46
+ const submenuExit = keyframes`
47
+ from {
48
+ width: 15.25rem;
49
+ opacity: 1;
50
+ }
51
+ to {
52
+ width: 0;
53
+ opacity: 0;
54
+ }
55
+ `;
56
56
  const MenuAside = styled_components.aside`
57
57
  background-color: ${({ background })=>background || "#000"};
58
58
  box-sizing: border-box;
@@ -78,6 +78,7 @@ const MenuHeader = styled_components.div`
78
78
  `;
79
79
  const ContainerLogo = styled_components.div`
80
80
  padding: 0 0.5rem;
81
+ max-height: 8.875rem;
81
82
  animation: ${({ $expand })=>$expand ? fadeInAndShow : fadeOutAndHide}
82
83
  0.25s forwards;
83
84
 
@@ -124,33 +125,40 @@ const ItemMenu = styled_components.div`
124
125
  transition:
125
126
  opacity 0.4s ease,
126
127
  transform 0.4s ease;
127
- white-space: ${({ $expand })=>$expand ? "wrap" : "nowrap"};
128
+ white-space: ${({ $expand, $animating })=>$expand && !$animating ? "normal" : "nowrap"};
128
129
  overflow: hidden;
129
-
130
+ text-overflow: ellipsis;
130
131
  &:hover {
131
132
  opacity: 1;
132
133
  }
133
134
  }
134
135
  `;
135
136
  const SubItemsContainer = styled_components.div`
136
- animation: ${({ $isClosing })=>$isClosing ? shrinkToRight : growFromRight}
137
- 0.4s ease forwards;
137
+ animation: ${({ $isClosing })=>$isClosing ? submenuExit : submenuEnter}
138
+ 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
138
139
  background-color: ${({ background })=>generateColorScale(background || "#000000")[500]};
139
140
  box-sizing: border-box;
140
141
  display: flex;
141
142
  flex-direction: column;
142
143
  gap: 0.5rem;
143
144
  height: 100%;
144
- padding: 1rem 0 0 1rem;
145
+ padding: 0.5rem 0 0 1rem;
145
146
  position: absolute;
146
147
  right: 0;
147
148
  top: 0;
148
149
  transform-origin: right;
149
150
  width: 15.25rem;
150
151
  z-index: 1;
152
+ overflow: hidden;
151
153
  `;
152
154
  const SubItemsHeader = styled_components.div`
153
155
  padding: 0.5rem 0 1.5rem 0;
156
+ display: flex;
157
+ gap: 0.5rem;
158
+ color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
159
+ font-size: 1rem;
160
+ line-height: 1.5rem;
161
+ font-weight: 500;
154
162
 
155
163
  button {
156
164
  align-items: center;
@@ -159,13 +167,18 @@ const SubItemsHeader = styled_components.div`
159
167
  color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
160
168
  cursor: pointer;
161
169
  display: flex;
162
- font-size: 1rem;
163
- font-weight: 500;
164
170
  gap: 0.5rem;
165
171
  line-height: 1rem;
166
172
  margin: 0;
173
+ border-radius: 50%;
167
174
  padding: 0;
168
- transition: opacity 0.2s ease;
175
+ transition: all 0.2s ease;
176
+
177
+ &:hover {
178
+ background-color: ${({ background })=>generateColorScale(background || "#00000")["dark" === getLuminance(background || "#00000") ? 400 : 600]};
179
+ box-shadow: 0 0 0 2px
180
+ ${({ background })=>generateColorScale(background || "#00000")["dark" === getLuminance(background || "#00000") ? 400 : 600]};
181
+ }
169
182
  }
170
183
  `;
171
184
  const SubItemsWrapper = styled_components.div`
@@ -194,6 +207,9 @@ const SubMenuItem = styled_components.span`
194
207
  opacity: ${({ $active })=>$active ? "1" : "0.68"};
195
208
  padding: 0.5rem 0.75rem;
196
209
  transition: background-color 0.2s ease;
210
+ white-space: ${({ $expand, $animating })=>$expand && !$animating ? "normal" : "nowrap"};
211
+ overflow: hidden;
212
+ text-overflow: ellipsis;
197
213
 
198
214
  &:hover {
199
215
  opacity: 1;
@@ -0,0 +1,7 @@
1
+ import { type RowComponentProps } from "react-window";
2
+ import { IMultiSelectOption } from "../..";
3
+ export default function Row({ index, style, options, onClickOption, addAll, }: RowComponentProps<{
4
+ options: IMultiSelectOption[];
5
+ onClickOption?: (event: React.MouseEvent<HTMLDivElement>, option: IMultiSelectOption) => void;
6
+ addAll?: (event: React.MouseEvent<HTMLDivElement>) => void;
7
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { OptionContainer, SkeletonLine } from "./style.js";
3
+ function Row({ index, style, options, onClickOption, addAll }) {
4
+ const option = options[index];
5
+ const hasSelectAll = "__select_all" === option.value;
6
+ const handleClick = (event)=>{
7
+ if (hasSelectAll) {
8
+ console.log(addAll);
9
+ addAll?.(event);
10
+ return;
11
+ }
12
+ onClickOption?.(event, option);
13
+ };
14
+ return /*#__PURE__*/ jsxs(OptionContainer, {
15
+ style: style,
16
+ onClick: handleClick,
17
+ className: hasSelectAll ? "__select_all" : "",
18
+ children: [
19
+ "__loading__" !== option.value && /*#__PURE__*/ jsx("span", {
20
+ children: option.label
21
+ }),
22
+ "__loading__" === option.value && /*#__PURE__*/ jsx(SkeletonLine, {})
23
+ ]
24
+ });
25
+ }
26
+ export { Row as default };
@@ -0,0 +1,6 @@
1
+ export declare const OptionContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
+ export declare const SkeletonBase: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
+ export declare const SkeletonLine: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>, {
4
+ width?: string;
5
+ height?: string;
6
+ }>> & string;
@@ -0,0 +1,48 @@
1
+ import styled_components, { keyframes } from "styled-components";
2
+ import { COLOR_NEUTRAL_DARKER, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_DUSK, COLOR_NEUTRAL_LIGHT, COLOR_NEUTRAL_LIGHTER, FONT_FAMILY_01, FONT_WEIGHT_MEDIUM } from "@ftdata/f-tokens";
3
+ const OptionContainer = styled_components.div`
4
+ background-color: ${COLOR_NEUTRAL_DAY};
5
+ box-sizing: border-box;
6
+ cursor: pointer;
7
+ display: flex;
8
+ gap: 0.5rem;
9
+ padding: 0.5rem 1rem;
10
+ width: 100%;
11
+ align-items: center;
12
+
13
+ &:hover {
14
+ background-color: ${COLOR_NEUTRAL_LIGHTER};
15
+
16
+ span {
17
+ color: ${COLOR_NEUTRAL_DUSK};
18
+ }
19
+ }
20
+
21
+ span {
22
+ max-width: 80%;
23
+ color: ${COLOR_NEUTRAL_DARKER};
24
+ font-size: 0.875rem;
25
+ line-height: 1.25rem;
26
+ font-family: ${FONT_FAMILY_01};
27
+ font-weight: ${FONT_WEIGHT_MEDIUM};
28
+ white-space: nowrap;
29
+ overflow: hidden;
30
+ text-overflow: ellipsis;
31
+ }
32
+ `;
33
+ const pulse = keyframes`
34
+ 0% { opacity: 0.6; }
35
+ 50% { opacity: 1; }
36
+ 100% { opacity: 0.6; }
37
+ `;
38
+ const SkeletonBase = styled_components.div`
39
+ background-color: ${COLOR_NEUTRAL_LIGHT};
40
+ border-radius: 0.25rem;
41
+ animation: ${pulse} 1.5s ease-in-out infinite;
42
+ `;
43
+ const SkeletonLine = styled_components(SkeletonBase)`
44
+ display: flex;
45
+ height: ${({ height })=>height || "1.125rem"};
46
+ width: ${({ width })=>width || "100%"};
47
+ `;
48
+ export { OptionContainer, SkeletonBase, SkeletonLine };
@@ -1,10 +1,11 @@
1
1
  import { IMultiSelectOption } from "..";
2
- interface MultiSelectProps {
2
+ interface MultiSelectListProps {
3
3
  onClickOption?: (event: React.MouseEvent<HTMLDivElement>, option: IMultiSelectOption) => void;
4
4
  options: IMultiSelectOption[];
5
- isLoading?: boolean;
5
+ loading?: boolean;
6
6
  addAll?: (event: React.MouseEvent<HTMLDivElement>) => void;
7
7
  translation: (key: string) => string;
8
+ onLoadMore?: () => Promise<void>;
8
9
  }
9
- export default function MultiSelect({ options, onClickOption, isLoading, addAll, translation, }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
10
+ export default function MultiSelectList({ options, onClickOption, loading, addAll, translation, onLoadMore, }: MultiSelectListProps): import("react/jsx-runtime").JSX.Element;
10
11
  export {};
@@ -1,59 +1,69 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { FixedSizeList } from "react-window";
3
- import { LoadingContainer, OptionContainer, SelectDropdown } from "./style.js";
4
- import Loading from "../../Loading/Loading/index.js";
5
- const renderRow = ({ data, index, style, onClickOption, addAll })=>{
6
- const option = data[index];
7
- const hasSelectAll = "__select_all" === option.value;
8
- const handleClick = (event)=>{
9
- if (hasSelectAll) {
10
- if (addAll) addAll(event);
11
- return;
12
- }
13
- onClickOption?.(event, option);
14
- };
15
- return /*#__PURE__*/ jsx(OptionContainer, {
16
- style: style,
17
- onClick: handleClick,
18
- className: hasSelectAll ? "__select_all" : "",
19
- children: /*#__PURE__*/ jsx("span", {
20
- children: option.label
21
- })
22
- });
23
- };
24
- function MultiSelect({ options, onClickOption, isLoading, addAll, translation }) {
2
+ import { List } from "react-window";
3
+ import Row from "./Row/index.js";
4
+ import { LoadingContainer, SelectDropdown } from "./style.js";
5
+ import Loading from "../../Loading/index.js";
6
+ import { useCallback, useState } from "react";
7
+ function MultiSelectList({ options, onClickOption, loading, addAll, translation, onLoadMore }) {
8
+ const [lastIndex, setLastIndex] = useState(0);
9
+ const [loadingMore, setLoadingMore] = useState(false);
25
10
  const selectAll = {
26
11
  value: "__select_all",
27
12
  label: translation("select_all")
28
13
  };
29
- const newOptions = addAll ? [
14
+ const allOptions = addAll ? [
30
15
  selectAll,
31
16
  ...options
32
17
  ] : options;
33
18
  const OPTION_SIZE = 36;
34
- const optionLength = newOptions.length;
19
+ const optionLength = allOptions.length;
35
20
  const height = OPTION_SIZE * (0 === optionLength ? 1 : optionLength >= 7 ? 7 : optionLength);
21
+ const onItemsRendered = useCallback(async ({ stopIndex })=>{
22
+ const isAtEnd = stopIndex >= (addAll ? options.length : options.length - 1);
23
+ if (loadingMore) return;
24
+ try {
25
+ setLoadingMore(true);
26
+ if (lastIndex !== stopIndex && isAtEnd) {
27
+ if (onLoadMore) await onLoadMore();
28
+ setLastIndex(stopIndex);
29
+ }
30
+ } finally{
31
+ setLoadingMore(false);
32
+ }
33
+ }, [
34
+ options.length,
35
+ onLoadMore,
36
+ lastIndex
37
+ ]);
38
+ const loadingOption = {
39
+ value: "__loading__",
40
+ label: "loading"
41
+ };
36
42
  return /*#__PURE__*/ jsx(SelectDropdown, {
37
- children: isLoading ? /*#__PURE__*/ jsx(LoadingContainer, {
43
+ children: loading ? /*#__PURE__*/ jsx(LoadingContainer, {
38
44
  children: /*#__PURE__*/ jsx(Loading, {
39
45
  size: "lg",
40
46
  variant: "light"
41
47
  })
42
- }) : /*#__PURE__*/ jsx(FixedSizeList, {
43
- itemCount: newOptions.length,
44
- itemData: newOptions,
45
- itemSize: 36,
46
- height: height,
47
- width: "100%",
48
- itemKey: (index)=>newOptions[index].value || index,
49
- children: ({ index, style, data })=>renderRow({
50
- data,
51
- index,
52
- style,
53
- onClickOption,
54
- addAll
55
- })
48
+ }) : /*#__PURE__*/ jsx(List, {
49
+ rowComponent: Row,
50
+ rowCount: loadingMore ? allOptions.length + 1 : allOptions.length,
51
+ rowHeight: OPTION_SIZE,
52
+ rowProps: {
53
+ options: loadingMore ? [
54
+ ...allOptions,
55
+ loadingOption
56
+ ] : allOptions,
57
+ onClickOption,
58
+ addAll
59
+ },
60
+ style: {
61
+ height: `${height / 16}rem`,
62
+ width: "100%"
63
+ },
64
+ onRowsRendered: onItemsRendered,
65
+ overscanCount: 0
56
66
  })
57
67
  });
58
68
  }
59
- export { MultiSelect as default };
69
+ export { MultiSelectList as default };
@@ -1,3 +1,2 @@
1
1
  export declare const SelectDropdown: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
- export declare const OptionContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
2
  export declare const LoadingContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -1,5 +1,5 @@
1
1
  import styled_components from "styled-components";
2
- import { COLOR_ACCENT_MEDIUM, COLOR_NEUTRAL_DARKER, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_DUSK, COLOR_NEUTRAL_LIGHTER, FONT_FAMILY_01, FONT_WEIGHT_BOLD, FONT_WEIGHT_MEDIUM } from "@ftdata/f-tokens";
2
+ import { COLOR_ACCENT_MEDIUM, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_DUSK, FONT_WEIGHT_BOLD } from "@ftdata/f-tokens";
3
3
  const SelectDropdown = styled_components.div`
4
4
  background-color: ${COLOR_NEUTRAL_DAY};
5
5
  border-radius: 0.25rem;
@@ -45,38 +45,9 @@ const SelectDropdown = styled_components.div`
45
45
  }
46
46
  }
47
47
  `;
48
- const OptionContainer = styled_components.div`
49
- background-color: ${COLOR_NEUTRAL_DAY};
50
- box-sizing: border-box;
51
- cursor: pointer;
52
- display: flex;
53
- gap: 0.5rem;
54
- padding: 0.5rem 1rem;
55
- width: 100%;
56
-
57
- &:hover {
58
- background-color: ${COLOR_NEUTRAL_LIGHTER};
59
-
60
- span {
61
- color: ${COLOR_NEUTRAL_DUSK};
62
- }
63
- }
64
-
65
- span {
66
- max-width: 80%;
67
- color: ${COLOR_NEUTRAL_DARKER};
68
- font-size: 0.875rem;
69
- line-height: 1.25rem;
70
- font-family: ${FONT_FAMILY_01};
71
- font-weight: ${FONT_WEIGHT_MEDIUM};
72
- white-space: nowrap;
73
- overflow: hidden;
74
- text-overflow: ellipsis;
75
- }
76
- `;
77
48
  const LoadingContainer = styled_components.div`
78
49
  background-color: ${COLOR_NEUTRAL_DAY};
79
50
  height: 10rem;
80
51
  width: 100%;
81
52
  `;
82
- export { LoadingContainer, OptionContainer, SelectDropdown };
53
+ export { LoadingContainer, SelectDropdown };
@@ -0,0 +1,5 @@
1
+ import { IMultiSelectOption } from '..';
2
+ export declare const addOption: (selected: IMultiSelectOption[], options: IMultiSelectOption[], option: IMultiSelectOption, max?: number) => {
3
+ selected: IMultiSelectOption[];
4
+ unselected: IMultiSelectOption[];
5
+ } | undefined;
@@ -0,0 +1,14 @@
1
+ import { computeUnselected } from "./computeUnselected.js";
2
+ const addOption = (selected, options, option, max)=>{
3
+ if ('feedback__' === option.value) return;
4
+ if (max && selected.length >= max) return;
5
+ const newSelected = [
6
+ ...selected,
7
+ option
8
+ ];
9
+ return {
10
+ selected: newSelected,
11
+ unselected: computeUnselected(options, newSelected)
12
+ };
13
+ };
14
+ export { addOption };
@@ -0,0 +1,2 @@
1
+ import { IMultiSelectOption } from '..';
2
+ export declare const computeUnselected: (options: IMultiSelectOption[], selected: IMultiSelectOption[]) => IMultiSelectOption[];
@@ -0,0 +1,2 @@
1
+ const computeUnselected = (options, selected)=>options.filter((opt)=>!selected.some((selected)=>selected.value === opt.value));
2
+ export { computeUnselected };
@@ -0,0 +1,5 @@
1
+ import { IMultiSelectOption } from '..';
2
+ export declare function feedbackText(translation: (key: string) => string, options: IMultiSelectOption[], filtered: IMultiSelectOption[], selected: IMultiSelectOption[], query: string, max?: number): {
3
+ value: string;
4
+ label: string;
5
+ }[];
@@ -0,0 +1,30 @@
1
+ import { computeUnselected } from "./computeUnselected.js";
2
+ function feedbackText(translation, options, filtered, selected, query, max) {
3
+ if (!options.length) return [
4
+ {
5
+ value: 'feedback__',
6
+ label: translation('no_data_is_available')
7
+ }
8
+ ];
9
+ if (max && selected.length >= max) return [
10
+ {
11
+ value: 'feedback__',
12
+ label: translation('the_selection_limit_has_been_reached')
13
+ }
14
+ ];
15
+ if (query && !filtered.length) return [
16
+ {
17
+ value: 'feedback__',
18
+ label: translation('no_data_was_found')
19
+ }
20
+ ];
21
+ const unselected = computeUnselected(options, selected);
22
+ if (!query && !unselected.length) return [
23
+ {
24
+ value: 'feedback__',
25
+ label: translation('all_were_selected')
26
+ }
27
+ ];
28
+ return [];
29
+ }
30
+ export { feedbackText };
@@ -0,0 +1,2 @@
1
+ import { IMultiSelectOption } from '..';
2
+ export declare const filterOptions: (options: IMultiSelectOption[], query: string) => IMultiSelectOption[];
@@ -0,0 +1,5 @@
1
+ const filterOptions = (options, query)=>{
2
+ const normalizedQuery = query.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
3
+ return options.filter((o)=>o.label.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').includes(normalizedQuery));
4
+ };
5
+ export { filterOptions };
@@ -0,0 +1,5 @@
1
+ import { IMultiSelectOption } from '..';
2
+ export declare const removeOption: (selected: IMultiSelectOption[], options: IMultiSelectOption[], option: IMultiSelectOption) => {
3
+ selected: IMultiSelectOption[];
4
+ unselected: IMultiSelectOption[];
5
+ };
@@ -0,0 +1,9 @@
1
+ import { computeUnselected } from "./computeUnselected.js";
2
+ const removeOption = (selected, options, option)=>{
3
+ const newSelected = selected.filter((o)=>o.value !== option.value);
4
+ return {
5
+ selected: newSelected,
6
+ unselected: computeUnselected(options, newSelected)
7
+ };
8
+ };
9
+ export { removeOption };
@@ -1,24 +1,39 @@
1
- import { InputHTMLAttributes } from "react";
1
+ import { InputHTMLAttributes, JSX } from "react";
2
+ import { FieldFeedbackType } from "../../types/feedback";
3
+ import { IconsNames } from "@ftdata/f-icons";
2
4
  export interface IMultiSelectOption {
3
5
  value: string;
4
6
  label: string;
5
7
  }
8
+ export interface IMultiSelectState {
9
+ selected: IMultiSelectOption[];
10
+ options: IMultiSelectOption[];
11
+ filtered: IMultiSelectOption[];
12
+ unselected: IMultiSelectOption[];
13
+ }
14
+ export interface IMultiSelectActions {
15
+ clear: () => void;
16
+ search?: (query: string) => void;
17
+ }
6
18
  interface MultiSelectProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value"> {
19
+ disabled?: boolean;
7
20
  helpText?: string;
21
+ helpIcon?: IconsNames;
22
+ icon?: IconsNames | JSX.Element;
23
+ rightItem?: JSX.Element;
8
24
  label?: string;
9
- name?: string;
10
- onChangeItems?: (options: IMultiSelectOption[]) => void;
11
- options: IMultiSelectOption[];
12
- optional?: string;
13
- required?: boolean;
14
- selectAll?: boolean;
15
- placeholder: string;
16
- isLoading?: boolean;
17
- isError?: boolean;
18
- isSuccess?: boolean;
19
- maxItems?: number;
25
+ sublabel?: string;
26
+ feedback?: FieldFeedbackType;
27
+ clear?: () => void;
28
+ loading?: boolean;
29
+ state: IMultiSelectState;
30
+ actions: IMultiSelectActions;
31
+ updateState: (newPartial: Partial<IMultiSelectState>) => void;
20
32
  translation: (key: string) => string;
21
- value?: IMultiSelectOption[];
33
+ max?: number;
34
+ selectAll?: boolean;
35
+ total?: number;
36
+ onLoadMore?: () => Promise<void>;
22
37
  }
23
- export default function MultiSelect({ helpText, label, isLoading, name, onChangeItems, optional, options, required, maxItems, placeholder, selectAll, isError, value, isSuccess, translation, ...rest }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
38
+ export default function MultiSelect({ helpText, label, sublabel, required, disabled, feedback, helpIcon, name, translation, state, updateState, placeholder, max, loading, actions, selectAll, total, icon, onLoadMore, }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
24
39
  export {};