@ftdata/ui 0.0.16 → 0.0.17
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/components/IconButton/index.d.ts +15 -0
- package/dist/components/IconButton/index.js +37 -0
- package/dist/components/IconButton/modifiers/color.d.ts +36 -0
- package/dist/components/IconButton/modifiers/color.js +38 -0
- package/dist/components/IconButton/styles.d.ts +10 -0
- package/dist/components/IconButton/styles.js +32 -0
- package/dist/components/Modal/index.d.ts +25 -0
- package/dist/components/Modal/index.js +69 -0
- package/dist/components/Modal/styles.d.ts +8 -0
- package/dist/components/Modal/styles.js +81 -0
- package/dist/components/MultiSelect/components/Badge/index.d.ts +2 -1
- package/dist/components/MultiSelect/components/Badge/index.js +5 -2
- package/dist/components/MultiSelect/components/Badge/styles.d.ts +5 -1
- package/dist/components/MultiSelect/components/Badge/styles.js +2 -1
- package/dist/components/MultiSelect/components/MultiSelectList/Row/index.d.ts +3 -2
- package/dist/components/MultiSelect/components/MultiSelectList/Row/index.js +21 -10
- package/dist/components/MultiSelect/components/MultiSelectList/Row/style.js +0 -1
- package/dist/components/MultiSelect/components/MultiSelectList/index.d.ts +3 -3
- package/dist/components/MultiSelect/components/MultiSelectList/index.js +8 -11
- package/dist/components/MultiSelect/components/MultiSelectList/style.d.ts +1 -1
- package/dist/components/MultiSelect/components/MultiSelectList/style.js +21 -3
- package/dist/components/MultiSelect/helpers/addOption.d.ts +3 -3
- package/dist/components/MultiSelect/helpers/computeUnselected.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/computeUnselected.js +1 -1
- package/dist/components/MultiSelect/helpers/feedbackText.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/feedbackText.js +9 -9
- package/dist/components/MultiSelect/helpers/filterOptions.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/removeOptions.d.ts +3 -3
- package/dist/components/MultiSelect/index.d.ts +37 -19
- package/dist/components/MultiSelect/index.js +92 -135
- package/dist/components/MultiSelect/styles.js +8 -23
- package/dist/components/Texts/paragraphs.d.ts +12 -0
- package/dist/components/Texts/paragraphs.js +14 -0
- package/dist/components/Texts/text.d.ts +17 -0
- package/dist/components/Texts/text.js +21 -0
- package/dist/components/Texts/titles.d.ts +7 -0
- package/dist/components/Texts/titles.js +37 -0
- package/dist/components/fields/modifiers/selectColorModifier.d.ts +1 -1
- package/dist/components/fields/modifiers/selectColorModifier.js +7 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -2
- package/package.json +3 -3
- package/dist/components/MultiSelect/helpers/arraysEqual.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/arraysEqual.js +0 -5
- package/dist/components/MultiSelect/helpers/computeSelected.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/computeSelected.js +0 -2
- package/dist/components/MultiSelect/helpers/getChangedFieds.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/getChangedFieds.js +0 -17
- package/dist/components/MultiSelect/hooks/useMultiSelect.d.ts +0 -10
- package/dist/components/MultiSelect/hooks/useMultiSelect.js +0 -44
- package/dist/components/MultiSelect/interfaces/actions.d.ts +0 -4
- package/dist/components/MultiSelect/interfaces/actions.js +0 -0
- package/dist/components/MultiSelect/interfaces/config.d.ts +0 -17
- package/dist/components/MultiSelect/interfaces/config.js +0 -0
- package/dist/components/MultiSelect/interfaces/state.d.ts +0 -10
- package/dist/components/MultiSelect/interfaces/state.js +0 -0
- package/dist/components/MultiSelect/reducers/stateReducer.d.ts +0 -21
- package/dist/components/MultiSelect/reducers/stateReducer.js +0 -44
- package/dist/components/Text/Paragraph/Paragraph.stories.d.ts +0 -29
- package/dist/components/Text/Paragraph/Paragraph.stories.js +0 -124
- package/dist/components/Text/Title/Title.stories.d.ts +0 -41
- package/dist/components/Text/Title/Title.stories.js +0 -106
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IconsNames } from "@ftdata/f-icons";
|
|
3
|
+
export type IconButtonVariants = "default" | "accent" | "danger" | "success" | "warning" | "light";
|
|
4
|
+
export type IconButtonSizes = "small" | "medium" | "big";
|
|
5
|
+
interface IconButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
icon: IconsNames;
|
|
7
|
+
variant?: IconButtonVariants;
|
|
8
|
+
size?: IconButtonSizes | string;
|
|
9
|
+
iconSize?: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
active?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export default function IconButton({ icon, variant, size, iconSize, color, disabled, active, ...rest }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { IconButtonStyled } from "./styles.js";
|
|
4
|
+
import { Icon } from "@ftdata/f-icons";
|
|
5
|
+
const SIZE_VARIANTS = {
|
|
6
|
+
small: {
|
|
7
|
+
buttonSize: "1.5rem",
|
|
8
|
+
iconSize: "1rem"
|
|
9
|
+
},
|
|
10
|
+
medium: {
|
|
11
|
+
buttonSize: "2rem",
|
|
12
|
+
iconSize: "1.5rem"
|
|
13
|
+
},
|
|
14
|
+
big: {
|
|
15
|
+
buttonSize: "2.5rem",
|
|
16
|
+
iconSize: "2rem"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function IconButton({ icon, variant = "default", size = "medium", iconSize, color, disabled = false, active = false, ...rest }) {
|
|
20
|
+
const isPresetSize = size in SIZE_VARIANTS;
|
|
21
|
+
const buttonSize = isPresetSize ? SIZE_VARIANTS[size].buttonSize : size;
|
|
22
|
+
const finalIconSize = iconSize || (isPresetSize ? SIZE_VARIANTS[size].iconSize : "1.5rem");
|
|
23
|
+
return /*#__PURE__*/ jsx(IconButtonStyled, {
|
|
24
|
+
variant: variant,
|
|
25
|
+
size: buttonSize,
|
|
26
|
+
color: color,
|
|
27
|
+
disabled: disabled,
|
|
28
|
+
$active: active,
|
|
29
|
+
...rest,
|
|
30
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
31
|
+
name: icon,
|
|
32
|
+
size: finalIconSize,
|
|
33
|
+
color: "currentColor"
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { IconButton as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const ICON_BUTTON_COLOR_MODIFIERS: {
|
|
2
|
+
default: {
|
|
3
|
+
background: string;
|
|
4
|
+
color: string;
|
|
5
|
+
hover: string;
|
|
6
|
+
};
|
|
7
|
+
accent: {
|
|
8
|
+
background: string;
|
|
9
|
+
color: string;
|
|
10
|
+
hover: string;
|
|
11
|
+
};
|
|
12
|
+
danger: {
|
|
13
|
+
background: string;
|
|
14
|
+
color: string;
|
|
15
|
+
hover: string;
|
|
16
|
+
};
|
|
17
|
+
success: {
|
|
18
|
+
background: string;
|
|
19
|
+
color: string;
|
|
20
|
+
hover: string;
|
|
21
|
+
};
|
|
22
|
+
warning: {
|
|
23
|
+
background: string;
|
|
24
|
+
color: string;
|
|
25
|
+
hover: string;
|
|
26
|
+
};
|
|
27
|
+
light: {
|
|
28
|
+
background: string;
|
|
29
|
+
color: string;
|
|
30
|
+
hover: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export declare const ICON_BUTTON_DISABLED_MODIFIERS: {
|
|
34
|
+
opacity: number;
|
|
35
|
+
cursor: string;
|
|
36
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { COLOR_ACCENT_LIGHTER, COLOR_ACCENT_MEDIUM, COLOR_DANGER_LIGHTER, COLOR_DANGER_MEDIUM, COLOR_NEUTRAL_DARKER, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_LIGHTER, COLOR_SUCCESS_LIGHTER, COLOR_SUCCESS_MEDIUM, COLOR_WARNING_LIGHTER, COLOR_WARNING_MEDIUM } from "@ftdata/f-tokens";
|
|
2
|
+
const ICON_BUTTON_COLOR_MODIFIERS = {
|
|
3
|
+
default: {
|
|
4
|
+
background: COLOR_NEUTRAL_LIGHTER,
|
|
5
|
+
color: COLOR_NEUTRAL_DARKER,
|
|
6
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
7
|
+
},
|
|
8
|
+
accent: {
|
|
9
|
+
background: COLOR_ACCENT_LIGHTER,
|
|
10
|
+
color: COLOR_ACCENT_MEDIUM,
|
|
11
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
12
|
+
},
|
|
13
|
+
danger: {
|
|
14
|
+
background: COLOR_DANGER_LIGHTER,
|
|
15
|
+
color: COLOR_DANGER_MEDIUM,
|
|
16
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
17
|
+
},
|
|
18
|
+
success: {
|
|
19
|
+
background: COLOR_SUCCESS_LIGHTER,
|
|
20
|
+
color: COLOR_SUCCESS_MEDIUM,
|
|
21
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
22
|
+
},
|
|
23
|
+
warning: {
|
|
24
|
+
background: COLOR_WARNING_LIGHTER,
|
|
25
|
+
color: COLOR_WARNING_MEDIUM,
|
|
26
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
27
|
+
},
|
|
28
|
+
light: {
|
|
29
|
+
background: "rgba(255, 255, 255, 0.5)",
|
|
30
|
+
color: COLOR_NEUTRAL_DAY,
|
|
31
|
+
hover: "rgba(255, 255, 255, 0.32)"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const ICON_BUTTON_DISABLED_MODIFIERS = {
|
|
35
|
+
opacity: 0.5,
|
|
36
|
+
cursor: "not-allowed"
|
|
37
|
+
};
|
|
38
|
+
export { ICON_BUTTON_COLOR_MODIFIERS, ICON_BUTTON_DISABLED_MODIFIERS };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IconButtonVariants } from ".";
|
|
2
|
+
interface IconButtonStyledProps {
|
|
3
|
+
variant: IconButtonVariants;
|
|
4
|
+
size: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
$active?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const IconButtonStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, IconButtonStyledProps>> & string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import styled_components from "styled-components";
|
|
2
|
+
import { ICON_BUTTON_COLOR_MODIFIERS, ICON_BUTTON_DISABLED_MODIFIERS } from "./modifiers/color.js";
|
|
3
|
+
import { COLOR_NEUTRAL_DARKER } from "@ftdata/f-tokens";
|
|
4
|
+
const IconButtonStyled = styled_components.button`
|
|
5
|
+
border-radius: 50%;
|
|
6
|
+
transition: all 0.15s ease-in-out;
|
|
7
|
+
width: ${({ size })=>size};
|
|
8
|
+
height: ${({ size })=>size};
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
color: ${({ color })=>color || COLOR_NEUTRAL_DARKER};
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
background-color: ${({ variant })=>ICON_BUTTON_COLOR_MODIFIERS[variant].hover};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:active {
|
|
19
|
+
background-color: ${({ variant })=>ICON_BUTTON_COLOR_MODIFIERS[variant].background};
|
|
20
|
+
color: ${({ variant })=>ICON_BUTTON_COLOR_MODIFIERS[variant].color};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
${({ $active, variant })=>$active && `
|
|
24
|
+
color: ${ICON_BUTTON_COLOR_MODIFIERS[variant].color};
|
|
25
|
+
`}
|
|
26
|
+
|
|
27
|
+
${({ disabled })=>disabled && `
|
|
28
|
+
opacity: ${ICON_BUTTON_DISABLED_MODIFIERS.opacity};
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
`}
|
|
31
|
+
`;
|
|
32
|
+
export { IconButtonStyled };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type ModalSizeCustom = {
|
|
3
|
+
width: string;
|
|
4
|
+
height: string;
|
|
5
|
+
};
|
|
6
|
+
export type ModalSizes = "small" | "medium" | "large" | ModalSizeCustom;
|
|
7
|
+
export type ModalAction = {
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
label: string;
|
|
10
|
+
shouldClose?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type ModalActions = {
|
|
14
|
+
primary?: ModalAction;
|
|
15
|
+
secondary?: ModalAction;
|
|
16
|
+
};
|
|
17
|
+
export interface ModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
size?: ModalSizes;
|
|
20
|
+
title?: string;
|
|
21
|
+
message?: string;
|
|
22
|
+
closeHandler: () => void;
|
|
23
|
+
actions?: ModalActions;
|
|
24
|
+
}
|
|
25
|
+
export default function Modal({ children, size, title, message, closeHandler, actions, }: ModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { ActionsContainer, ContentContainer, ModalContainer } from "./styles.js";
|
|
4
|
+
import { Title } from "../Texts/titles.js";
|
|
5
|
+
import { Paragraph } from "../Texts/paragraphs.js";
|
|
6
|
+
import Button from "../Button/index.js";
|
|
7
|
+
import IconButton from "../IconButton/index.js";
|
|
8
|
+
function Modal({ children, size, title, message, closeHandler, actions }) {
|
|
9
|
+
const [isClosing, setIsClosing] = useState(false);
|
|
10
|
+
const handleClose = useCallback(()=>{
|
|
11
|
+
setIsClosing(true);
|
|
12
|
+
setTimeout(()=>{
|
|
13
|
+
closeHandler();
|
|
14
|
+
}, 200);
|
|
15
|
+
}, [
|
|
16
|
+
closeHandler
|
|
17
|
+
]);
|
|
18
|
+
const handleActionClick = useCallback((action)=>{
|
|
19
|
+
action.onClick();
|
|
20
|
+
if (action.shouldClose) handleClose();
|
|
21
|
+
}, [
|
|
22
|
+
handleClose
|
|
23
|
+
]);
|
|
24
|
+
return /*#__PURE__*/ jsxs(ModalContainer, {
|
|
25
|
+
size: size,
|
|
26
|
+
isClosing: isClosing,
|
|
27
|
+
children: [
|
|
28
|
+
/*#__PURE__*/ jsx(IconButton, {
|
|
29
|
+
icon: "ui delete-disabled",
|
|
30
|
+
size: "small",
|
|
31
|
+
onClick: handleClose,
|
|
32
|
+
style: {
|
|
33
|
+
position: "absolute",
|
|
34
|
+
top: "1rem",
|
|
35
|
+
right: "1rem"
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
/*#__PURE__*/ jsxs(ContentContainer, {
|
|
39
|
+
children: [
|
|
40
|
+
title && /*#__PURE__*/ jsx(Title, {
|
|
41
|
+
as: "h2",
|
|
42
|
+
children: title
|
|
43
|
+
}),
|
|
44
|
+
message && /*#__PURE__*/ jsx(Paragraph, {
|
|
45
|
+
children: message
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
children,
|
|
50
|
+
actions && /*#__PURE__*/ jsxs(ActionsContainer, {
|
|
51
|
+
children: [
|
|
52
|
+
actions.secondary && /*#__PURE__*/ jsx(Button, {
|
|
53
|
+
onClick: ()=>handleActionClick(actions.secondary),
|
|
54
|
+
type: "button",
|
|
55
|
+
variant: "secondary",
|
|
56
|
+
children: actions.secondary.label
|
|
57
|
+
}),
|
|
58
|
+
actions.primary && /*#__PURE__*/ jsx(Button, {
|
|
59
|
+
onClick: ()=>handleActionClick(actions.primary),
|
|
60
|
+
type: "button",
|
|
61
|
+
variant: "primary",
|
|
62
|
+
children: actions.primary.label
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export { Modal as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModalProps, ModalSizes } from '.';
|
|
2
|
+
export declare const getSize: (size?: ModalSizes) => import("styled-components").RuleSet<object> | undefined;
|
|
3
|
+
export declare const ModalOverlay: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
+
export declare const ModalContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Partial<ModalProps> & {
|
|
5
|
+
isClosing?: boolean;
|
|
6
|
+
}>> & string;
|
|
7
|
+
export declare const ActionsContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
8
|
+
export declare const ContentContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import styled_components, { css, keyframes } from "styled-components";
|
|
2
|
+
import { COLOR_NEUTRAL_DARKER, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_DUSK } from "@ftdata/f-tokens";
|
|
3
|
+
const SIZES = {
|
|
4
|
+
small: '31.5rem',
|
|
5
|
+
medium: '42.5rem',
|
|
6
|
+
large: '53.5rem'
|
|
7
|
+
};
|
|
8
|
+
const slideIn = keyframes`
|
|
9
|
+
from {
|
|
10
|
+
opacity: 0.5;
|
|
11
|
+
transform: translateY(0.625rem) scale(0.97);
|
|
12
|
+
}
|
|
13
|
+
to {
|
|
14
|
+
opacity: 1;
|
|
15
|
+
transform: translateY(0) scale(1);
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
const fadeOut = keyframes`
|
|
19
|
+
from {
|
|
20
|
+
opacity: 1;
|
|
21
|
+
}
|
|
22
|
+
to {
|
|
23
|
+
opacity: 0;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const getSize = (size)=>{
|
|
27
|
+
if (!size) return;
|
|
28
|
+
if ('object' == typeof size) return css`
|
|
29
|
+
height: ${size.height};
|
|
30
|
+
width: ${size.width};
|
|
31
|
+
`;
|
|
32
|
+
return css`
|
|
33
|
+
width: ${SIZES[size]};
|
|
34
|
+
`;
|
|
35
|
+
};
|
|
36
|
+
const ModalOverlay = styled_components.div`
|
|
37
|
+
background-color: ${COLOR_NEUTRAL_DUSK};
|
|
38
|
+
position: fixed;
|
|
39
|
+
height: 100vh;
|
|
40
|
+
opacity: 0.32;
|
|
41
|
+
right: 0;
|
|
42
|
+
top: 0;
|
|
43
|
+
width: 100vw;
|
|
44
|
+
z-index: 999;
|
|
45
|
+
`;
|
|
46
|
+
const ModalContainer = styled_components.div`
|
|
47
|
+
display: flex;
|
|
48
|
+
position: relative;
|
|
49
|
+
padding: 2rem;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
border-radius: 0.5rem;
|
|
52
|
+
box-shadow: 0px 4px 8px 0px #6b757c52;
|
|
53
|
+
gap: 2rem;
|
|
54
|
+
position: relative;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
background-color: ${COLOR_NEUTRAL_DAY};
|
|
57
|
+
animation: ${({ isClosing })=>isClosing ? fadeOut : slideIn} 0.2s ease-out;
|
|
58
|
+
|
|
59
|
+
${({ size })=>getSize(size)};
|
|
60
|
+
`;
|
|
61
|
+
const ActionsContainer = styled_components.div`
|
|
62
|
+
display: flex;
|
|
63
|
+
width: 100%;
|
|
64
|
+
gap: 1rem;
|
|
65
|
+
justify-content: flex-end;
|
|
66
|
+
`;
|
|
67
|
+
const ContentContainer = styled_components.div`
|
|
68
|
+
display: flex;
|
|
69
|
+
width: 100%;
|
|
70
|
+
gap: 1.5rem;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
|
|
73
|
+
h2 {
|
|
74
|
+
color: ${COLOR_NEUTRAL_DUSK};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
p {
|
|
78
|
+
color: ${COLOR_NEUTRAL_DARKER};
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
export { ActionsContainer, ContentContainer, ModalContainer, ModalOverlay, getSize };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface BadgeProps {
|
|
2
2
|
text: string;
|
|
3
3
|
remove: () => void;
|
|
4
|
+
disabled?: boolean;
|
|
4
5
|
}
|
|
5
|
-
export default function Badge({ text, remove }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default function Badge({ text, remove, disabled }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export {};
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { BadgeContainer } from "./styles.js";
|
|
4
4
|
import { Icon } from "@ftdata/f-icons";
|
|
5
|
-
function Badge({ text, remove }) {
|
|
5
|
+
function Badge({ text, remove, disabled }) {
|
|
6
6
|
const [isVisible, setIsVisible] = useState(true);
|
|
7
7
|
const handleRemove = ()=>{
|
|
8
8
|
setIsVisible(false);
|
|
@@ -12,12 +12,15 @@ function Badge({ text, remove }) {
|
|
|
12
12
|
};
|
|
13
13
|
return /*#__PURE__*/ jsxs(BadgeContainer, {
|
|
14
14
|
className: isVisible ? "" : "remove",
|
|
15
|
+
disabled: disabled,
|
|
16
|
+
title: text,
|
|
15
17
|
children: [
|
|
16
18
|
/*#__PURE__*/ jsx("span", {
|
|
17
19
|
children: text
|
|
18
20
|
}),
|
|
19
|
-
/*#__PURE__*/ jsx("button", {
|
|
21
|
+
!disabled && /*#__PURE__*/ jsx("button", {
|
|
20
22
|
onClick: handleRemove,
|
|
23
|
+
type: "button",
|
|
21
24
|
children: /*#__PURE__*/ jsx(Icon, {
|
|
22
25
|
name: "ui delete-disabled",
|
|
23
26
|
size: "1rem",
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
interface BadgeContainerProps {
|
|
2
|
+
disabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare const BadgeContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, BadgeContainerProps>> & string;
|
|
5
|
+
export {};
|
|
@@ -21,7 +21,7 @@ const popOut = keyframes`
|
|
|
21
21
|
}
|
|
22
22
|
`;
|
|
23
23
|
const BadgeContainer = styled_components.div`
|
|
24
|
-
background-color: ${COLOR_NEUTRAL_LIGHTER};
|
|
24
|
+
background-color: ${({ disabled })=>disabled ? "rgba(0, 0, 0, 0.06)" : COLOR_NEUTRAL_LIGHTER};
|
|
25
25
|
border-radius: 0.25rem;
|
|
26
26
|
display: flex;
|
|
27
27
|
padding: 0.25rem 0.5rem;
|
|
@@ -29,6 +29,7 @@ const BadgeContainer = styled_components.div`
|
|
|
29
29
|
opacity: 0;
|
|
30
30
|
transform: scale(0.8);
|
|
31
31
|
animation: ${popIn} 0.15s forwards;
|
|
32
|
+
cursor: default;
|
|
32
33
|
|
|
33
34
|
&.remove {
|
|
34
35
|
animation: ${popOut} 0.15s forwards;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type RowComponentProps } from "react-window";
|
|
2
|
-
import { IMultiSelectOption } from "
|
|
3
|
-
export default function Row({ index, style, options, onClickOption, addAll, }: RowComponentProps<{
|
|
2
|
+
import { IMultiSelectOption } from "../../..";
|
|
3
|
+
export default function Row({ index, style, options, onClickOption, addAll, translation, }: RowComponentProps<{
|
|
4
4
|
options: IMultiSelectOption[];
|
|
5
5
|
onClickOption?: (event: React.MouseEvent<HTMLDivElement>, option: IMultiSelectOption) => void;
|
|
6
6
|
addAll?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
7
|
+
translation: (key: string) => string;
|
|
7
8
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { OptionContainer
|
|
3
|
-
function Row({ index, style, options, onClickOption, addAll }) {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { OptionContainer } from "./style.js";
|
|
3
|
+
function Row({ index, style, options, onClickOption, addAll, translation }) {
|
|
4
4
|
const option = options[index];
|
|
5
5
|
const hasSelectAll = "__select_all" === option.value;
|
|
6
|
+
const isLoading = "__loading__" === option.value;
|
|
6
7
|
const handleClick = (event)=>{
|
|
8
|
+
if (isLoading) return;
|
|
7
9
|
if (hasSelectAll) {
|
|
8
10
|
console.log(addAll);
|
|
9
11
|
addAll?.(event);
|
|
@@ -11,16 +13,25 @@ function Row({ index, style, options, onClickOption, addAll }) {
|
|
|
11
13
|
}
|
|
12
14
|
onClickOption?.(event, option);
|
|
13
15
|
};
|
|
14
|
-
return /*#__PURE__*/
|
|
16
|
+
if (isLoading) return /*#__PURE__*/ jsx(OptionContainer, {
|
|
17
|
+
style: style,
|
|
18
|
+
className: "__loading",
|
|
19
|
+
title: translation("loading_more"),
|
|
20
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
21
|
+
style: {
|
|
22
|
+
opacity: 0.6
|
|
23
|
+
},
|
|
24
|
+
children: translation("loading_more")
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
return /*#__PURE__*/ jsx(OptionContainer, {
|
|
15
28
|
style: style,
|
|
16
29
|
onClick: handleClick,
|
|
17
30
|
className: hasSelectAll ? "__select_all" : "",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"__loading__" === option.value && /*#__PURE__*/ jsx(SkeletonLine, {})
|
|
23
|
-
]
|
|
31
|
+
title: option.label,
|
|
32
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
33
|
+
children: option.label
|
|
34
|
+
})
|
|
24
35
|
});
|
|
25
36
|
}
|
|
26
37
|
export { Row as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMultiSelectOption } from "
|
|
1
|
+
import { IMultiSelectOption } from "../..";
|
|
2
2
|
interface MultiSelectListProps {
|
|
3
3
|
onClickOption?: (event: React.MouseEvent<HTMLDivElement>, option: IMultiSelectOption) => void;
|
|
4
4
|
options: IMultiSelectOption[];
|
|
@@ -6,7 +6,7 @@ interface MultiSelectListProps {
|
|
|
6
6
|
addAll?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
7
7
|
translation: (key: string) => string;
|
|
8
8
|
onLoadMore?: () => Promise<void>;
|
|
9
|
-
|
|
9
|
+
listPosition?: "top" | "bottom";
|
|
10
10
|
}
|
|
11
|
-
export default function MultiSelectList({ options, onClickOption, loading, addAll, translation, onLoadMore,
|
|
11
|
+
export default function MultiSelectList({ options, onClickOption, loading, addAll, translation, onLoadMore, listPosition, }: MultiSelectListProps): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -3,8 +3,8 @@ import { List } from "react-window";
|
|
|
3
3
|
import Row from "./Row/index.js";
|
|
4
4
|
import { LoadingContainer, SelectDropdown } from "./style.js";
|
|
5
5
|
import Loading from "../../../Loading/index.js";
|
|
6
|
-
import {
|
|
7
|
-
function MultiSelectList({ options, onClickOption, loading, addAll, translation, onLoadMore,
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
function MultiSelectList({ options, onClickOption, loading, addAll, translation, onLoadMore, listPosition = "bottom" }) {
|
|
8
8
|
const [lastIndex, setLastIndex] = useState(0);
|
|
9
9
|
const [loadingMore, setLoadingMore] = useState(false);
|
|
10
10
|
const selectAll = {
|
|
@@ -18,7 +18,7 @@ function MultiSelectList({ options, onClickOption, loading, addAll, translation,
|
|
|
18
18
|
const OPTION_SIZE = 36;
|
|
19
19
|
const optionLength = allOptions.length;
|
|
20
20
|
const height = OPTION_SIZE * (0 === optionLength ? 1 : optionLength >= 7 ? 7 : optionLength);
|
|
21
|
-
const onItemsRendered =
|
|
21
|
+
const onItemsRendered = async ({ stopIndex })=>{
|
|
22
22
|
const isAtEnd = stopIndex >= (addAll ? options.length : options.length - 1);
|
|
23
23
|
if (loadingMore) return;
|
|
24
24
|
try {
|
|
@@ -30,17 +30,13 @@ function MultiSelectList({ options, onClickOption, loading, addAll, translation,
|
|
|
30
30
|
} finally{
|
|
31
31
|
setLoadingMore(false);
|
|
32
32
|
}
|
|
33
|
-
}
|
|
34
|
-
options.length,
|
|
35
|
-
onLoadMore,
|
|
36
|
-
lastIndex
|
|
37
|
-
]);
|
|
33
|
+
};
|
|
38
34
|
const loadingOption = {
|
|
39
35
|
value: "__loading__",
|
|
40
|
-
label: "
|
|
36
|
+
label: translation("loading_more")
|
|
41
37
|
};
|
|
42
38
|
return /*#__PURE__*/ jsx(SelectDropdown, {
|
|
43
|
-
|
|
39
|
+
listPosition: listPosition,
|
|
44
40
|
children: loading ? /*#__PURE__*/ jsx(LoadingContainer, {
|
|
45
41
|
children: /*#__PURE__*/ jsx(Loading, {
|
|
46
42
|
size: "lg",
|
|
@@ -56,7 +52,8 @@ function MultiSelectList({ options, onClickOption, loading, addAll, translation,
|
|
|
56
52
|
loadingOption
|
|
57
53
|
] : allOptions,
|
|
58
54
|
onClickOption,
|
|
59
|
-
addAll
|
|
55
|
+
addAll,
|
|
56
|
+
translation
|
|
60
57
|
},
|
|
61
58
|
style: {
|
|
62
59
|
height: `${height / 16}rem`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
interface SelectDropdownProps {
|
|
2
|
-
|
|
2
|
+
listPosition?: "top" | "bottom";
|
|
3
3
|
}
|
|
4
4
|
export declare const SelectDropdown: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, SelectDropdownProps>> & string;
|
|
5
5
|
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,21 @@
|
|
|
1
|
-
import styled_components from "styled-components";
|
|
1
|
+
import styled_components, { keyframes } from "styled-components";
|
|
2
2
|
import { COLOR_ACCENT_MEDIUM, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_DUSK, FONT_WEIGHT_BOLD } from "@ftdata/f-tokens";
|
|
3
|
+
const slideDown = keyframes`
|
|
4
|
+
0% {
|
|
5
|
+
transform: translateY(-0.25rem);
|
|
6
|
+
}
|
|
7
|
+
100% {
|
|
8
|
+
transform: translateY(0);
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
const slideUp = keyframes`
|
|
12
|
+
0% {
|
|
13
|
+
transform: translateY(0.25rem);
|
|
14
|
+
}
|
|
15
|
+
100% {
|
|
16
|
+
transform: translateY(0);
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
3
19
|
const SelectDropdown = styled_components.div`
|
|
4
20
|
background-color: ${COLOR_NEUTRAL_DAY};
|
|
5
21
|
border-radius: 0.25rem;
|
|
@@ -11,8 +27,10 @@ const SelectDropdown = styled_components.div`
|
|
|
11
27
|
height: auto;
|
|
12
28
|
z-index: 3;
|
|
13
29
|
|
|
14
|
-
|
|
15
|
-
|
|
30
|
+
animation: ${({ listPosition })=>"top" === listPosition ? slideUp : slideDown}
|
|
31
|
+
0.18s ease-out;
|
|
32
|
+
top: ${({ listPosition })=>"top" === listPosition ? "auto" : "calc(100% + 0.5rem)"};
|
|
33
|
+
bottom: ${({ listPosition })=>"top" === listPosition ? "calc(100% + 0.5rem)" : "auto"};
|
|
16
34
|
|
|
17
35
|
& > div {
|
|
18
36
|
border-radius: 0.25rem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IMultiSelectOption } from "
|
|
1
|
+
import { IMultiSelectOption } from "..";
|
|
2
2
|
export declare const addOption: (selected: IMultiSelectOption[], options: IMultiSelectOption[], option: IMultiSelectOption, max?: number) => {
|
|
3
|
-
selected:
|
|
4
|
-
unselected:
|
|
3
|
+
selected: import("../../Select").ISelectOption[];
|
|
4
|
+
unselected: import("../../Select").ISelectOption[];
|
|
5
5
|
} | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IMultiSelectOption } from "
|
|
1
|
+
import { IMultiSelectOption } from "..";
|
|
2
2
|
export declare const computeUnselected: (options: IMultiSelectOption[], selected: IMultiSelectOption[]) => IMultiSelectOption[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const computeUnselected = (options, selected)=>options.filter((opt)=>!selected.some((
|
|
1
|
+
const computeUnselected = (options, selected)=>options.filter((opt)=>!selected.some((selected)=>selected.value === opt.value));
|
|
2
2
|
export { computeUnselected };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMultiSelectOption } from "
|
|
1
|
+
import { IMultiSelectOption } from "..";
|
|
2
2
|
export declare function feedbackText(translation: (key: string) => string, options: IMultiSelectOption[], filtered: IMultiSelectOption[], selected: IMultiSelectOption[], query: string, max?: number): {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|