@infomaximum/ui-kit 0.10.2 → 0.11.1
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/Avatar/Avatar.types.d.ts +2 -1
- package/dist/components/Avatar/Avatar.utils.d.ts +1 -0
- package/dist/components/Avatar/Avatar.utils.js +4 -0
- package/dist/components/Avatar/index.d.ts +2 -1
- package/dist/components/Dropdown/Dropdown.js +1 -0
- package/dist/components/Dropdown/Dropdown.types.d.ts +0 -1
- package/dist/components/Dropdown/Dropdown.utils.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.utils.js +1 -2
- package/dist/components/Dropdown/components/Group/Group.js +5 -7
- package/dist/components/Dropdown/components/Menu/Menu.js +4 -6
- package/dist/components/Dropdown/hooks/useSelectedKeysController.d.ts +2 -1
- package/dist/components/Dropdown/hooks/useSelectedKeysController.js +2 -1
- package/dist/components/InternalPicker/pickers/RangePicker/RangePicker.js +2 -2
- package/dist/components/InternalPicker/pickers/SinglePicker/SinglePicker.js +2 -2
- package/dist/components/InternalPicker/pickers/SinglePicker/SinglePicker.utils.d.ts +1 -0
- package/dist/components/InternalPicker/pickers/SinglePicker/SinglePicker.utils.js +3 -1
- package/dist/components/Tabs/Tabs.d.ts +3 -0
- package/dist/components/Tabs/Tabs.js +60 -0
- package/dist/components/Tabs/Tabs.styles.d.ts +6 -0
- package/dist/components/Tabs/Tabs.styles.js +9 -0
- package/dist/components/Tabs/Tabs.tokens.d.ts +14 -0
- package/dist/components/Tabs/Tabs.tokens.js +15 -0
- package/dist/components/Tabs/Tabs.types.d.ts +28 -0
- package/dist/components/Tabs/components/TabBar/TabBar.d.ts +3 -0
- package/dist/components/Tabs/components/TabBar/TabBar.js +88 -0
- package/dist/components/Tabs/components/TabBar/TabBar.styles.d.ts +46 -0
- package/dist/components/Tabs/components/TabBar/TabBar.styles.js +70 -0
- package/dist/components/Tabs/components/TabBar/TabBar.types.d.ts +14 -0
- package/dist/components/Tabs/components/TabItem/TabItem.d.ts +3 -0
- package/dist/components/Tabs/components/TabItem/TabItem.js +94 -0
- package/dist/components/Tabs/components/TabItem/TabItem.styles.d.ts +42 -0
- package/dist/components/Tabs/components/TabItem/TabItem.styles.js +69 -0
- package/dist/components/Tabs/components/TabItem/TabItem.types.d.ts +32 -0
- package/dist/components/Tabs/forStories/items.d.ts +50 -0
- package/dist/components/Tabs/hooks/useMoreTabsController.d.ts +17 -0
- package/dist/components/Tabs/hooks/useMoreTabsController.js +68 -0
- package/dist/components/Tabs/hooks/useTabsDndController.d.ts +10 -0
- package/dist/components/Tabs/hooks/useTabsDndController.js +36 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -0
- package/package.json +10 -3
- package/dist/docComponents/Demonstration/Demonstration.d.ts +0 -4
- package/dist/docComponents/Demonstration/Demonstration.styles.d.ts +0 -9
- package/dist/docComponents/Demonstration/Demonstration.types.d.ts +0 -5
- package/dist/docComponents/Description/Description.d.ts +0 -5
- package/dist/docComponents/Description/Description.style.d.ts +0 -26
- package/dist/docComponents/Doc/Doc.d.ts +0 -4
- package/dist/docComponents/Doc/Doc.style.d.ts +0 -13
- package/dist/docComponents/Example/Example.d.ts +0 -4
- package/dist/docComponents/Example/Example.styles.d.ts +0 -9
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useState, useRef, useCallback, useMemo } from "react";
|
|
2
|
+
import { isMenuItem } from "../../Dropdown/Dropdown.types.js";
|
|
3
|
+
const useMoreTabsController = (items, currentActiveKey, currentTabElement, onTabClick, onChange, changeActiveKey) => {
|
|
4
|
+
const [hiddenTabs, setHiddenTabs] = useState([]);
|
|
5
|
+
const tabsRef = useRef(null);
|
|
6
|
+
const addHiddenTab = useCallback((itemKey) => {
|
|
7
|
+
setHiddenTabs((prev) => [...prev, itemKey]);
|
|
8
|
+
}, []);
|
|
9
|
+
const deleteHiddenTab = useCallback((itemKey) => {
|
|
10
|
+
setHiddenTabs((prev) => prev.filter((item) => item !== itemKey));
|
|
11
|
+
}, []);
|
|
12
|
+
const dropdownItems = useMemo(() => {
|
|
13
|
+
return items.reduce((acc, item) => {
|
|
14
|
+
if (!hiddenTabs.includes(item.key)) {
|
|
15
|
+
return acc;
|
|
16
|
+
}
|
|
17
|
+
const dropdownItem = {
|
|
18
|
+
key: item.key,
|
|
19
|
+
icon: item.icon,
|
|
20
|
+
label: item.label,
|
|
21
|
+
disabled: item.disabled
|
|
22
|
+
};
|
|
23
|
+
return [...acc, dropdownItem];
|
|
24
|
+
}, []);
|
|
25
|
+
}, [hiddenTabs, items]);
|
|
26
|
+
const scrollToTab = useCallback((element) => {
|
|
27
|
+
if (tabsRef.current && element) {
|
|
28
|
+
const leftPos = element.offsetLeft + element.offsetWidth < tabsRef.current.offsetWidth ? element.offsetLeft : element.offsetLeft - tabsRef.current.offsetWidth + element.offsetWidth;
|
|
29
|
+
tabsRef.current.scrollTo({
|
|
30
|
+
left: leftPos
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
const handleDropdownItemClick = useCallback((props) => {
|
|
35
|
+
const {
|
|
36
|
+
item,
|
|
37
|
+
key,
|
|
38
|
+
e
|
|
39
|
+
} = props;
|
|
40
|
+
const selected = key === currentActiveKey;
|
|
41
|
+
onTabClick == null ? void 0 : onTabClick(key, e);
|
|
42
|
+
if (isMenuItem(item) && (item == null ? void 0 : item.disabled)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (selected) {
|
|
46
|
+
scrollToTab(currentTabElement);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
onChange == null ? void 0 : onChange(key);
|
|
50
|
+
changeActiveKey(key);
|
|
51
|
+
}, [changeActiveKey, currentActiveKey, currentTabElement, onChange, onTabClick, scrollToTab]);
|
|
52
|
+
const dropdownMenu = useMemo(() => {
|
|
53
|
+
return {
|
|
54
|
+
items: dropdownItems,
|
|
55
|
+
onClick: handleDropdownItemClick
|
|
56
|
+
};
|
|
57
|
+
}, [dropdownItems, handleDropdownItemClick]);
|
|
58
|
+
return {
|
|
59
|
+
tabsRef,
|
|
60
|
+
dropdownMenu,
|
|
61
|
+
addHiddenTab,
|
|
62
|
+
deleteHiddenTab,
|
|
63
|
+
scrollToTab
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
useMoreTabsController
|
|
68
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TabItem } from '../components/TabItem/TabItem.types';
|
|
2
|
+
import { DragEndEvent } from '@dnd-kit/core';
|
|
3
|
+
export declare const useTabsDndController: (items: TabItem[]) => {
|
|
4
|
+
tabsOrder: string[];
|
|
5
|
+
isDragging: boolean;
|
|
6
|
+
dndEvents: {
|
|
7
|
+
onDragStart: () => void;
|
|
8
|
+
onDragEnd: (e: DragEndEvent) => void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
import { arrayMove } from "@dnd-kit/sortable";
|
|
3
|
+
const useTabsDndController = (items) => {
|
|
4
|
+
const [tabsOrder, setTabsOrder] = useState(items.map((item) => item.key));
|
|
5
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
6
|
+
const handleDragStart = useCallback(() => {
|
|
7
|
+
setIsDragging(true);
|
|
8
|
+
}, []);
|
|
9
|
+
const handleDragEnd = useCallback((e) => {
|
|
10
|
+
const {
|
|
11
|
+
active,
|
|
12
|
+
over
|
|
13
|
+
} = e;
|
|
14
|
+
setIsDragging(false);
|
|
15
|
+
if (active.id === (over == null ? void 0 : over.id)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
setTabsOrder((prev) => {
|
|
19
|
+
const activeIndex = prev.findIndex((key) => key === active.id);
|
|
20
|
+
const overIndex = prev.findIndex((key) => key === (over == null ? void 0 : over.id));
|
|
21
|
+
return arrayMove(prev, activeIndex, overIndex);
|
|
22
|
+
});
|
|
23
|
+
}, []);
|
|
24
|
+
const dndEvents = {
|
|
25
|
+
onDragStart: handleDragStart,
|
|
26
|
+
onDragEnd: handleDragEnd
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
tabsOrder,
|
|
30
|
+
isDragging,
|
|
31
|
+
dndEvents
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
useTabsDndController
|
|
36
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -32,8 +32,10 @@ export { type UploadProps, Upload } from './components/Upload';
|
|
|
32
32
|
export { Dropdown } from './components/Dropdown';
|
|
33
33
|
export type { DropdownProps, DropdownMenu } from './components/Dropdown';
|
|
34
34
|
export { type ProgressProps, Progress } from './components/Progress';
|
|
35
|
-
export { Avatar } from './components/Avatar';
|
|
36
|
-
export type { AvatarProps } from './components/Avatar';
|
|
35
|
+
export { Avatar, avatarColors } from './components/Avatar';
|
|
36
|
+
export type { AvatarProps, AvatarColorType } from './components/Avatar';
|
|
37
|
+
export { Tabs } from './components/Tabs';
|
|
38
|
+
export type { TabsProps } from './components/Tabs';
|
|
37
39
|
export { Tag } from './components/Tag';
|
|
38
40
|
export type { TagProps, CheckableProps } from './components/Tag';
|
|
39
41
|
export { ConfigProvider, useConfig, type Locale } from './components/ConfigProvider';
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ import { Upload } from "./components/Upload/Upload.js";
|
|
|
21
21
|
import { Dropdown } from "./components/Dropdown/Dropdown.js";
|
|
22
22
|
import { Progress } from "./components/Progress/Progress.js";
|
|
23
23
|
import { Avatar } from "./components/Avatar/Avatar.js";
|
|
24
|
+
import { avatarColors } from "./components/Avatar/Avatar.utils.js";
|
|
25
|
+
import { Tabs } from "./components/Tabs/Tabs.js";
|
|
24
26
|
import { Tag } from "./components/Tag/Tag.js";
|
|
25
27
|
import { ConfigProvider } from "./components/ConfigProvider/ConfigProvider.js";
|
|
26
28
|
import { useConfig } from "./components/ConfigProvider/hooks/useConfig/useConfig.js";
|
|
@@ -44,11 +46,13 @@ export {
|
|
|
44
46
|
Radio,
|
|
45
47
|
Select,
|
|
46
48
|
Switch,
|
|
49
|
+
Tabs,
|
|
47
50
|
Tag,
|
|
48
51
|
ThemeProvider,
|
|
49
52
|
TimePicker,
|
|
50
53
|
Tooltip,
|
|
51
54
|
Upload,
|
|
55
|
+
avatarColors,
|
|
52
56
|
message,
|
|
53
57
|
messagesHolder,
|
|
54
58
|
themeMap,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infomaximum/ui-kit",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -34,6 +34,9 @@
|
|
|
34
34
|
"update-icons": "node scripts/updateIcons/updateIcons.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@dnd-kit/core": "^6.3.1",
|
|
38
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
39
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
37
40
|
"@emotion/react": "^11.0.0",
|
|
38
41
|
"@floating-ui/react": "^0.27.6",
|
|
39
42
|
"@infomaximum/icons": "^1.3.2",
|
|
@@ -42,13 +45,17 @@
|
|
|
42
45
|
"rc-picker": "^4.11.3",
|
|
43
46
|
"rc-util": "^5.44.4",
|
|
44
47
|
"react": "^18.3.1",
|
|
45
|
-
"react-dom": "^18.3.1"
|
|
48
|
+
"react-dom": "^18.3.1",
|
|
49
|
+
"react-intersection-observer": "^9.16.0"
|
|
46
50
|
},
|
|
47
51
|
"peerDependencies": {
|
|
48
52
|
"@emotion/react": "^11.0.0",
|
|
49
53
|
"dayjs": "^1.0.0",
|
|
50
54
|
"react": "^18",
|
|
51
|
-
"react-dom": "^18"
|
|
55
|
+
"react-dom": "^18",
|
|
56
|
+
"@dnd-kit/core": "^6",
|
|
57
|
+
"@dnd-kit/sortable": "^10",
|
|
58
|
+
"@dnd-kit/utilities": "^3"
|
|
52
59
|
},
|
|
53
60
|
"devDependencies": {
|
|
54
61
|
"@emotion/babel-plugin": "^11.13.5",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Theme } from 'themes';
|
|
2
|
-
export declare const descriptionStyle: (theme: Theme) => {
|
|
3
|
-
readonly padding: "24px 48px";
|
|
4
|
-
readonly background: "#FAFAFA";
|
|
5
|
-
readonly display: "flex";
|
|
6
|
-
readonly flexDirection: "column";
|
|
7
|
-
readonly gap: "24px";
|
|
8
|
-
readonly ".docblock-source.sb-unstyled": {
|
|
9
|
-
readonly margin: 0;
|
|
10
|
-
};
|
|
11
|
-
readonly "p, span": {
|
|
12
|
-
readonly color: "inherit";
|
|
13
|
-
readonly fontWeight: 400;
|
|
14
|
-
readonly margin: 0;
|
|
15
|
-
readonly fontFamily: "Roboto";
|
|
16
|
-
readonly fontSize: 14;
|
|
17
|
-
readonly lineHeight: "20px";
|
|
18
|
-
};
|
|
19
|
-
readonly h4: {
|
|
20
|
-
readonly color: "#262626";
|
|
21
|
-
readonly fontWeight: 500;
|
|
22
|
-
readonly fontFamily: "Roboto";
|
|
23
|
-
readonly fontSize: 16;
|
|
24
|
-
readonly lineHeight: "24px";
|
|
25
|
-
};
|
|
26
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Theme } from 'themes';
|
|
2
|
-
export declare const docStyle: (theme: Theme) => {
|
|
3
|
-
readonly ".blue": {
|
|
4
|
-
readonly color: "#1677FF";
|
|
5
|
-
};
|
|
6
|
-
readonly fontFamily: "Roboto";
|
|
7
|
-
readonly fontSize: 14;
|
|
8
|
-
readonly lineHeight: "20px";
|
|
9
|
-
readonly display: "flex";
|
|
10
|
-
readonly flexDirection: "column";
|
|
11
|
-
readonly gap: 48;
|
|
12
|
-
readonly color: "#595959";
|
|
13
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Theme } from 'themes';
|
|
2
|
-
export declare const exampleStyle: (theme: Theme) => {
|
|
3
|
-
readonly display: "flex";
|
|
4
|
-
readonly flexDirection: "column";
|
|
5
|
-
readonly borderRadius: 12;
|
|
6
|
-
readonly border: "1px solid #D9D9D9";
|
|
7
|
-
readonly background: "#FFFFFF";
|
|
8
|
-
readonly overflow: "hidden";
|
|
9
|
-
};
|