@ftdata/ui 0.0.14 → 0.0.16
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/Collapse/styles.js +2 -0
- package/dist/components/Input/index.js +15 -11
- package/dist/components/Input/styles.d.ts +2 -1
- package/dist/components/Input/styles.js +27 -16
- package/dist/components/Menu/constants/icons.d.ts +2 -16
- package/dist/components/Menu/constants/icons.js +13 -58
- package/dist/components/Menu/helpers/createMenus.js +13 -6
- package/dist/components/Menu/helpers/createSubMenus.d.ts +1 -1
- package/dist/components/Menu/helpers/createSubMenus.js +1 -1
- package/dist/components/Menu/helpers/generateColorScale.js +2 -2
- package/dist/components/Menu/helpers/getLuminance.d.ts +1 -1
- package/dist/components/Menu/helpers/getLuminance.js +2 -2
- package/dist/components/Menu/index.d.ts +1 -1
- package/dist/components/Menu/index.js +18 -31
- package/dist/components/Menu/styles.d.ts +0 -1
- package/dist/components/Menu/styles.js +29 -45
- package/dist/components/Menu/types/IconKeysType.d.ts +1 -1
- package/dist/components/Menu/types/MenuItem.d.ts +3 -2
- package/dist/components/Select/List/index.js +0 -1
- package/dist/components/Select/index.d.ts +2 -2
- package/dist/components/Select/index.js +1 -0
- package/package.json +2 -2
- package/dist/components/Collapse/Colapse.stories.d.ts +0 -10
- package/dist/components/Collapse/Colapse.stories.js +0 -108
- package/dist/components/Menu/Menu.stories.d.ts +0 -6
- package/dist/components/Menu/Menu.stories.js +0 -116
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { Container,
|
|
4
|
-
import DoneCircleIcon from "../../assets/DoneCircleIcon.js";
|
|
5
|
-
import CancelSquareIcon from "../../assets/CancelSquareIcon.js";
|
|
3
|
+
import { Container, DivIcon, HelpText, InputContainer, InputControl, StyledLabel } from "./styles.js";
|
|
6
4
|
import { Icon } from "@ftdata/f-icons";
|
|
7
5
|
const Input = ({ disabled, error, helpText, name, success, width, icon, textField, margin, required, ...rest })=>/*#__PURE__*/ jsxs(Container, {
|
|
8
6
|
margin: margin,
|
|
9
7
|
children: [
|
|
10
|
-
textField && /*#__PURE__*/ jsxs(
|
|
8
|
+
textField && /*#__PURE__*/ jsxs(StyledLabel, {
|
|
9
|
+
htmlFor: name,
|
|
11
10
|
children: [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}),
|
|
15
|
-
required && /*#__PURE__*/ jsx("div", {
|
|
16
|
-
className: "required",
|
|
11
|
+
textField,
|
|
12
|
+
required && /*#__PURE__*/ jsx("span", {
|
|
17
13
|
children: "*"
|
|
18
14
|
})
|
|
19
15
|
]
|
|
@@ -44,8 +40,16 @@ const Input = ({ disabled, error, helpText, name, success, width, icon, textFiel
|
|
|
44
40
|
error: error,
|
|
45
41
|
success: success,
|
|
46
42
|
children: [
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
error && /*#__PURE__*/ jsx("div", {
|
|
44
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
45
|
+
name: "ui warning-circle",
|
|
46
|
+
size: "1rem",
|
|
47
|
+
color: "currentColor"
|
|
48
|
+
})
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsx("span", {
|
|
51
|
+
children: helpText
|
|
52
|
+
})
|
|
49
53
|
]
|
|
50
54
|
})
|
|
51
55
|
]
|
|
@@ -13,5 +13,6 @@ interface HelpTextProps extends React.AllHTMLAttributes<HTMLSpanElement> {
|
|
|
13
13
|
error?: boolean;
|
|
14
14
|
success?: boolean;
|
|
15
15
|
}
|
|
16
|
-
export declare const HelpText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").
|
|
16
|
+
export declare const HelpText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, HelpTextProps>> & string;
|
|
17
|
+
export declare const StyledLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;
|
|
17
18
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled_components from "styled-components";
|
|
2
|
-
import { BORDER_RADIUS_SM, COLOR_ACCENT_MEDIUM, COLOR_DANGER_MEDIUM, COLOR_NEUTRAL_DARK, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_DUSK, COLOR_NEUTRAL_LIGHT, COLOR_NEUTRAL_LIGHTER, COLOR_NEUTRAL_MEDIUM,
|
|
2
|
+
import { BORDER_RADIUS_SM, COLOR_ACCENT_MEDIUM, COLOR_DANGER_MEDIUM, COLOR_NEUTRAL_DARK, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_DUSK, COLOR_NEUTRAL_LIGHT, COLOR_NEUTRAL_LIGHTER, COLOR_NEUTRAL_MEDIUM, COLOR_SUCCESS_MEDIUM, FONT_FAMILY_01, FONT_SIZE_MD, FONT_SIZE_SM, FONT_WEIGHT_BOLD, FONT_WEIGHT_MEDIUM, LINE_HEIGHT_MEDIUM, SPACING_INLINE_02, SPACING_INSET_SM, SPACING_SQUISH_NANO, SPACING_STACK_02 } from "@ftdata/f-tokens";
|
|
3
3
|
import { Component } from "react";
|
|
4
4
|
const ContainerTextField = styled_components.div`
|
|
5
5
|
display: flex;
|
|
@@ -75,22 +75,33 @@ const InputControl = styled_components.input`
|
|
|
75
75
|
color: ${({ disabled })=>disabled ? COLOR_NEUTRAL_LIGHT : COLOR_NEUTRAL_MEDIUM};
|
|
76
76
|
}
|
|
77
77
|
`;
|
|
78
|
-
const HelpText = styled_components
|
|
79
|
-
|
|
80
|
-
box-sizing: border-box;
|
|
81
|
-
color: ${({ disabled, error, success })=>disabled && COLOR_NEUTRAL_MEDIUM || error && COLOR_DANGER_MEDIUM || success && COLOR_SUCCESS_DARK || COLOR_NEUTRAL_DARK};
|
|
78
|
+
const HelpText = styled_components.div`
|
|
79
|
+
color: ${({ error, success })=>error ? COLOR_DANGER_MEDIUM : success ? COLOR_SUCCESS_MEDIUM : COLOR_NEUTRAL_DARK};
|
|
82
80
|
display: flex;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
line-height: ${LINE_HEIGHT_MEDIUM};
|
|
86
|
-
font-size: ${FONT_SIZE_XS};
|
|
87
|
-
margin-top: 8px;
|
|
81
|
+
gap: 0.25rem;
|
|
82
|
+
margin-top: 0.5rem;
|
|
88
83
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
div {
|
|
85
|
+
height: 1rem;
|
|
86
|
+
width: 1rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
span {
|
|
90
|
+
font-size: 0.875rem;
|
|
91
|
+
line-height: 1rem;
|
|
92
|
+
font-weight: ${FONT_WEIGHT_MEDIUM};
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
const StyledLabel = styled_components.label`
|
|
96
|
+
color: ${COLOR_NEUTRAL_DUSK};
|
|
97
|
+
display: flex;
|
|
98
|
+
font-size: 0.875rem;
|
|
99
|
+
font-weight: ${FONT_WEIGHT_BOLD};
|
|
100
|
+
line-height: 1rem;
|
|
101
|
+
margin-bottom: 0.5rem;
|
|
102
|
+
|
|
103
|
+
span {
|
|
104
|
+
color: ${COLOR_DANGER_MEDIUM};
|
|
94
105
|
}
|
|
95
106
|
`;
|
|
96
|
-
export { Container, ContainerTextField, DivIcon, HelpText, InputContainer, InputControl, ReactInputMask, TextField };
|
|
107
|
+
export { Container, ContainerTextField, DivIcon, HelpText, InputContainer, InputControl, ReactInputMask, StyledLabel, TextField };
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
registration: import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
logistics: import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
reports: import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
driver_behavior: import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
settings: import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
f_analytics: import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
f_speed: import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
title_module_playback_f_view: import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
message: import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
maps: import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
changelog: import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
dashboard: import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
mosaic: import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
};
|
|
1
|
+
import { IconsNames } from "@ftdata/f-icons";
|
|
2
|
+
export declare const ICONS: Record<string, IconsNames>;
|
|
17
3
|
export type IconsKeys = keyof typeof ICONS;
|
|
@@ -1,61 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Icon } from "@ftdata/f-icons";
|
|
1
|
+
import "react";
|
|
3
2
|
const ICONS = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
reports: /*#__PURE__*/ jsx(Icon, {
|
|
17
|
-
name: "bp chart-19",
|
|
18
|
-
color: "currentColor"
|
|
19
|
-
}),
|
|
20
|
-
driver_behavior: /*#__PURE__*/ jsx(Icon, {
|
|
21
|
-
name: "nav direction-arrow-road",
|
|
22
|
-
color: "currentColor"
|
|
23
|
-
}),
|
|
24
|
-
settings: /*#__PURE__*/ jsx(Icon, {
|
|
25
|
-
name: "ui settings",
|
|
26
|
-
color: "currentColor"
|
|
27
|
-
}),
|
|
28
|
-
f_analytics: /*#__PURE__*/ jsx(Icon, {
|
|
29
|
-
name: "sm google-analytics",
|
|
30
|
-
color: "currentColor"
|
|
31
|
-
}),
|
|
32
|
-
f_speed: /*#__PURE__*/ jsx(Icon, {
|
|
33
|
-
name: "cs speedometer",
|
|
34
|
-
color: "currentColor"
|
|
35
|
-
}),
|
|
36
|
-
title_module_playback_f_view: /*#__PURE__*/ jsx(Icon, {
|
|
37
|
-
name: "ui video-camera",
|
|
38
|
-
color: "currentColor"
|
|
39
|
-
}),
|
|
40
|
-
message: /*#__PURE__*/ jsx(Icon, {
|
|
41
|
-
name: "eml emails-letter-mail-2",
|
|
42
|
-
color: "currentColor"
|
|
43
|
-
}),
|
|
44
|
-
maps: /*#__PURE__*/ jsx(Icon, {
|
|
45
|
-
name: "nav earth-home-world",
|
|
46
|
-
color: "currentColor"
|
|
47
|
-
}),
|
|
48
|
-
changelog: /*#__PURE__*/ jsx(Icon, {
|
|
49
|
-
name: "ui info-information",
|
|
50
|
-
color: "currentColor"
|
|
51
|
-
}),
|
|
52
|
-
dashboard: /*#__PURE__*/ jsx(Icon, {
|
|
53
|
-
name: "ui dashboard-minimal",
|
|
54
|
-
color: "currentColor"
|
|
55
|
-
}),
|
|
56
|
-
mosaic: /*#__PURE__*/ jsx(Icon, {
|
|
57
|
-
name: "ui grid-layout-add",
|
|
58
|
-
color: "currentColor"
|
|
59
|
-
})
|
|
3
|
+
"fa-building-o": "ui briefcase",
|
|
4
|
+
"fa-edit": "ui plus-add",
|
|
5
|
+
"fa-connectdevelop": "nav arrow-location-direction-1",
|
|
6
|
+
"fa-list-ol": "bp chart-19",
|
|
7
|
+
"fa-road": "nav direction-arrow-road",
|
|
8
|
+
"fa-cogs": "ui settings",
|
|
9
|
+
"fa-bar-chart": "sm google-analytics",
|
|
10
|
+
"fa-gauge": "cs speedometer",
|
|
11
|
+
"fa-camera": "ui video-camera",
|
|
12
|
+
"fa-globe": "nav earth-home-world",
|
|
13
|
+
"fa-truck": "nmk truck",
|
|
14
|
+
"fa-dashboard": "ui dashboard-minimal"
|
|
60
15
|
};
|
|
61
16
|
export { ICONS };
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Icon } from "@ftdata/f-icons";
|
|
2
4
|
import { createSubMenus } from "./createSubMenus.js";
|
|
5
|
+
import { ICONS } from "../constants/icons.js";
|
|
3
6
|
function createMenuItems(data, translate) {
|
|
4
|
-
return data.sort((a, b)=>a.ordenation - b.ordenation).
|
|
5
|
-
const icon =
|
|
7
|
+
return data.sort((a, b)=>a.ordenation - b.ordenation).map((item)=>{
|
|
8
|
+
const icon = /*#__PURE__*/ jsx(Icon, {
|
|
9
|
+
name: ICONS[item.menu_icon.trim()] || "ui plus-add",
|
|
10
|
+
color: "currentColor"
|
|
11
|
+
});
|
|
6
12
|
const subItems = item.itens.sort((a, b)=>a.ordenation - b.ordenation);
|
|
7
13
|
return {
|
|
8
|
-
|
|
9
|
-
icon,
|
|
14
|
+
id: item.id,
|
|
10
15
|
callback: ()=>{
|
|
11
16
|
if (item.endpoint) {
|
|
12
17
|
const url = new URL(item.endpoint, window.location.origin).toString();
|
|
13
18
|
window.open(url, "_blank");
|
|
14
19
|
}
|
|
15
20
|
},
|
|
16
|
-
submenus: createSubMenus(subItems, translate)
|
|
21
|
+
submenus: createSubMenus(subItems, translate),
|
|
22
|
+
icon,
|
|
23
|
+
label: translate(item.translate_key)
|
|
17
24
|
};
|
|
18
25
|
});
|
|
19
26
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MenuItemData, SubMenuData } from
|
|
1
|
+
import { MenuItemData, SubMenuData } from '../types/MenuItem';
|
|
2
2
|
export declare function createSubMenus(data: MenuItemData[], translate: (key: string) => string): SubMenuData[];
|
|
@@ -23,7 +23,7 @@ function generateColorScale(hex) {
|
|
|
23
23
|
950
|
|
24
24
|
];
|
|
25
25
|
const toRgb = (hex)=>{
|
|
26
|
-
const clean = hex.replace(
|
|
26
|
+
const clean = hex.replace('#', '');
|
|
27
27
|
const bigint = parseInt(clean, 16);
|
|
28
28
|
return {
|
|
29
29
|
r: bigint >> 16 & 255,
|
|
@@ -35,7 +35,7 @@ function generateColorScale(hex) {
|
|
|
35
35
|
r,
|
|
36
36
|
g,
|
|
37
37
|
b
|
|
38
|
-
].map((c)=>Math.round(c).toString(16).padStart(2,
|
|
38
|
+
].map((c)=>Math.round(c).toString(16).padStart(2, '0')).join('')}`;
|
|
39
39
|
const mix = (c1, c2, amount)=>c1 + (c2 - c1) * amount;
|
|
40
40
|
const { r: baseR, g: baseG, b: baseB } = toRgb(hex);
|
|
41
41
|
const lighten = (amount)=>({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getLuminance(hex: string):
|
|
1
|
+
export declare function getLuminance(hex: string): 'dark' | 'light';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
function getLuminance(hex) {
|
|
2
|
-
const sanitizedHex = hex.replace(
|
|
2
|
+
const sanitizedHex = hex.replace('#', '');
|
|
3
3
|
const r = parseInt(sanitizedHex.substring(0, 2), 16);
|
|
4
4
|
const g = parseInt(sanitizedHex.substring(2, 4), 16);
|
|
5
5
|
const b = parseInt(sanitizedHex.substring(4, 6), 16);
|
|
6
6
|
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
7
|
-
return luminance < 0.5 ?
|
|
7
|
+
return luminance < 0.5 ? 'dark' : 'light';
|
|
8
8
|
}
|
|
9
9
|
export { getLuminance };
|
|
@@ -9,5 +9,5 @@ interface MenuProps {
|
|
|
9
9
|
translate: (key: string) => string;
|
|
10
10
|
active?: string;
|
|
11
11
|
}
|
|
12
|
-
export default function Menu({ background, fontcolor, subMenusBackground, logo, items, translate, active, }: MenuProps):
|
|
12
|
+
export default function Menu({ background, fontcolor, subMenusBackground, logo, items, translate, active, }: MenuProps): JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -7,22 +7,14 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
7
7
|
const [expand, setExpand] = useState(false);
|
|
8
8
|
const [submenus, setSubmenus] = useState([]);
|
|
9
9
|
const [isClosingSubmenu, setIsClosingSubmenu] = useState(false);
|
|
10
|
-
const [menuAnimating, setMenuAnimating] = useState(false);
|
|
11
10
|
const menuRef = useRef(null);
|
|
12
11
|
const menus = createMenus(items, translate);
|
|
13
12
|
const toggleMenu = ()=>{
|
|
14
|
-
if (expand) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
setExpand(false);
|
|
19
|
-
setMenuAnimating(false);
|
|
20
|
-
}, 120);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
13
|
+
if (expand) return void setTimeout(()=>{
|
|
14
|
+
setSubmenus([]);
|
|
15
|
+
setExpand(false);
|
|
16
|
+
}, 120);
|
|
23
17
|
setExpand(true);
|
|
24
|
-
setMenuAnimating(true);
|
|
25
|
-
setTimeout(()=>setMenuAnimating(false), 120);
|
|
26
18
|
};
|
|
27
19
|
const handleClickItem = (event, submenus, callback)=>{
|
|
28
20
|
event.stopPropagation();
|
|
@@ -34,10 +26,6 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
34
26
|
event.stopPropagation();
|
|
35
27
|
toggleMenu();
|
|
36
28
|
};
|
|
37
|
-
const handleClickAside = (event)=>{
|
|
38
|
-
if (!expand) return void toggleMenu();
|
|
39
|
-
if (event.target === event.currentTarget) toggleMenu();
|
|
40
|
-
};
|
|
41
29
|
const handleClickBack = ()=>{
|
|
42
30
|
setIsClosingSubmenu(true);
|
|
43
31
|
setTimeout(()=>{
|
|
@@ -62,7 +50,7 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
62
50
|
return /*#__PURE__*/ jsxs(MenuAside, {
|
|
63
51
|
ref: menuRef,
|
|
64
52
|
background: background,
|
|
65
|
-
onClick:
|
|
53
|
+
onClick: expand ? ()=>null : toggleMenu,
|
|
66
54
|
$expand: expand,
|
|
67
55
|
children: [
|
|
68
56
|
/*#__PURE__*/ jsxs(MenuHeader, {
|
|
@@ -71,12 +59,12 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
71
59
|
onClick: handleClickHamburger,
|
|
72
60
|
fontcolor: fontcolor,
|
|
73
61
|
$expand: expand,
|
|
74
|
-
$animating: menuAnimating,
|
|
75
62
|
children: [
|
|
76
63
|
/*#__PURE__*/ jsx("div", {
|
|
77
64
|
children: /*#__PURE__*/ jsx(Icon, {
|
|
78
65
|
name: "ui menu-burger-square",
|
|
79
|
-
width: "1.5rem"
|
|
66
|
+
width: "1.5rem",
|
|
67
|
+
color: "currentColor"
|
|
80
68
|
})
|
|
81
69
|
}),
|
|
82
70
|
/*#__PURE__*/ jsx("span", {
|
|
@@ -96,7 +84,6 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
96
84
|
onClick: (event)=>handleClickItem(event, menu.submenus, menu.callback),
|
|
97
85
|
$expand: expand || void 0,
|
|
98
86
|
$active: menu.label === translate(active || ""),
|
|
99
|
-
$animating: menuAnimating,
|
|
100
87
|
children: [
|
|
101
88
|
/*#__PURE__*/ jsx("div", {
|
|
102
89
|
children: menu.icon
|
|
@@ -111,24 +98,24 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
111
98
|
$isClosing: isClosingSubmenu || void 0,
|
|
112
99
|
background: subMenusBackground,
|
|
113
100
|
children: [
|
|
114
|
-
/*#__PURE__*/
|
|
101
|
+
/*#__PURE__*/ jsx(SubItemsHeader, {
|
|
115
102
|
fontcolor: fontcolor,
|
|
116
|
-
children:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
name: "arw arrow-left"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
children: /*#__PURE__*/ jsxs("button", {
|
|
104
|
+
onClick: handleClickBack,
|
|
105
|
+
children: [
|
|
106
|
+
/*#__PURE__*/ jsx(Icon, {
|
|
107
|
+
name: "arw arrow-left",
|
|
108
|
+
color: "currentColor"
|
|
109
|
+
}),
|
|
110
|
+
translate("back")
|
|
111
|
+
]
|
|
112
|
+
})
|
|
125
113
|
}),
|
|
126
114
|
/*#__PURE__*/ jsx(SubItemsWrapper, {
|
|
127
115
|
background: subMenusBackground,
|
|
128
116
|
children: submenus.map((submenu, idx)=>/*#__PURE__*/ jsx(SubMenuItem, {
|
|
129
117
|
fontcolor: fontcolor,
|
|
130
118
|
onClick: (event)=>handleClickItem(event, [], submenu.callback),
|
|
131
|
-
$animating: menuAnimating,
|
|
132
119
|
children: submenu.label
|
|
133
120
|
}, `${submenu.label}-${idx}`))
|
|
134
121
|
})
|
|
@@ -4,7 +4,6 @@ interface ICommonProps {
|
|
|
4
4
|
$active?: boolean;
|
|
5
5
|
$expand?: boolean;
|
|
6
6
|
$isClosing?: boolean;
|
|
7
|
-
$animating?: boolean;
|
|
8
7
|
}
|
|
9
8
|
export declare const MenuAside: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, ICommonProps>> & string;
|
|
10
9
|
export declare const MenuHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ICommonProps>> & string;
|
|
@@ -1,6 +1,26 @@
|
|
|
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
|
+
`;
|
|
4
24
|
const fadeOutAndHide = keyframes`
|
|
5
25
|
0% {
|
|
6
26
|
opacity: 1;
|
|
@@ -33,26 +53,6 @@ const fadeInAndShow = keyframes`
|
|
|
33
53
|
display: flex;
|
|
34
54
|
}
|
|
35
55
|
`;
|
|
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,7 +78,6 @@ 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;
|
|
82
81
|
animation: ${({ $expand })=>$expand ? fadeInAndShow : fadeOutAndHide}
|
|
83
82
|
0.25s forwards;
|
|
84
83
|
|
|
@@ -87,7 +86,7 @@ const ContainerLogo = styled_components.div`
|
|
|
87
86
|
align-items: center;
|
|
88
87
|
display: flex;
|
|
89
88
|
justify-content: center;
|
|
90
|
-
max-height:
|
|
89
|
+
max-height: 8.875rem;
|
|
91
90
|
max-width: 100%;
|
|
92
91
|
}
|
|
93
92
|
`;
|
|
@@ -125,40 +124,33 @@ const ItemMenu = styled_components.div`
|
|
|
125
124
|
transition:
|
|
126
125
|
opacity 0.4s ease,
|
|
127
126
|
transform 0.4s ease;
|
|
128
|
-
white-space: ${({ $expand
|
|
127
|
+
white-space: ${({ $expand })=>$expand ? "wrap" : "nowrap"};
|
|
129
128
|
overflow: hidden;
|
|
130
|
-
|
|
129
|
+
|
|
131
130
|
&:hover {
|
|
132
131
|
opacity: 1;
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
`;
|
|
136
135
|
const SubItemsContainer = styled_components.div`
|
|
137
|
-
animation: ${({ $isClosing })=>$isClosing ?
|
|
138
|
-
0.
|
|
136
|
+
animation: ${({ $isClosing })=>$isClosing ? shrinkToRight : growFromRight}
|
|
137
|
+
0.4s ease forwards;
|
|
139
138
|
background-color: ${({ background })=>generateColorScale(background || "#000000")[500]};
|
|
140
139
|
box-sizing: border-box;
|
|
141
140
|
display: flex;
|
|
142
141
|
flex-direction: column;
|
|
143
142
|
gap: 0.5rem;
|
|
144
143
|
height: 100%;
|
|
145
|
-
padding:
|
|
144
|
+
padding: 1rem 0 0 1rem;
|
|
146
145
|
position: absolute;
|
|
147
146
|
right: 0;
|
|
148
147
|
top: 0;
|
|
149
148
|
transform-origin: right;
|
|
150
149
|
width: 15.25rem;
|
|
151
150
|
z-index: 1;
|
|
152
|
-
overflow: hidden;
|
|
153
151
|
`;
|
|
154
152
|
const SubItemsHeader = styled_components.div`
|
|
155
153
|
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;
|
|
162
154
|
|
|
163
155
|
button {
|
|
164
156
|
align-items: center;
|
|
@@ -167,18 +159,13 @@ const SubItemsHeader = styled_components.div`
|
|
|
167
159
|
color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
|
|
168
160
|
cursor: pointer;
|
|
169
161
|
display: flex;
|
|
162
|
+
font-size: 1rem;
|
|
163
|
+
font-weight: 500;
|
|
170
164
|
gap: 0.5rem;
|
|
171
165
|
line-height: 1rem;
|
|
172
166
|
margin: 0;
|
|
173
|
-
border-radius: 50%;
|
|
174
167
|
padding: 0;
|
|
175
|
-
transition:
|
|
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
|
-
}
|
|
168
|
+
transition: opacity 0.2s ease;
|
|
182
169
|
}
|
|
183
170
|
`;
|
|
184
171
|
const SubItemsWrapper = styled_components.div`
|
|
@@ -207,9 +194,6 @@ const SubMenuItem = styled_components.span`
|
|
|
207
194
|
opacity: ${({ $active })=>$active ? "1" : "0.68"};
|
|
208
195
|
padding: 0.5rem 0.75rem;
|
|
209
196
|
transition: background-color 0.2s ease;
|
|
210
|
-
white-space: ${({ $expand, $animating })=>$expand && !$animating ? "normal" : "nowrap"};
|
|
211
|
-
overflow: hidden;
|
|
212
|
-
text-overflow: ellipsis;
|
|
213
197
|
|
|
214
198
|
&:hover {
|
|
215
199
|
opacity: 1;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICONS } from
|
|
1
|
+
import { ICONS } from '../constants/icons';
|
|
2
2
|
export type IconsKeysType = keyof typeof ICONS;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JSX } from
|
|
2
|
-
import { IconsKeysType } from
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { IconsKeysType } from './IconKeysType';
|
|
3
3
|
export type SubMenuData = {
|
|
4
4
|
callback: () => void;
|
|
5
5
|
label: string;
|
|
@@ -19,6 +19,7 @@ export type MenuItemData = {
|
|
|
19
19
|
ordenation: number;
|
|
20
20
|
};
|
|
21
21
|
export type MenuItem = {
|
|
22
|
+
id: number;
|
|
22
23
|
callback: () => void;
|
|
23
24
|
submenus: SubMenu[];
|
|
24
25
|
icon: JSX.Element;
|
|
@@ -13,7 +13,6 @@ const SelectList = ({ options, onClickOption, selectedOption, isLoading, onLoadM
|
|
|
13
13
|
const height = OPTION_SIZE * (0 === optionLength ? 1 : optionLength >= 7 ? 7 : optionLength);
|
|
14
14
|
const onItemsRendered = useCallback(async ({ stopIndex })=>{
|
|
15
15
|
const isAtEnd = stopIndex >= options.length - 1;
|
|
16
|
-
console.log(lastIndex, stopIndex, isAtEnd);
|
|
17
16
|
if (loadingMore) return;
|
|
18
17
|
try {
|
|
19
18
|
setLoadingMore(true);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { InputHTMLAttributes, JSX } from "react";
|
|
2
2
|
export interface ISelectOption {
|
|
3
3
|
label: string;
|
|
4
4
|
value: string;
|
|
@@ -25,7 +25,7 @@ export interface SelectProps extends InputPropsWithoutOnToggle {
|
|
|
25
25
|
icon?: JSX.Element;
|
|
26
26
|
variation?: "default" | "searchable";
|
|
27
27
|
selected: ISelectOption | null;
|
|
28
|
-
setSelected:
|
|
28
|
+
setSelected: (selected: ISelectOption | null) => void;
|
|
29
29
|
onLoadMore?: () => Promise<void>;
|
|
30
30
|
onToggle?: (open: boolean) => void;
|
|
31
31
|
dropdownPosition?: "top" | "bottom";
|
|
@@ -153,6 +153,7 @@ function Select({ helpText, isError, isSuccess, label, name, isRequired, options
|
|
|
153
153
|
onClick: handleClickCavet,
|
|
154
154
|
isListOpen: showList,
|
|
155
155
|
ref: cavetRef,
|
|
156
|
+
type: "button",
|
|
156
157
|
children: /*#__PURE__*/ jsx(Icon, {
|
|
157
158
|
name: "arw caret-down",
|
|
158
159
|
color: "currentColor",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ftdata/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"react-input-mask-next": "3.0.0-alpha.12",
|
|
32
32
|
"react-select": "^5.10.2",
|
|
33
33
|
"react-window": "^2.0.2",
|
|
34
|
-
"@ftdata/f-icons": "0.0.
|
|
34
|
+
"@ftdata/f-icons": "0.0.4",
|
|
35
35
|
"@ftdata/f-tokens": "0.0.1"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import Collapse from ".";
|
|
3
|
-
/**
|
|
4
|
-
* Collapses são usados para permitir que usuários ocultem ou mostrem o conteúdo dinamicamente.
|
|
5
|
-
* Usado normalmente para economizar espaço e manter a ui concisa.
|
|
6
|
-
*/
|
|
7
|
-
declare const meta: Meta<typeof Collapse>;
|
|
8
|
-
export default meta;
|
|
9
|
-
type Story = StoryObj<typeof meta>;
|
|
10
|
-
export declare const Default: Story;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import index from "./index.js";
|
|
3
|
-
import { COLOR_CUSTOM_COLUMNBG } from "@ftdata/f-tokens";
|
|
4
|
-
import { Paragraph } from "../Text/index.js";
|
|
5
|
-
const Element = /*#__PURE__*/ jsx("div", {
|
|
6
|
-
style: {
|
|
7
|
-
backgroundColor: "#FF5656",
|
|
8
|
-
fontFamily: "sans-serif",
|
|
9
|
-
border: "none",
|
|
10
|
-
borderRadius: "10px",
|
|
11
|
-
height: "10rem",
|
|
12
|
-
color: "#f5f5f5",
|
|
13
|
-
fontWeight: "800",
|
|
14
|
-
display: "flex",
|
|
15
|
-
alignItems: "center",
|
|
16
|
-
justifyContent: "center",
|
|
17
|
-
marginTop: "1rem"
|
|
18
|
-
},
|
|
19
|
-
children: "Elemento"
|
|
20
|
-
});
|
|
21
|
-
const defaultExample = /*#__PURE__*/ jsx(Paragraph, {
|
|
22
|
-
size: "sm",
|
|
23
|
-
children: "Este \xe9 o conte\xfado exibido dentro do Collapse."
|
|
24
|
-
});
|
|
25
|
-
const firstExample = /*#__PURE__*/ jsxs("div", {
|
|
26
|
-
children: [
|
|
27
|
-
Element,
|
|
28
|
-
Element
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
const meta = {
|
|
32
|
-
title: "DESIGN COMPONENTS/Collapse",
|
|
33
|
-
component: index,
|
|
34
|
-
tags: [
|
|
35
|
-
"autodocs"
|
|
36
|
-
],
|
|
37
|
-
parameters: {
|
|
38
|
-
layout: "centered"
|
|
39
|
-
},
|
|
40
|
-
decorators: [
|
|
41
|
-
(Story)=>/*#__PURE__*/ jsx("div", {
|
|
42
|
-
style: {
|
|
43
|
-
width: "300px"
|
|
44
|
-
},
|
|
45
|
-
children: /*#__PURE__*/ jsx(Story, {})
|
|
46
|
-
})
|
|
47
|
-
],
|
|
48
|
-
argTypes: {
|
|
49
|
-
title: {
|
|
50
|
-
description: "Define o t\xedtulo do Collpase.",
|
|
51
|
-
table: {
|
|
52
|
-
type: {
|
|
53
|
-
summary: "string | JSX.Element"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
showCollapse: {
|
|
58
|
-
description: "Define se o Collapse est\xe1 aberto ou fechado."
|
|
59
|
-
},
|
|
60
|
-
margin: {
|
|
61
|
-
description: "Define a margem do Collapse."
|
|
62
|
-
},
|
|
63
|
-
iconColor: {
|
|
64
|
-
description: "Define a cor do icone do Collapse."
|
|
65
|
-
},
|
|
66
|
-
iconCavet: {
|
|
67
|
-
description: "Define a posi\xe7\xe3o do \xedcone do Collapse."
|
|
68
|
-
},
|
|
69
|
-
children: {
|
|
70
|
-
control: {
|
|
71
|
-
type: "select"
|
|
72
|
-
},
|
|
73
|
-
description: "Recebe o que ser\xe1 exibido dentro do Collapse.",
|
|
74
|
-
mapping: {
|
|
75
|
-
"Default Example": defaultExample,
|
|
76
|
-
"First Example": firstExample
|
|
77
|
-
},
|
|
78
|
-
options: [
|
|
79
|
-
"Deafault Example",
|
|
80
|
-
"First Example"
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
handleChange: {
|
|
84
|
-
description: "Recebe uma fun\xe7\xe3o respons\xe1vel em lidar com as altera\xe7\xf5es da visibilidade do Collapse."
|
|
85
|
-
},
|
|
86
|
-
fontSyze: {
|
|
87
|
-
description: "Define o tamanho da fonte do Collapse."
|
|
88
|
-
},
|
|
89
|
-
maxHeight: {
|
|
90
|
-
description: "Define o tamanho m\xe1ximo do children do Collapse."
|
|
91
|
-
},
|
|
92
|
-
espacamentoTitleIcon: {
|
|
93
|
-
description: "Define o espa\xe7amento entre o titulo e o \xedcone"
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const Colapse_stories = meta;
|
|
98
|
-
const Default = {
|
|
99
|
-
args: {
|
|
100
|
-
title: "Collapse",
|
|
101
|
-
showCollapse: false,
|
|
102
|
-
margin: "0",
|
|
103
|
-
iconColor: COLOR_CUSTOM_COLUMNBG,
|
|
104
|
-
iconCavet: "left",
|
|
105
|
-
children: defaultExample
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
export { Default, Colapse_stories as default };
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import index from "./index.js";
|
|
3
|
-
import { Icon } from "@ftdata/f-icons";
|
|
4
|
-
const meta = {
|
|
5
|
-
title: "Components/Menu",
|
|
6
|
-
component: index,
|
|
7
|
-
argTypes: {
|
|
8
|
-
background: {
|
|
9
|
-
control: "color"
|
|
10
|
-
},
|
|
11
|
-
fontcolor: {
|
|
12
|
-
control: "color"
|
|
13
|
-
},
|
|
14
|
-
subMenusBackground: {
|
|
15
|
-
control: "color"
|
|
16
|
-
},
|
|
17
|
-
active: {
|
|
18
|
-
control: "text"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const Menu_stories = meta;
|
|
23
|
-
const mockLogo = /*#__PURE__*/ jsx(Icon, {
|
|
24
|
-
name: "ui airplay-signal",
|
|
25
|
-
width: "2rem"
|
|
26
|
-
});
|
|
27
|
-
const mockItems = [
|
|
28
|
-
{
|
|
29
|
-
id: 1,
|
|
30
|
-
description: "Dashboard principal",
|
|
31
|
-
endpoint: "/dashboard",
|
|
32
|
-
itens: [
|
|
33
|
-
{
|
|
34
|
-
id: 11,
|
|
35
|
-
description: "Relat\xf3rios",
|
|
36
|
-
endpoint: "/dashboard/reports",
|
|
37
|
-
itens: [
|
|
38
|
-
{
|
|
39
|
-
id: 12,
|
|
40
|
-
description: "Estat\xedsticas",
|
|
41
|
-
endpoint: "/dashboard/statistics",
|
|
42
|
-
itens: [],
|
|
43
|
-
menu_icon: "ui statistics",
|
|
44
|
-
translate_key: "changelog",
|
|
45
|
-
ordenation: 2
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: 12,
|
|
49
|
-
description: "Estat\xedsticas",
|
|
50
|
-
endpoint: "/dashboard/statistics",
|
|
51
|
-
itens: [],
|
|
52
|
-
menu_icon: "ui statistics",
|
|
53
|
-
translate_key: "changelog",
|
|
54
|
-
ordenation: 2
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 12,
|
|
58
|
-
description: "Estat\xedsticas",
|
|
59
|
-
endpoint: "/dashboard/statistics",
|
|
60
|
-
itens: [],
|
|
61
|
-
menu_icon: "ui statistics",
|
|
62
|
-
translate_key: "changelog",
|
|
63
|
-
ordenation: 2
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
menu_icon: "ui report",
|
|
67
|
-
translate_key: "reports",
|
|
68
|
-
ordenation: 1
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
id: 12,
|
|
72
|
-
description: "Estat\xedsticas",
|
|
73
|
-
endpoint: "/dashboard/statistics",
|
|
74
|
-
itens: [],
|
|
75
|
-
menu_icon: "ui statistics",
|
|
76
|
-
translate_key: "changelog",
|
|
77
|
-
ordenation: 2
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
menu_icon: "ui dashboard",
|
|
81
|
-
translate_key: "dashboard",
|
|
82
|
-
ordenation: 1
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: 2,
|
|
86
|
-
description: "Configura\xe7\xf5es do sistema",
|
|
87
|
-
endpoint: "/settings",
|
|
88
|
-
itens: [],
|
|
89
|
-
menu_icon: "ui settings",
|
|
90
|
-
translate_key: "settings",
|
|
91
|
-
ordenation: 2
|
|
92
|
-
}
|
|
93
|
-
];
|
|
94
|
-
const mockTranslate = (key)=>{
|
|
95
|
-
const dict = {
|
|
96
|
-
menu: "Menu",
|
|
97
|
-
dashboard: "Dashboard",
|
|
98
|
-
settings: "Configura\xe7\xf5es",
|
|
99
|
-
back: "Voltar",
|
|
100
|
-
reports: "Relat\xf3rios",
|
|
101
|
-
statistics: "Estat\xedsticas"
|
|
102
|
-
};
|
|
103
|
-
return dict[key] || key;
|
|
104
|
-
};
|
|
105
|
-
const Default = {
|
|
106
|
-
args: {
|
|
107
|
-
background: "#222",
|
|
108
|
-
fontcolor: "#fff",
|
|
109
|
-
subMenusBackground: "#333",
|
|
110
|
-
logo: mockLogo,
|
|
111
|
-
items: mockItems,
|
|
112
|
-
translate: mockTranslate,
|
|
113
|
-
active: "dashboard"
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
export { Default, Menu_stories as default };
|