@symply.io/basic-components 1.3.3 → 1.3.4-beta.2
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/DynamicHeaderBar/HeaderBar.js +2 -1
- package/DynamicHeaderBar/HeaderButtons.d.ts +3 -0
- package/DynamicHeaderBar/HeaderButtons.js +2 -2
- package/DynamicHeaderBar/HeaderLine.d.ts +2 -0
- package/DynamicHeaderBar/HeaderLine.js +2 -2
- package/DynamicHeaderBar/index.d.ts +3 -1
- package/DynamicHeaderBar/index.js +7 -6
- package/package.json +1 -1
@@ -22,11 +22,12 @@ import HeaderButtons from "./HeaderButtons";
|
|
22
22
|
import useCustomTheme from "../useCustomTheme";
|
23
23
|
function HeaderBar(props) {
|
24
24
|
var title = props.title, color = props.color, subtitle = props.subtitle, bottomEl = props.bottomEl, _a = props.buttons, buttons = _a === void 0 ? [] : _a, showBackButton = props.showBackButton, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onBack = props.onBack;
|
25
|
+
console.log(2, { primaryColor: primaryColor, secondaryColor: secondaryColor });
|
25
26
|
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
26
27
|
var isLessThanSm = useMediaQuery(theme.breakpoints.down("sm"));
|
27
28
|
var hasButtons = useMemo(function () { return buttons.length > 0; }, [buttons.length]);
|
28
29
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsxs(Grid, __assign({ sx: { mb: 1 } }, { children: [_jsxs(Grid, __assign({ container: true, direction: "row", justifyContent: "flex-start", alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true, xs: 12, sm: hasButtons ? 6 : 12, md: hasButtons ? 5 : 12, lg: hasButtons ? 4 : 12, xl: hasButtons ? 3 : 12 }, { children: _jsxs(Grid, __assign({ container: true, direction: "row", justifyContent: "flex-start", alignItems: "center" }, { children: [showBackButton && (_jsx(IconButton, __assign({ onClick: function () {
|
29
30
|
onBack ? onBack() : window.history.back();
|
30
|
-
} }, { children: _jsx(ArrowBackIcon, { fontSize: "small" }) }))), typeof title === "string" ? (_jsx(Typography, __assign({ align: "left", sx: { fontWeight: 600, fontSize: isLessThanSm ? 21 : 24 } }, { children: title }))) : (cloneElement(title))] })) })), hasButtons ? (_jsx(Grid, __assign({ item: true, xs: 12, sm: 6, md: 7, lg: 8, xl: 9 }, { children: _jsx(HeaderButtons, { buttons: buttons }) }))) : (_jsx(_Fragment, {}))] })), _jsx(Grid, __assign({ container: true, direction: "row" }, { children: _jsx(Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: _jsx(HeaderLine, { color: color }) })) })), subtitle && (_jsx(Grid, __assign({ container: true, direction: "row" }, { children: _jsx(Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: typeof subtitle === "string" ? (_jsx(Typography, { children: subtitle })) : (cloneElement(subtitle)) })) }))), bottomEl && (_jsx(Grid, __assign({ container: true, direction: "row" }, { children: _jsx(Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: cloneElement(bottomEl) })) })))] })) })));
|
31
|
+
} }, { children: _jsx(ArrowBackIcon, { fontSize: "small" }) }))), typeof title === "string" ? (_jsx(Typography, __assign({ align: "left", sx: { fontWeight: 600, fontSize: isLessThanSm ? 21 : 24 } }, { children: title }))) : (cloneElement(title))] })) })), hasButtons ? (_jsx(Grid, __assign({ item: true, xs: 12, sm: 6, md: 7, lg: 8, xl: 9 }, { children: _jsx(HeaderButtons, { buttons: buttons, primaryColor: primaryColor, secondaryColor: secondaryColor }) }))) : (_jsx(_Fragment, {}))] })), _jsx(Grid, __assign({ container: true, direction: "row" }, { children: _jsx(Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: _jsx(HeaderLine, { color: color, primaryColor: primaryColor, secondaryColor: secondaryColor }) })) })), subtitle && (_jsx(Grid, __assign({ container: true, direction: "row" }, { children: _jsx(Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: typeof subtitle === "string" ? (_jsx(Typography, { children: subtitle })) : (cloneElement(subtitle)) })) }))), bottomEl && (_jsx(Grid, __assign({ container: true, direction: "row" }, { children: _jsx(Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: cloneElement(bottomEl) })) })))] })) })));
|
31
32
|
}
|
32
33
|
export default HeaderBar;
|
@@ -1,6 +1,9 @@
|
|
1
|
+
import { CSSProperties } from "react";
|
1
2
|
import { HeaderButtonProps } from "./types";
|
2
3
|
export interface HeaderButtonsProps {
|
3
4
|
buttons: Array<HeaderButtonProps>;
|
5
|
+
primaryColor?: CSSProperties["color"];
|
6
|
+
secondaryColor?: CSSProperties["color"];
|
4
7
|
}
|
5
8
|
declare function HeaderButtons(props: HeaderButtonsProps): JSX.Element;
|
6
9
|
export default HeaderButtons;
|
@@ -20,8 +20,8 @@ import MenuButtonGroup from "../MenuButtonGroup";
|
|
20
20
|
import { HeaderButtonCategory } from "./types";
|
21
21
|
import useCustomTheme from "../useCustomTheme";
|
22
22
|
function HeaderButtons(props) {
|
23
|
-
var buttons = props.buttons;
|
24
|
-
var theme = useCustomTheme();
|
23
|
+
var buttons = props.buttons, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
|
24
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
25
25
|
var isLessThanSm = useMediaQuery(theme.breakpoints.down("sm"));
|
26
26
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Grid, __assign({ container: true, spacing: 1, direction: "row", justifyContent: "flex-end", alignItems: "center" }, { children: buttons.map(function (button) {
|
27
27
|
switch (button.type) {
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { CSSProperties } from "react";
|
2
2
|
interface HeaderLineProps {
|
3
3
|
color?: CSSProperties["color"];
|
4
|
+
primaryColor?: CSSProperties["color"];
|
5
|
+
secondaryColor?: CSSProperties["color"];
|
4
6
|
}
|
5
7
|
declare function HeaderLine(props: HeaderLineProps): JSX.Element;
|
6
8
|
export default HeaderLine;
|
@@ -2,8 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Divider from "@mui/material/Divider";
|
3
3
|
import useCustomTheme from "../useCustomTheme";
|
4
4
|
function HeaderLine(props) {
|
5
|
-
var color = props.color;
|
6
|
-
var theme = useCustomTheme();
|
5
|
+
var color = props.color, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
|
6
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
7
7
|
return (_jsx(Divider, { sx: {
|
8
8
|
height: "3px",
|
9
9
|
backgroundColor: color || theme.palette.primary.main
|
@@ -1,9 +1,11 @@
|
|
1
|
-
import { ReactElement } from "react";
|
1
|
+
import { ReactElement, CSSProperties } from "react";
|
2
2
|
import { SxProps } from "@mui/material/styles";
|
3
3
|
import { HeaderBarProps } from "./HeaderBar";
|
4
4
|
interface HeaderProviderProps {
|
5
5
|
sx?: SxProps;
|
6
6
|
children: ReactElement;
|
7
|
+
primaryColor?: CSSProperties["color"];
|
8
|
+
secondaryColor?: CSSProperties["color"];
|
7
9
|
}
|
8
10
|
interface HeaderContextProps {
|
9
11
|
onInit: (props: HeaderBarProps) => void;
|
@@ -10,22 +10,23 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
-
import { cloneElement, createContext, useContext, useState, useCallback
|
13
|
+
import { cloneElement, createContext, useContext, useState, useCallback } from "react";
|
14
14
|
import Grid from "@mui/material/Grid";
|
15
15
|
import HeaderBar from "./HeaderBar";
|
16
16
|
var HeaderContext = createContext({
|
17
17
|
onInit: function () { },
|
18
18
|
onShow: function () { },
|
19
|
-
onHide: function () { }
|
19
|
+
onHide: function () { }
|
20
20
|
});
|
21
21
|
export function HeaderProvider(props) {
|
22
|
-
var children = props.children, _a = props.sx, sx = _a === void 0 ? {} : _a;
|
22
|
+
var children = props.children, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, _a = props.sx, sx = _a === void 0 ? {} : _a;
|
23
23
|
var _b = useState(false), visible = _b[0], setVisible = _b[1];
|
24
24
|
var _c = useState({ title: "" }), headerProps = _c[0], setHeaderProps = _c[1];
|
25
25
|
var _d = useState(0), height = _d[0], setHeight = _d[1];
|
26
26
|
var onInit = useCallback(function (args) {
|
27
27
|
setHeaderProps(args);
|
28
28
|
}, []);
|
29
|
+
console.log({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
29
30
|
var onShow = useCallback(function () {
|
30
31
|
setVisible(true);
|
31
32
|
}, []);
|
@@ -37,12 +38,12 @@ export function HeaderProvider(props) {
|
|
37
38
|
setHeight(node.getBoundingClientRect().height);
|
38
39
|
}
|
39
40
|
}, [headerProps]);
|
40
|
-
return (_jsx(HeaderContext.Provider, __assign({ value: { onInit: onInit, onHide: onHide, onShow: onShow } }, { children: _jsxs(_Fragment, { children: [visible ? (_jsx(Grid, __assign({ container: true, direction: "row", sx: __assign({}, sx), ref: measureRef }, { children: _jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(HeaderBar, __assign({}, headerProps)) })) }))) : (_jsx(_Fragment, {})), cloneElement(children, {
|
41
|
+
return (_jsx(HeaderContext.Provider, __assign({ value: { onInit: onInit, onHide: onHide, onShow: onShow } }, { children: _jsxs(_Fragment, { children: [visible ? (_jsx(Grid, __assign({ container: true, direction: "row", sx: __assign({}, sx), ref: measureRef }, { children: _jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(HeaderBar, __assign({}, headerProps, { primaryColor: primaryColor, secondaryColor: secondaryColor })) })) }))) : (_jsx(_Fragment, {})), cloneElement(children, {
|
41
42
|
sx: {
|
42
43
|
p: 3,
|
43
44
|
py: 1,
|
44
|
-
pt: height ? "calc(".concat(height, "px)") : undefined
|
45
|
-
}
|
45
|
+
pt: height ? "calc(".concat(height, "px)") : undefined
|
46
|
+
}
|
46
47
|
})] }) })));
|
47
48
|
}
|
48
49
|
export function useHeaderBar() {
|