@pipelinesolucoes/form 1.3.10 → 1.3.11
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.
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { SvgIconProps } from '@mui/material';
|
|
2
3
|
import { TypographyVariant } from '@mui/material/styles';
|
|
3
4
|
import { ColorProps, LayoutProps } from '@pipelinesolucoes/theme';
|
|
4
5
|
export interface FieldProps extends Pick<ColorProps, 'background' | 'color'>, Pick<LayoutProps, 'width' | "maxWidth"> {
|
|
6
|
+
icon?: () => ReactElement<HTMLImageElement> | ReactElement<SvgIconProps>;
|
|
5
7
|
label: string;
|
|
6
8
|
textVariantLabel?: TypographyVariant;
|
|
7
9
|
colorLabel?: string;
|
package/dist/components/Field.js
CHANGED
|
@@ -6,10 +6,18 @@ import { fbbackground, fbcolor } from '../constant';
|
|
|
6
6
|
const StyledContainer = styled(Box, {
|
|
7
7
|
shouldForwardProp: (prop) => !['maxWidth', 'background', 'color', 'width'].includes(prop),
|
|
8
8
|
})(({ maxWidth, background, color, width, typo, theme, }) => (Object.assign({ display: 'flex', flexDirection: 'column', width: width, minWidth: 150, maxWidth: maxWidth || '100%', background: background || 'transparent', color: color || theme.palette.text.primary, height: 'auto', margin: 0 }, (typo !== null && typo !== void 0 ? typo : {}))));
|
|
9
|
+
const StyledContainerIcon = styled(Box)(() => ({
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'row',
|
|
12
|
+
width: '100%',
|
|
13
|
+
height: 'auto',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
margin: 0,
|
|
16
|
+
}));
|
|
9
17
|
const LabelStyle = styled(Box, {
|
|
10
18
|
shouldForwardProp: (prop) => !['color', 'typo',].includes(prop),
|
|
11
19
|
})(({ color, typo, theme, }) => (Object.assign({ color: color || theme.palette.text.primary }, (typo !== null && typo !== void 0 ? typo : {}))));
|
|
12
|
-
const Field = ({ label, textVariantLabel = 'caption', colorLabel, value, background, color, textVariantField = 'body1', width = 'auto', maxWidth = '100%' }) => {
|
|
20
|
+
const Field = ({ icon, label, textVariantLabel = 'caption', colorLabel, value, background, color, textVariantField = 'body1', width = 'auto', maxWidth = '100%' }) => {
|
|
13
21
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
14
22
|
const theme = useTheme();
|
|
15
23
|
// props -> tokens -> fallback
|
|
@@ -20,7 +28,10 @@ const Field = ({ label, textVariantLabel = 'caption', colorLabel, value, backgro
|
|
|
20
28
|
const labelTheme = (_h = (_g = theme.pipelinesolucoes) === null || _g === void 0 ? void 0 : _g.forms) === null || _h === void 0 ? void 0 : _h.label;
|
|
21
29
|
const typoLabel = (_k = (_j = (textVariantLabel && theme.typography[textVariantLabel])) !== null && _j !== void 0 ? _j : labelTheme === null || labelTheme === void 0 ? void 0 : labelTheme.typography) !== null && _k !== void 0 ? _k : theme.typography.caption;
|
|
22
30
|
const color_label = (_l = colorLabel !== null && colorLabel !== void 0 ? colorLabel : labelTheme === null || labelTheme === void 0 ? void 0 : labelTheme.color) !== null && _l !== void 0 ? _l : fbcolor;
|
|
23
|
-
|
|
31
|
+
if (!icon)
|
|
32
|
+
return (_jsxs(StyledContainer, { maxWidth: maxWidth, background: bg, color: txt, typo: typoField, width: width, children: [_jsx(LabelStyle, { typo: typoLabel, color: color_label, children: label }), _jsx("div", { children: value !== null && value !== void 0 ? value : '-' })] }));
|
|
33
|
+
else
|
|
34
|
+
return (_jsxs(StyledContainerIcon, { children: [icon(), _jsxs(StyledContainer, { maxWidth: maxWidth, background: bg, color: txt, typo: typoField, width: width, children: [_jsx(LabelStyle, { typo: typoLabel, color: color_label, children: label }), _jsx("div", { children: value !== null && value !== void 0 ? value : '-' })] })] }));
|
|
24
35
|
};
|
|
25
36
|
Field.displayName = 'Field';
|
|
26
37
|
export default Field;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../src/components/Field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../src/components/Field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,GAAG,EAAgB,MAAM,eAAe,CAAC;AAClD,OAAO,EAAa,MAAM,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAiBpD,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,EAAE;IAClC,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1B,CAAC,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAc,CAAC;CACzE,CAAC,CAIA,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,CAAC,iBAEvD,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,QAAQ,EACvB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,GAAG,EACb,QAAQ,EAAE,QAAQ,IAAI,MAAM,EAC5B,UAAU,EAAE,UAAU,IAAI,aAAa,EACvC,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAC1C,MAAM,EAAC,MAAM,EACb,MAAM,EAAE,CAAC,IACN,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,EACf,CACH,CAAC;AAEF,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3C,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,KAAK;IACpB,KAAK,EAAE,MAAM;IACb,MAAM,E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