@toptal/picasso-form 3.0.7 → 4.0.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-package/src/FieldRequirements/FieldRequirementItem.d.ts.map +1 -1
- package/dist-package/src/FieldRequirements/FieldRequirementItem.js +1 -7
- package/dist-package/src/FieldRequirements/FieldRequirementItem.js.map +1 -1
- package/dist-package/src/FieldRequirements/FieldRequirements.d.ts.map +1 -1
- package/dist-package/src/FieldRequirements/FieldRequirements.js +14 -13
- package/dist-package/src/FieldRequirements/FieldRequirements.js.map +1 -1
- package/dist-package/src/FieldsLayout/FieldsLayoutContext.d.ts +2 -1
- package/dist-package/src/FieldsLayout/FieldsLayoutContext.d.ts.map +1 -1
- package/dist-package/src/FieldsLayout/FieldsLayoutContext.js.map +1 -1
- package/package.json +8 -7
- package/src/FieldRequirements/FieldRequirementItem.tsx +1 -11
- package/src/FieldRequirements/FieldRequirements.tsx +36 -34
- package/src/FieldsLayout/FieldsLayoutContext.tsx +3 -1
- package/src/FormError/__snapshots__/test.tsx.snap +2 -16
- package/dist-package/src/FieldRequirements/styles.d.ts +0 -4
- package/dist-package/src/FieldRequirements/styles.d.ts.map +0 -1
- package/dist-package/src/FieldRequirements/styles.js +0 -9
- package/dist-package/src/FieldRequirements/styles.js.map +0 -1
- package/src/FieldRequirements/styles.ts +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldRequirementItem.d.ts","sourceRoot":"","sources":["../../../src/FieldRequirements/FieldRequirementItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FieldRequirementItem.d.ts","sourceRoot":"","sources":["../../../src/FieldRequirements/FieldRequirementItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAM9C,oBAAY,0BAA0B,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;AAexE,UAAU,KAAM,SAAQ,iBAAiB,CAAC,EAAE,CAAC;IAC3C,MAAM,EAAE,0BAA0B,CAAA;IAClC,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;CACF;AACD,QAAA,MAAM,oBAAoB,kCAAmC,KAAK,gBAgBjE,CAAA;AAED,eAAe,oBAAoB,CAAA"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
3
2
|
import { Typography } from '@toptal/picasso-typography';
|
|
4
3
|
import { Bullet16, CheckMinor16, CloseMinor16 } from '@toptal/picasso-icons';
|
|
5
4
|
import { GridCompound as Grid } from '@toptal/picasso-grid';
|
|
6
|
-
import styles from './styles';
|
|
7
|
-
const useStyles = makeStyles(styles, {
|
|
8
|
-
name: 'FieldRequirementItem',
|
|
9
|
-
});
|
|
10
5
|
const colorMap = {
|
|
11
6
|
default: 'dark-grey',
|
|
12
7
|
success: 'inherit',
|
|
@@ -18,10 +13,9 @@ const IconsMap = {
|
|
|
18
13
|
error: CloseMinor16,
|
|
19
14
|
};
|
|
20
15
|
const FieldRequirementItem = ({ children, status, testIds }) => {
|
|
21
|
-
const classes = useStyles();
|
|
22
16
|
const IconComponent = IconsMap[status];
|
|
23
17
|
const iconTestId = getIconTestId(status, testIds);
|
|
24
|
-
return (React.createElement(Grid.Item, { xs: 6, className:
|
|
18
|
+
return (React.createElement(Grid.Item, { xs: 6, className: 'flex items-center text-gray-600', "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.root },
|
|
25
19
|
React.createElement(IconComponent, { color: colorMap[status], "data-testid": iconTestId }),
|
|
26
20
|
React.createElement(Typography, { color: colorMap[status], className: 'ml-[8px]', size: 'xxsmall' }, children)));
|
|
27
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldRequirementItem.js","sourceRoot":"","sources":["../../../src/FieldRequirements/FieldRequirementItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FieldRequirementItem.js","sourceRoot":"","sources":["../../../src/FieldRequirements/FieldRequirementItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAK3D,MAAM,QAAQ,GAAkD;IAC9D,OAAO,EAAE,WAAW;IACpB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,KAAK;CACb,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,YAAY;CACpB,CAAA;AAWD,MAAM,oBAAoB,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAS,EAAE,EAAE;IACpE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAEjD,OAAO,CACL,oBAAC,IAAI,CAAC,IAAI,IACR,EAAE,EAAE,CAAC,EACL,SAAS,EAAC,iCAAiC,iBAC9B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI;QAE1B,oBAAC,aAAa,IAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,iBAAe,UAAU,GAAI;QACnE,oBAAC,UAAU,IAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,EAAC,UAAU,EAAC,IAAI,EAAC,SAAS,IACrE,QAAQ,CACE,CACH,CACb,CAAA;AACH,CAAC,CAAA;AAED,eAAe,oBAAoB,CAAA;AAEnC,MAAM,aAAa,GAAG,CACpB,MAAkC,EAClC,OAKC,EACD,EAAE;IACF,IAAI,MAAM,KAAK,OAAO,EAAE;QACtB,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA;KAC1B;IACD,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAA;KAC5B;IAED,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAA;AAC7B,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldRequirements.d.ts","sourceRoot":"","sources":["../../../src/FieldRequirements/FieldRequirements.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"FieldRequirements.d.ts","sourceRoot":"","sources":["../../../src/FieldRequirements/FieldRequirements.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAOvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,MAAM,WAAW,KAAK,CAAC,UAAU,CAAE,SAAQ,SAAS;IAClD,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,yFAAyF;IACzF,IAAI,EAAE,OAAO,CAAA;IACb,yDAAyD;IACzD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,qEAAqE;IACrE,YAAY,EAAE,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAA;IAC5C,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;KACvB,CAAA;CACF;AAID,eAAO,MAAM,iBAAiB;;;;;;;;CA2D7B,CAAA;AAUD,eAAe,iBAAiB,CAAA"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Collapse } from '@material-ui/core';
|
|
3
2
|
import { Typography } from '@toptal/picasso-typography';
|
|
4
3
|
import { Grid } from '@toptal/picasso-grid';
|
|
4
|
+
import { Collapse } from '@toptal/picasso-collapse';
|
|
5
5
|
import FieldRequirementItem from './FieldRequirementItem';
|
|
6
6
|
const ANIMATION_TIMEOUT = 500;
|
|
7
7
|
export const FieldRequirements = ({ value, description, open, error, timeout, requirements, className, style, testIds, }) => {
|
|
8
8
|
return (React.createElement(Collapse, { style: style, className: className, in: open, timeout: timeout, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.root },
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
React.createElement(React.Fragment, null,
|
|
10
|
+
description && (React.createElement(Typography, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.description, variant: 'body', size: 'xxsmall', className: 'mt-[0.4rem]' }, description)),
|
|
11
|
+
React.createElement(Grid, { className: 'w-input', spacing: 0, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.gridContainer }, requirements.map(requirement => {
|
|
12
|
+
let status = 'default';
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
14
|
+
if (requirement.validator(value)) {
|
|
15
|
+
status = 'success';
|
|
16
|
+
}
|
|
17
|
+
else if (error) {
|
|
18
|
+
status = 'error';
|
|
19
|
+
}
|
|
20
|
+
return (React.createElement(FieldRequirementItem, { key: requirement.message, status: status, testIds: requirement.testIds }, requirement.message));
|
|
21
|
+
})))));
|
|
21
22
|
};
|
|
22
23
|
FieldRequirements.defaultProps = {
|
|
23
24
|
open: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldRequirements.js","sourceRoot":"","sources":["../../../src/FieldRequirements/FieldRequirements.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FieldRequirements.js","sourceRoot":"","sources":["../../../src/FieldRequirements/FieldRequirements.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAGnD,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AAuBzD,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAE7B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAc,EAC7C,KAAK,EACL,WAAW,EACX,IAAI,EACJ,KAAK,EACL,OAAO,EACP,YAAY,EACZ,SAAS,EACT,KAAK,EACL,OAAO,GACW,EAAE,EAAE;IACtB,OAAO,CACL,oBAAC,QAAQ,IACP,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,IAAI,EACR,OAAO,EAAE,OAAO,iBACH,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI;QAE1B;YACG,WAAW,IAAI,CACd,oBAAC,UAAU,mBACI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EACjC,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,SAAS,EACd,SAAS,EAAC,aAAa,IAEtB,WAAW,CACD,CACd;YACD,oBAAC,IAAI,IACH,SAAS,EAAC,SAAS,EACnB,OAAO,EAAE,CAAC,iBACG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,IAElC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;gBAC9B,IAAI,MAAM,GAA+B,SAAS,CAAA;gBAElD,oEAAoE;gBACpE,IAAI,WAAW,CAAC,SAAS,CAAC,KAAM,CAAC,EAAE;oBACjC,MAAM,GAAG,SAAS,CAAA;iBACnB;qBAAM,IAAI,KAAK,EAAE;oBAChB,MAAM,GAAG,OAAO,CAAA;iBACjB;gBAED,OAAO,CACL,oBAAC,oBAAoB,IACnB,GAAG,EAAE,WAAW,CAAC,OAAO,EACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,CAAC,OAAO,IAE3B,WAAW,CAAC,OAAO,CACC,CACxB,CAAA;YACH,CAAC,CAAC,CACG,CACN,CACM,CACZ,CAAA;AACH,CAAC,CAAA;AAED,iBAAiB,CAAC,YAAY,GAAG;IAC/B,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,iBAAiB;IAC1B,KAAK,EAAE,EAAE;CACV,CAAA;AAED,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAA;AAEnD,eAAe,iBAAiB,CAAA"}
|
|
@@ -4,8 +4,9 @@ export declare type LabelColumnSize = 2 | 3 | 4;
|
|
|
4
4
|
export declare type ResponsiveLabelColumnSize = {
|
|
5
5
|
[k in BreakpointKeys]?: LabelColumnSize;
|
|
6
6
|
};
|
|
7
|
+
export declare type FieldLayout = 'horizontal' | 'vertical';
|
|
7
8
|
export declare type FieldsLayoutContextValue = {
|
|
8
|
-
layout:
|
|
9
|
+
layout: FieldLayout;
|
|
9
10
|
labelWidth: LabelColumnSize | ResponsiveLabelColumnSize;
|
|
10
11
|
};
|
|
11
12
|
export declare const DEFAULT_LABEL_WIDTH_SIZE: LabelColumnSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldsLayoutContext.d.ts","sourceRoot":"","sources":["../../../src/FieldsLayout/FieldsLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAA;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE3D,oBAAY,eAAe,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEvC,oBAAY,yBAAyB,GAAG;KACrC,CAAC,IAAI,cAAc,CAAC,CAAC,EAAE,eAAe;CACxC,CAAA;AAED,oBAAY,wBAAwB,GAAG;IACrC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"FieldsLayoutContext.d.ts","sourceRoot":"","sources":["../../../src/FieldsLayout/FieldsLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAA;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE3D,oBAAY,eAAe,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEvC,oBAAY,yBAAyB,GAAG;KACrC,CAAC,IAAI,cAAc,CAAC,CAAC,EAAE,eAAe;CACxC,CAAA;AAED,oBAAY,WAAW,GAAG,YAAY,GAAG,UAAU,CAAA;AAEnD,oBAAY,wBAAwB,GAAG;IACrC,MAAM,EAAE,WAAW,CAAA;IACnB,UAAU,EAAE,eAAe,GAAG,yBAAyB,CAAA;CACxD,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,eAAmB,CAAA;AAO1D,oBAAY,gCAAgC,GAAG;IAC7C,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,UAAU,CAAC,EAAE,eAAe,GAAG,yBAAyB,CAAA;IACxD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,2BAA2B,sCAIrC,gCAAgC,gBAgBlC,CAAA;AAED,eAAO,MAAM,sBAAsB,gCAAwC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldsLayoutContext.js","sourceRoot":"","sources":["../../../src/FieldsLayout/FieldsLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"FieldsLayoutContext.js","sourceRoot":"","sources":["../../../src/FieldsLayout/FieldsLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAgBrD,MAAM,CAAC,MAAM,wBAAwB,GAAoB,CAAC,CAAA;AAE1D,MAAM,mBAAmB,GAAG,aAAa,CAA2B;IAClE,MAAM,EAAE,UAAU;IAClB,UAAU,EAAE,wBAAwB;CACrC,CAAC,CAAA;AAQF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EAC1C,MAAM,GAAG,UAAU,EACnB,UAAU,GAAG,wBAAwB,EACrC,QAAQ,GACyB,EAAE,EAAE;IACrC,MAAM,aAAa,GAAG,aAAa,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAEjD,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM;QAC3C,UAAU;KACX,CAAC,EACF,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,CAAC,CACpC,CAAA;IAED,OAAO,CACL,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACvC,QAAQ,CACoB,CAChC,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-form",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Toptal UI components library - Form",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@toptal/picasso-
|
|
26
|
-
"@toptal/picasso-
|
|
27
|
-
"@toptal/picasso-
|
|
25
|
+
"@toptal/picasso-collapse": "2.0.0",
|
|
26
|
+
"@toptal/picasso-container": "2.0.0",
|
|
27
|
+
"@toptal/picasso-grid": "4.0.1",
|
|
28
|
+
"@toptal/picasso-icons": "1.6.0",
|
|
28
29
|
"@toptal/picasso-shared": "15.0.0",
|
|
29
|
-
"@toptal/picasso-typography": "
|
|
30
|
+
"@toptal/picasso-typography": "3.0.0",
|
|
30
31
|
"@toptal/picasso-utils": "1.0.3",
|
|
31
32
|
"ap-style-title-case": "^1.1.2",
|
|
32
33
|
"classnames": "^2.5.1",
|
|
@@ -39,14 +40,14 @@
|
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@material-ui/core": "4.12.4",
|
|
41
42
|
"@toptal/picasso-provider": "*",
|
|
42
|
-
"@toptal/picasso-tailwind": ">=2.
|
|
43
|
+
"@toptal/picasso-tailwind": ">=2.7",
|
|
43
44
|
"react": ">=16.12.0 < 19.0.0"
|
|
44
45
|
},
|
|
45
46
|
"exports": {
|
|
46
47
|
".": "./dist-package/src/index.js"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@toptal/picasso-provider": "
|
|
50
|
+
"@toptal/picasso-provider": "5.0.0",
|
|
50
51
|
"@toptal/picasso-test-utils": "1.1.1"
|
|
51
52
|
},
|
|
52
53
|
"files": [
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
4
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
5
3
|
import { Typography } from '@toptal/picasso-typography'
|
|
6
4
|
import { Bullet16, CheckMinor16, CloseMinor16 } from '@toptal/picasso-icons'
|
|
7
5
|
import { GridCompound as Grid } from '@toptal/picasso-grid'
|
|
8
6
|
|
|
9
|
-
import styles from './styles'
|
|
10
|
-
|
|
11
|
-
const useStyles = makeStyles<Theme>(styles, {
|
|
12
|
-
name: 'FieldRequirementItem',
|
|
13
|
-
})
|
|
14
|
-
|
|
15
7
|
export type FieldRequirementItemStatus = 'default' | 'success' | 'error'
|
|
16
8
|
type ColorType = 'dark-grey' | 'inherit' | 'red'
|
|
17
9
|
|
|
@@ -37,15 +29,13 @@ interface Props extends PropsWithChildren<{}> {
|
|
|
37
29
|
}
|
|
38
30
|
}
|
|
39
31
|
const FieldRequirementItem = ({ children, status, testIds }: Props) => {
|
|
40
|
-
const classes = useStyles()
|
|
41
|
-
|
|
42
32
|
const IconComponent = IconsMap[status]
|
|
43
33
|
const iconTestId = getIconTestId(status, testIds)
|
|
44
34
|
|
|
45
35
|
return (
|
|
46
36
|
<Grid.Item
|
|
47
37
|
xs={6}
|
|
48
|
-
className=
|
|
38
|
+
className='flex items-center text-gray-600'
|
|
49
39
|
data-testid={testIds?.root}
|
|
50
40
|
>
|
|
51
41
|
<IconComponent color={colorMap[status]} data-testid={iconTestId} />
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { Collapse } from '@material-ui/core'
|
|
3
2
|
import type { BaseProps } from '@toptal/picasso-shared'
|
|
4
3
|
import { Typography } from '@toptal/picasso-typography'
|
|
5
4
|
import { Grid } from '@toptal/picasso-grid'
|
|
5
|
+
import { Collapse } from '@toptal/picasso-collapse'
|
|
6
6
|
|
|
7
7
|
import type { FieldRequirementItemStatus } from './FieldRequirementItem'
|
|
8
8
|
import FieldRequirementItem from './FieldRequirementItem'
|
|
@@ -49,42 +49,44 @@ export const FieldRequirements = <TValueType,>({
|
|
|
49
49
|
timeout={timeout}
|
|
50
50
|
data-testid={testIds?.root}
|
|
51
51
|
>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
<>
|
|
53
|
+
{description && (
|
|
54
|
+
<Typography
|
|
55
|
+
data-testid={testIds?.description}
|
|
56
|
+
variant='body'
|
|
57
|
+
size='xxsmall'
|
|
58
|
+
className='mt-[0.4rem]'
|
|
59
|
+
>
|
|
60
|
+
{description}
|
|
61
|
+
</Typography>
|
|
62
|
+
)}
|
|
63
|
+
<Grid
|
|
64
|
+
className='w-input'
|
|
65
|
+
spacing={0}
|
|
66
|
+
data-testid={testIds?.gridContainer}
|
|
58
67
|
>
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
)}
|
|
62
|
-
<Grid
|
|
63
|
-
className='w-input'
|
|
64
|
-
spacing={0}
|
|
65
|
-
data-testid={testIds?.gridContainer}
|
|
66
|
-
>
|
|
67
|
-
{requirements.map(requirement => {
|
|
68
|
-
let status: FieldRequirementItemStatus = 'default'
|
|
68
|
+
{requirements.map(requirement => {
|
|
69
|
+
let status: FieldRequirementItemStatus = 'default'
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
if (requirement.validator(value!)) {
|
|
73
|
+
status = 'success'
|
|
74
|
+
} else if (error) {
|
|
75
|
+
status = 'error'
|
|
76
|
+
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
return (
|
|
79
|
+
<FieldRequirementItem
|
|
80
|
+
key={requirement.message}
|
|
81
|
+
status={status}
|
|
82
|
+
testIds={requirement.testIds}
|
|
83
|
+
>
|
|
84
|
+
{requirement.message}
|
|
85
|
+
</FieldRequirementItem>
|
|
86
|
+
)
|
|
87
|
+
})}
|
|
88
|
+
</Grid>
|
|
89
|
+
</>
|
|
88
90
|
</Collapse>
|
|
89
91
|
)
|
|
90
92
|
}
|
|
@@ -8,8 +8,10 @@ export type ResponsiveLabelColumnSize = {
|
|
|
8
8
|
[k in BreakpointKeys]?: LabelColumnSize
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export type FieldLayout = 'horizontal' | 'vertical'
|
|
12
|
+
|
|
11
13
|
export type FieldsLayoutContextValue = {
|
|
12
|
-
layout:
|
|
14
|
+
layout: FieldLayout
|
|
13
15
|
labelWidth: LabelColumnSize | ResponsiveLabelColumnSize
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -22,29 +22,15 @@ exports[`FormError renders 1`] = `
|
|
|
22
22
|
</span>
|
|
23
23
|
</label>
|
|
24
24
|
<div
|
|
25
|
-
class="
|
|
25
|
+
class="base-Input base-Input base-Input relative inline-flex gap-y gap-x items-center rounded-sm [font-size:_unset] hover:[&_.resetButtonDirty]:visible p-2 h-8 w-[18.75rem] bg-white after:content-[""] after:inline-block after:absolute after:top-0 after:bottom-0 after:right-0 after:left-0 after:pointer-events after:border-solid after:rounded-sm after:border-gray [&:has(input:focus)]:after:border-blue after:border [&:has(input:focus)]:after:shadow-[0_0_0_3px] [&:has(input:focus)]:after:shadow-blue hover:[&:not(:has(input:focus))]:after:border-gray text-black cursor-[inherit]"
|
|
26
26
|
>
|
|
27
27
|
<input
|
|
28
28
|
aria-invalid="false"
|
|
29
29
|
autocomplete="none"
|
|
30
|
-
class="
|
|
30
|
+
class="base-Input [&::-webkit-calendar-picker-indicator]:bg bg-transparent border-none box-border cursor-[inherit] h-full outline-none p-0 peer resize-none w-full text-md leading-4 text-black [&::placeholder]:text-gray [&::placeholder]:opacity-100"
|
|
31
31
|
type="text"
|
|
32
32
|
value=""
|
|
33
33
|
/>
|
|
34
|
-
<fieldset
|
|
35
|
-
aria-hidden="true"
|
|
36
|
-
class="PrivateNotchedOutline-root MuiOutlinedInput-notchedOutline PicassoOutlinedInput-notchedOutline"
|
|
37
|
-
style="padding-left: 8px;"
|
|
38
|
-
>
|
|
39
|
-
<legend
|
|
40
|
-
class="PrivateNotchedOutline-legend"
|
|
41
|
-
style="width: 0.01px;"
|
|
42
|
-
>
|
|
43
|
-
<span>
|
|
44
|
-
|
|
45
|
-
</span>
|
|
46
|
-
</legend>
|
|
47
|
-
</fieldset>
|
|
48
34
|
</div>
|
|
49
35
|
<div
|
|
50
36
|
class="PicassoFormError-root"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/FieldRequirements/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;sCAGxB,KAAK;AAAlC,wBAOI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/FieldRequirements/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,eAAe,CAAC,EAAE,OAAO,EAAS,EAAE,EAAE,CACpC,YAAY,CAAC;IACX,oBAAoB,EAAE;QACpB,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK;KAC1B;CACF,CAAC,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
2
|
-
import { createStyles } from '@material-ui/core/styles'
|
|
3
|
-
|
|
4
|
-
export default ({ palette }: Theme) =>
|
|
5
|
-
createStyles({
|
|
6
|
-
fieldRequirementItem: {
|
|
7
|
-
display: 'flex',
|
|
8
|
-
alignItems: 'center',
|
|
9
|
-
color: palette.grey.main2,
|
|
10
|
-
},
|
|
11
|
-
})
|