@monolith-forensics/monolith-ui 1.2.121 → 1.3.0
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/Button/Button.js +0 -1
- package/dist/Tabs/Tab.d.ts +10 -0
- package/dist/Tabs/Tab.js +69 -0
- package/dist/Tabs/Tabs.d.ts +13 -0
- package/dist/Tabs/Tabs.js +29 -0
- package/dist/Tabs/Tabs.types.d.ts +2 -0
- package/dist/Tabs/Tabs.types.js +1 -0
- package/dist/Tabs/TabsProvider.d.ts +24 -0
- package/dist/Tabs/TabsProvider.js +32 -0
- package/dist/Tabs/index.d.ts +2 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -1
package/dist/Button/Button.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export declare const Tab: React.FC<{
|
|
3
|
+
value: string | number;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
leftSection?: React.ReactNode;
|
|
9
|
+
rightSection?: React.ReactNode;
|
|
10
|
+
}>;
|
package/dist/Tabs/Tab.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled, { css } from "styled-components";
|
|
3
|
+
import Button from "../Button";
|
|
4
|
+
import { useTabs } from "./TabsProvider";
|
|
5
|
+
const StyledTabButton = styled(Button) `
|
|
6
|
+
user-select: none;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
|
|
9
|
+
border: none;
|
|
10
|
+
border-radius: 0;
|
|
11
|
+
|
|
12
|
+
color: ${({ theme }) => theme.palette.text.secondary};
|
|
13
|
+
font-weight: 500;
|
|
14
|
+
|
|
15
|
+
${({ orientation }) => orientation === "horizontal" &&
|
|
16
|
+
css `
|
|
17
|
+
border-bottom: 2px solid transparent;
|
|
18
|
+
border-top-left-radius: 5px;
|
|
19
|
+
border-top-right-radius: 5px;
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
border-top: 0;
|
|
23
|
+
border-left: 0;
|
|
24
|
+
border-right: 0;
|
|
25
|
+
border-bottom: 2px solid transparent;
|
|
26
|
+
|
|
27
|
+
background-color: ${({ theme }) => theme.palette.action.hover};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&[data-active="true"] {
|
|
31
|
+
border-bottom-color: ${({ theme }) => theme.palette.primary.main};
|
|
32
|
+
color: ${({ theme }) => theme.palette.primary.main};
|
|
33
|
+
}
|
|
34
|
+
`}
|
|
35
|
+
|
|
36
|
+
${({ orientation }) => orientation === "vertical" &&
|
|
37
|
+
css `
|
|
38
|
+
width: auto;
|
|
39
|
+
border-right: 2px solid transparent;
|
|
40
|
+
border-bottom-left-radius: 5px;
|
|
41
|
+
border-top-left-radius: 5px;
|
|
42
|
+
|
|
43
|
+
.inner-span {
|
|
44
|
+
justify-content: flex-start !important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:hover {
|
|
48
|
+
border-top: 0;
|
|
49
|
+
border-left: 0;
|
|
50
|
+
border-bottom: 0;
|
|
51
|
+
border-right: 2px solid transparent;
|
|
52
|
+
|
|
53
|
+
background-color: ${({ theme }) => theme.palette.action.hover};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&[data-active="true"] {
|
|
57
|
+
border-right-color: ${({ theme }) => theme.palette.primary.main};
|
|
58
|
+
color: ${({ theme }) => theme.palette.primary.main};
|
|
59
|
+
}
|
|
60
|
+
`}
|
|
61
|
+
`;
|
|
62
|
+
export const Tab = ({ children, style, onClick, disabled, leftSection, rightSection, value, }) => {
|
|
63
|
+
const { size, value: activeValue, onChange, orientation } = useTabs();
|
|
64
|
+
const isActive = activeValue === value;
|
|
65
|
+
return (_jsx(StyledTabButton, { className: "tab-button", style: style, "data-active": isActive, onClick: () => {
|
|
66
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
67
|
+
onChange(value);
|
|
68
|
+
}, size: size, disabled: disabled, leftSection: leftSection, rightSection: rightSection, orientation: orientation, children: children }));
|
|
69
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { Size } from "../core";
|
|
3
|
+
import { Justify, Orientation } from "./Tabs.types";
|
|
4
|
+
export declare const Tabs: React.FC<{
|
|
5
|
+
defaultValue?: string | number;
|
|
6
|
+
value?: string | number;
|
|
7
|
+
onChange?: (value: string | number) => void;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
size?: Size;
|
|
10
|
+
showDivider?: boolean;
|
|
11
|
+
justify?: Justify;
|
|
12
|
+
orientation?: Orientation;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled, { css } from "styled-components";
|
|
3
|
+
import { TabsProvider } from "./TabsProvider";
|
|
4
|
+
const StyledContainer = styled.div `
|
|
5
|
+
user-select: none;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
justify-content: ${({ justify }) => justify};
|
|
9
|
+
|
|
10
|
+
${({ orientation, showDivider, theme }) => orientation === "vertical"
|
|
11
|
+
? css `
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
border-right: ${showDivider
|
|
14
|
+
? "1px solid " + theme.palette.divider
|
|
15
|
+
: "transparent"};
|
|
16
|
+
width: max-content;
|
|
17
|
+
`
|
|
18
|
+
: css `
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
border-bottom: ${showDivider
|
|
21
|
+
? "1px solid " + theme.palette.divider
|
|
22
|
+
: "transparent"};
|
|
23
|
+
`}
|
|
24
|
+
|
|
25
|
+
color: ${({ theme }) => theme.palette.text.secondary};
|
|
26
|
+
`;
|
|
27
|
+
export const Tabs = ({ children, size, showDivider = true, justify = "start", defaultValue, value, onChange, orientation = "horizontal", }) => {
|
|
28
|
+
return (_jsx(TabsProvider, { size: size, value: value, defaultValue: defaultValue, onChange: onChange, orientation: orientation, children: _jsx(StyledContainer, { className: "tabs-container", size: size, showDivider: showDivider, justify: justify, orientation: orientation, children: children }) }));
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Size } from "../core";
|
|
2
|
+
import { Orientation } from "./Tabs.types";
|
|
3
|
+
export declare const TabsContext: import("react").Context<{
|
|
4
|
+
value: string | number;
|
|
5
|
+
defaultValue?: string | number;
|
|
6
|
+
onChange: (value: string | number) => void;
|
|
7
|
+
size?: Size;
|
|
8
|
+
orientation?: Orientation;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const TabsProvider: React.FC<{
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
size?: Size;
|
|
13
|
+
value?: string | number;
|
|
14
|
+
defaultValue?: string | number;
|
|
15
|
+
onChange?: (value: string | number) => void;
|
|
16
|
+
orientation?: Orientation;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const useTabs: () => {
|
|
19
|
+
value: string | number;
|
|
20
|
+
defaultValue?: string | number;
|
|
21
|
+
onChange: (value: string | number) => void;
|
|
22
|
+
size?: Size;
|
|
23
|
+
orientation?: Orientation;
|
|
24
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { useUncontrolled } from "@mantine/hooks";
|
|
4
|
+
export const TabsContext = createContext({
|
|
5
|
+
value: "",
|
|
6
|
+
defaultValue: "",
|
|
7
|
+
onChange: () => { },
|
|
8
|
+
size: "sm",
|
|
9
|
+
orientation: "horizontal",
|
|
10
|
+
});
|
|
11
|
+
export const TabsProvider = ({ children, size, value, defaultValue, onChange, orientation }) => {
|
|
12
|
+
const [_value, handleChange] = useUncontrolled({
|
|
13
|
+
value,
|
|
14
|
+
defaultValue,
|
|
15
|
+
finalValue: "Final",
|
|
16
|
+
onChange,
|
|
17
|
+
});
|
|
18
|
+
return (_jsx(TabsContext.Provider, { value: {
|
|
19
|
+
value: _value,
|
|
20
|
+
onChange: handleChange,
|
|
21
|
+
size,
|
|
22
|
+
defaultValue,
|
|
23
|
+
orientation,
|
|
24
|
+
}, children: children }));
|
|
25
|
+
};
|
|
26
|
+
export const useTabs = () => {
|
|
27
|
+
const context = useContext(TabsContext);
|
|
28
|
+
if (!context) {
|
|
29
|
+
throw new Error("useTabs must be used within a TabsProvider");
|
|
30
|
+
}
|
|
31
|
+
return context;
|
|
32
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monolith-forensics/monolith-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Matt Danner (Monolith Forensics LLC)",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"registry": "https://registry.npmjs.org/"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
+
"dev": "cd playground && yarn dev",
|
|
19
20
|
"clean": "rm -r ./dist",
|
|
20
21
|
"build": "tsc",
|
|
21
22
|
"listFiles": "tsc --listFiles",
|