@fixefy/fixefy-ui-components 0.0.8 → 0.0.9

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.
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Bars = exports.DataWrapper = exports.ShowMoreContainer = exports.ShowMore = exports.Text = exports.Link = exports.PageTitle = exports.Value = exports.BoldValue = exports.Label = exports.PageHeader = exports.Card = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importStar(require("react"));
6
+ const styles_1 = require("@mui/material/styles");
7
+ const fixefy_ui_utils_1 = require("@fixefy/fixefy-ui-utils");
8
+ const material_1 = require("@mui/material");
9
+ exports.Card = (0, styles_1.styled)(material_1.Paper)(({ theme }) => ({
10
+ borderRadius: 8,
11
+ padding: 16,
12
+ overflow: 'hidden',
13
+ position: 'relative',
14
+ }));
15
+ exports.PageHeader = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
16
+ backgroundColor: '#E2EEF1',
17
+ width: '100%',
18
+ height: 220,
19
+ padding: 32,
20
+ }));
21
+ exports.Label = (0, styles_1.styled)(material_1.Typography)(({ theme }) => (Object.assign(Object.assign({}, theme.typography.overLineCaption), { color: theme.palette.statistics.label })));
22
+ exports.BoldValue = (0, styles_1.styled)(material_1.Typography)(({ theme }) => (Object.assign(Object.assign({}, theme.typography.subtitle2), { fontWeight: 700, lineHeight: '16px', color: theme.palette.typography.title })));
23
+ exports.Value = (0, styles_1.styled)(material_1.Typography)(({ theme }) => (Object.assign(Object.assign({}, theme.typography.body1), { fontFamily: theme.typography.fontFamily, lineHeight: '20px', color: theme.palette.typography.title })));
24
+ exports.PageTitle = (0, styles_1.styled)(material_1.Typography)(({ theme }) => (Object.assign(Object.assign({}, theme.typography.h4), { color: theme.palette.common.black })));
25
+ exports.Link = (0, styles_1.styled)(material_1.Link)(({ theme }) => (Object.assign(Object.assign({}, theme.typography.body1), { lineHeight: '20px', fontStyle: 'italic', color: theme.palette.primary[500], cursor: 'pointer', textDecoration: 'none' })));
26
+ exports.Text = (0, styles_1.styled)(material_1.Typography)(({ theme }) => (Object.assign(Object.assign({}, theme.typography.body1), { color: theme.palette.typography.title, textOverflow: 'ellipsis', whiteSpace: 'nowrap', overflow: 'hidden' })));
27
+ exports.ShowMore = (0, styles_1.styled)(material_1.Typography)(({ theme }) => (Object.assign(Object.assign({}, theme.typography.body1), { color: theme.palette.primary['500'], fontWeight: 600, fontSize: '12px', letterSpacing: '0.5px', lineHeight: '24px', cursor: 'pointer' })));
28
+ exports.ShowMoreContainer = (0, styles_1.styled)(material_1.Grid)(({ theme }) => ({
29
+ backgroundColor: theme.palette.common.white,
30
+ width: '100%',
31
+ display: 'flex',
32
+ justifyContent: 'center',
33
+ cursor: 'pointer',
34
+ }));
35
+ const DataWrapper = ({ values = [], title, icon, columns = 4, cardStyle = {}, wrapperStyle = {} }) => {
36
+ const normalizedValues = values.length % columns !== 0 ? [...values, ...new Array(columns - (values.length % columns))] : values;
37
+ const last4Items = normalizedValues.splice(-columns);
38
+ const containerColumns = columns === 5 ? 10 : 12;
39
+ return (<material_1.Box sx={Object.assign({}, wrapperStyle)}>
40
+ {(title || icon) && (<material_1.Box display="flex" alignItems="center" sx={{ ml: 2, mb: 1 }}>
41
+ {icon && icon}
42
+ {title && <exports.BoldValue sx={{ ml: 1 }}>{(0, fixefy_ui_utils_1.titleCase)(title)}</exports.BoldValue>}
43
+ </material_1.Box>)}
44
+ <exports.Card elevation={0} sx={Object.assign({ padding: 0, border: `1px solid #F0F0F0` }, cardStyle)}>
45
+ <material_1.Grid container columns={containerColumns}>
46
+ {normalizedValues.map((value, index) => {
47
+ return (<material_1.Grid sx={{
48
+ minHeight: 74,
49
+ padding: 2,
50
+ borderRight: value && (index + 1) % columns !== 0 && `1px solid #F0F0F0`,
51
+ borderBottom: value && `1px solid #F0F0F0`,
52
+ display: 'flex',
53
+ alignItems: 'center',
54
+ }} item key={index} xs={containerColumns / columns}>
55
+ {value && react_1.default.cloneElement(value)}
56
+ </material_1.Grid>);
57
+ })}
58
+ {last4Items.map((value, index) => {
59
+ return (<material_1.Grid sx={{
60
+ minHeight: 74,
61
+ padding: 2,
62
+ borderRight: value && (index + 1) % columns !== 0 && `1px solid #F0F0F0`,
63
+ display: 'flex',
64
+ alignItems: 'center',
65
+ }} item key={index} xs={containerColumns / columns}>
66
+ {value && react_1.default.cloneElement(value)}
67
+ </material_1.Grid>);
68
+ })}
69
+ </material_1.Grid>
70
+ </exports.Card>
71
+ </material_1.Box>);
72
+ };
73
+ exports.DataWrapper = DataWrapper;
74
+ const Bars = ({ fields }) => {
75
+ const max = (0, react_1.useMemo)(() => {
76
+ return fields.reduce((total, acc) => {
77
+ return acc.value > total ? acc.value : total;
78
+ }, 0);
79
+ }, [fields]);
80
+ const calculateTheValue = (value) => {
81
+ const calculatedValue = (value * 24) / max;
82
+ if (calculatedValue > 0 && calculatedValue < 2) {
83
+ return 2;
84
+ }
85
+ if (calculatedValue < 1) {
86
+ return 1;
87
+ }
88
+ return calculatedValue;
89
+ };
90
+ return (<div style={{ display: 'flex', alignItems: 'flex-end' }}>
91
+ {fields.map((field, index) => {
92
+ return (<div key={index} style={{
93
+ width: 8,
94
+ borderRadius: '0.75px',
95
+ height: calculateTheValue(field.value),
96
+ backgroundColor: field.color,
97
+ marginRight: 2,
98
+ }}/>);
99
+ })}
100
+ </div>);
101
+ };
102
+ exports.Bars = Bars;
package/dist-cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WizardContextProvider = exports.WizardContext = exports.FxWizard = exports.FxTodo = exports.FxTextField = exports.FxTag = exports.FxStatusBar = exports.FxStatisticsBar = exports.FxSlider = exports.FxShowMore = exports.FxScore = exports.FxProgressCounter = exports.FxProgressCircle = exports.FxNumberField = exports.FxNotes = exports.FxModal = exports.FxIcon = exports.FxChip = exports.FxButton = exports.FxAvatar = exports.FxAsyncDropdown = exports.FxAggregationsBar = exports.FxActionsTray = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  var FxActionsTray_1 = require("./FxActionsTray");
5
6
  Object.defineProperty(exports, "FxActionsTray", { enumerable: true, get: function () { return FxActionsTray_1.FxActionsTray; } });
6
7
  var FxAggregationsBar_1 = require("./FxAggregationsBar");
@@ -45,3 +46,4 @@ var FxWizard_1 = require("./FxWizard");
45
46
  Object.defineProperty(exports, "FxWizard", { enumerable: true, get: function () { return FxWizard_1.FxWizard; } });
46
47
  Object.defineProperty(exports, "WizardContext", { enumerable: true, get: function () { return FxWizard_1.WizardContext; } });
47
48
  Object.defineProperty(exports, "WizardContextProvider", { enumerable: true, get: function () { return FxWizard_1.WizardContextProvider; } });
49
+ tslib_1.__exportStar(require("./FxStyledComponents"), exports);
@@ -0,0 +1,133 @@
1
+ import React, { useMemo } from 'react';
2
+ import { styled } from '@mui/material/styles';
3
+ import { titleCase } from '@fixefy/fixefy-ui-utils';
4
+ import { Paper, Link as MuiLink, Typography, Box, Grid } from '@mui/material';
5
+ export const Card = styled(Paper)(({ theme }) => ({
6
+ borderRadius: 8,
7
+ padding: 16,
8
+ overflow: 'hidden',
9
+ position: 'relative',
10
+ }));
11
+ export const PageHeader = styled(Box)(({ theme }) => ({
12
+ backgroundColor: '#E2EEF1',
13
+ width: '100%',
14
+ height: 220,
15
+ padding: 32,
16
+ }));
17
+ export const Label = styled(Typography)(({ theme }) => ({
18
+ ...theme.typography.overLineCaption,
19
+ color: theme.palette.statistics.label,
20
+ }));
21
+ export const BoldValue = styled(Typography)(({ theme }) => ({
22
+ ...theme.typography.subtitle2,
23
+ fontWeight: 700,
24
+ lineHeight: '16px',
25
+ color: theme.palette.typography.title,
26
+ }));
27
+ export const Value = styled(Typography)(({ theme }) => ({
28
+ ...theme.typography.body1,
29
+ fontFamily: theme.typography.fontFamily,
30
+ lineHeight: '20px',
31
+ color: theme.palette.typography.title,
32
+ }));
33
+ export const PageTitle = styled(Typography)(({ theme }) => ({
34
+ ...theme.typography.h4,
35
+ color: theme.palette.common.black,
36
+ }));
37
+ export const Link = styled(MuiLink)(({ theme }) => ({
38
+ ...theme.typography.body1,
39
+ lineHeight: '20px',
40
+ fontStyle: 'italic',
41
+ color: theme.palette.primary[500],
42
+ cursor: 'pointer',
43
+ textDecoration: 'none',
44
+ }));
45
+ export const Text = styled(Typography)(({ theme }) => ({
46
+ ...theme.typography.body1,
47
+ color: theme.palette.typography.title,
48
+ textOverflow: 'ellipsis',
49
+ whiteSpace: 'nowrap',
50
+ overflow: 'hidden',
51
+ }));
52
+ export const ShowMore = styled(Typography)(({ theme }) => ({
53
+ ...theme.typography.body1,
54
+ color: theme.palette.primary['500'],
55
+ fontWeight: 600,
56
+ fontSize: '12px',
57
+ letterSpacing: '0.5px',
58
+ lineHeight: '24px',
59
+ cursor: 'pointer',
60
+ }));
61
+ export const ShowMoreContainer = styled(Grid)(({ theme }) => ({
62
+ backgroundColor: theme.palette.common.white,
63
+ width: '100%',
64
+ display: 'flex',
65
+ justifyContent: 'center',
66
+ cursor: 'pointer',
67
+ }));
68
+ export const DataWrapper = ({ values = [], title, icon, columns = 4, cardStyle = {}, wrapperStyle = {} }) => {
69
+ const normalizedValues = values.length % columns !== 0 ? [...values, ...new Array(columns - (values.length % columns))] : values;
70
+ const last4Items = normalizedValues.splice(-columns);
71
+ const containerColumns = columns === 5 ? 10 : 12;
72
+ return (<Box sx={{ ...wrapperStyle }}>
73
+ {(title || icon) && (<Box display="flex" alignItems="center" sx={{ ml: 2, mb: 1 }}>
74
+ {icon && icon}
75
+ {title && <BoldValue sx={{ ml: 1 }}>{titleCase(title)}</BoldValue>}
76
+ </Box>)}
77
+ <Card elevation={0} sx={{ padding: 0, border: `1px solid #F0F0F0`, ...cardStyle }}>
78
+ <Grid container columns={containerColumns}>
79
+ {normalizedValues.map((value, index) => {
80
+ return (<Grid sx={{
81
+ minHeight: 74,
82
+ padding: 2,
83
+ borderRight: value && (index + 1) % columns !== 0 && `1px solid #F0F0F0`,
84
+ borderBottom: value && `1px solid #F0F0F0`,
85
+ display: 'flex',
86
+ alignItems: 'center',
87
+ }} item key={index} xs={containerColumns / columns}>
88
+ {value && React.cloneElement(value)}
89
+ </Grid>);
90
+ })}
91
+ {last4Items.map((value, index) => {
92
+ return (<Grid sx={{
93
+ minHeight: 74,
94
+ padding: 2,
95
+ borderRight: value && (index + 1) % columns !== 0 && `1px solid #F0F0F0`,
96
+ display: 'flex',
97
+ alignItems: 'center',
98
+ }} item key={index} xs={containerColumns / columns}>
99
+ {value && React.cloneElement(value)}
100
+ </Grid>);
101
+ })}
102
+ </Grid>
103
+ </Card>
104
+ </Box>);
105
+ };
106
+ export const Bars = ({ fields }) => {
107
+ const max = useMemo(() => {
108
+ return fields.reduce((total, acc) => {
109
+ return acc.value > total ? acc.value : total;
110
+ }, 0);
111
+ }, [fields]);
112
+ const calculateTheValue = (value) => {
113
+ const calculatedValue = (value * 24) / max;
114
+ if (calculatedValue > 0 && calculatedValue < 2) {
115
+ return 2;
116
+ }
117
+ if (calculatedValue < 1) {
118
+ return 1;
119
+ }
120
+ return calculatedValue;
121
+ };
122
+ return (<div style={{ display: 'flex', alignItems: 'flex-end' }}>
123
+ {fields.map((field, index) => {
124
+ return (<div key={index} style={{
125
+ width: 8,
126
+ borderRadius: '0.75px',
127
+ height: calculateTheValue(field.value),
128
+ backgroundColor: field.color,
129
+ marginRight: 2,
130
+ }}/>);
131
+ })}
132
+ </div>);
133
+ };
package/dist-es/index.js CHANGED
@@ -19,3 +19,4 @@ export { FxTag } from './FxTag';
19
19
  export { FxTextField } from './FxTextField';
20
20
  export { FxTodo } from './FxTodo';
21
21
  export { FxWizard, WizardContext, WizardContextProvider } from './FxWizard';
22
+ export * from './FxStyledComponents';
@@ -0,0 +1,27 @@
1
+ import React, { ReactElement } from 'react';
2
+ export declare const Card: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
3
+ export declare const PageHeader: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
4
+ export declare const Label: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
5
+ export declare const BoldValue: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
6
+ export declare const Value: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
7
+ export declare const PageTitle: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
8
+ export declare const Link: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
9
+ export declare const Text: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
10
+ export declare const ShowMore: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
11
+ export declare const ShowMoreContainer: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
12
+ export declare const DataWrapper: ({ values, title, icon, columns, cardStyle, wrapperStyle }: {
13
+ values: ReactElement[];
14
+ title?: string | undefined;
15
+ columns?: number | undefined;
16
+ icon?: any;
17
+ cardStyle?: any;
18
+ wrapperStyle?: any;
19
+ }) => React.JSX.Element;
20
+ interface field {
21
+ value: number;
22
+ color: string;
23
+ }
24
+ export declare const Bars: ({ fields }: {
25
+ fields: field[];
26
+ }) => React.JSX.Element;
27
+ export {};
@@ -19,3 +19,4 @@ export { FxTag, TagPropsType } from './FxTag';
19
19
  export { FxTextField, TextFieldPropsType } from './FxTextField';
20
20
  export { FxTodo, TodoPropsType } from './FxTodo';
21
21
  export { FxWizard, WizardPropsType, WizardContext, WizardContextProvider } from './FxWizard';
22
+ export * from './FxStyledComponents';
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "dependencies": {
7
7
  "@apollo/client": "^3.8.4",
8
- "@fixefy/fixefy-ui-utils": "^0.0.6",
8
+ "@fixefy/fixefy-ui-utils": "^0.0.7",
9
9
  "@mui/icons-material": "^5.14.11",
10
10
  "@mui/material": "^5.14.11",
11
11
  "@mui/styled-engine": "^5.14.11",
@@ -62,5 +62,5 @@
62
62
  }
63
63
  },
64
64
  "types": "./dist-types/index.d.ts",
65
- "version": "0.0.8"
65
+ "version": "0.0.9"
66
66
  }