@coorpacademy/components 11.18.6 → 11.18.7-alpha.4
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/es/atom/image-upload/index.d.ts +2 -2
- package/es/atom/image-upload/index.d.ts.map +1 -1
- package/es/atom/image-upload/index.js +3 -4
- package/es/atom/image-upload/index.js.map +1 -1
- package/es/molecule/drag-and-drop-wrapper/index.d.ts +1 -1
- package/es/molecule/title-and-checkbox-wrapper/index.d.ts +1 -1
- package/es/molecule/title-radio-wrapper/index.d.ts +1 -1
- package/es/molecule/title-radio-wrapper/types.d.ts +1 -1
- package/es/organism/rewards-form/index.d.ts +1 -1
- package/es/organism/select-opponents/index.d.ts +1 -1
- package/es/organism/select-opponents/types.d.ts +1 -1
- package/es/organism/title-and-input/index.d.ts +1 -1
- package/es/organism/title-and-input/types.d.ts +1 -1
- package/es/organism/wizard-contents/index.d.ts +1 -1
- package/es/util/proptypes.d.ts +1 -1
- package/es/util/proptypes.d.ts.map +1 -1
- package/es/util/proptypes.js +16 -4
- package/es/util/proptypes.js.map +1 -1
- package/lib/atom/image-upload/index.d.ts +2 -2
- package/lib/atom/image-upload/index.d.ts.map +1 -1
- package/lib/atom/image-upload/index.js +4 -5
- package/lib/atom/image-upload/index.js.map +1 -1
- package/lib/molecule/drag-and-drop-wrapper/index.d.ts +1 -1
- package/lib/molecule/title-and-checkbox-wrapper/index.d.ts +1 -1
- package/lib/molecule/title-radio-wrapper/index.d.ts +1 -1
- package/lib/molecule/title-radio-wrapper/types.d.ts +1 -1
- package/lib/organism/rewards-form/index.d.ts +1 -1
- package/lib/organism/select-opponents/index.d.ts +1 -1
- package/lib/organism/select-opponents/types.d.ts +1 -1
- package/lib/organism/title-and-input/index.d.ts +1 -1
- package/lib/organism/title-and-input/types.d.ts +1 -1
- package/lib/organism/wizard-contents/index.d.ts +1 -1
- package/lib/util/proptypes.d.ts +1 -1
- package/lib/util/proptypes.d.ts.map +1 -1
- package/lib/util/proptypes.js +16 -4
- package/lib/util/proptypes.js.map +1 -1
- package/package.json +2 -2
|
@@ -14,7 +14,7 @@ declare function ImageUpload({ title, description, previewLabel, previewContent,
|
|
|
14
14
|
labelLink: any;
|
|
15
15
|
labelButtonLink: any;
|
|
16
16
|
hrefLink: any;
|
|
17
|
-
imageTypes?: string
|
|
17
|
+
imageTypes?: string | undefined;
|
|
18
18
|
error?: string | undefined;
|
|
19
19
|
buttonAriaLabel: any;
|
|
20
20
|
errorButtonLabel: any;
|
|
@@ -26,7 +26,7 @@ declare namespace ImageUpload {
|
|
|
26
26
|
name: PropTypes.Requireable<string>;
|
|
27
27
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
28
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
29
|
-
imageTypes:
|
|
29
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
30
30
|
error: PropTypes.Requireable<string>;
|
|
31
31
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
32
32
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/image-upload/index.js"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/image-upload/index.js"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;;;;;;;;gBAiFC"}
|
|
@@ -5,8 +5,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
5
5
|
import React, { useCallback } from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import DragAndDrop from '../drag-and-drop';
|
|
8
|
-
import { ImagePropType } from '../../util/proptypes';
|
|
9
8
|
import Link from '../button-link';
|
|
9
|
+
import { ImagePropType } from '../../util/proptypes';
|
|
10
10
|
import style from './style.css';
|
|
11
11
|
|
|
12
12
|
const ImageUpload = ({
|
|
@@ -24,8 +24,7 @@ const ImageUpload = ({
|
|
|
24
24
|
labelLink,
|
|
25
25
|
labelButtonLink,
|
|
26
26
|
hrefLink,
|
|
27
|
-
|
|
28
|
-
imageTypes = ['*'],
|
|
27
|
+
imageTypes = 'image/*',
|
|
29
28
|
error = '',
|
|
30
29
|
buttonAriaLabel,
|
|
31
30
|
errorButtonLabel,
|
|
@@ -83,7 +82,7 @@ ImageUpload.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, Dra
|
|
|
83
82
|
name: PropTypes.string,
|
|
84
83
|
onChange: PropTypes.func,
|
|
85
84
|
onReset: PropTypes.func,
|
|
86
|
-
imageTypes:
|
|
85
|
+
imageTypes: ImagePropType,
|
|
87
86
|
error: PropTypes.string,
|
|
88
87
|
buttonAriaLabel: PropTypes.string,
|
|
89
88
|
errorButtonLabel: PropTypes.string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","PropTypes","DragAndDrop","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","PropTypes","DragAndDrop","Link","ImagePropType","style","ImageUpload","title","description","previewLabel","previewContent","uploadLabel","loading","modified","disabled","onChange","onReset","name","labelLink","labelButtonLink","hrefLink","imageTypes","error","buttonAriaLabel","errorButtonLabel","pdfButtonLabel","pdfButtonAriaLabel","handleReset","e","preventDefault","linkCustomStyle","width","color","onDragStart","onDragStop","input","templateLink","href","download","propTypes","string","func"],"sources":["../../../src/atom/image-upload/index.js"],"sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport {isNil} from 'lodash/fp';\nimport DragAndDrop from '../drag-and-drop';\nimport Link from '../button-link';\nimport {ImagePropType} from '../../util/proptypes';\nimport style from './style.css';\n\nconst ImageUpload = ({\n title,\n description,\n previewLabel,\n previewContent,\n uploadLabel,\n loading,\n modified,\n disabled = false,\n onChange,\n onReset = null,\n name,\n labelLink,\n labelButtonLink,\n hrefLink,\n imageTypes = 'image/*',\n error = '',\n buttonAriaLabel,\n errorButtonLabel,\n pdfButtonLabel,\n pdfButtonAriaLabel\n}) => {\n const handleReset = useCallback(\n e => {\n if (isNil(onReset)) return;\n e.preventDefault();\n return onReset(e);\n },\n [onReset]\n );\n\n const linkCustomStyle = {\n width: '40px',\n color: '#FF541F'\n };\n\n return (\n <>\n <DragAndDrop\n title={title}\n description={description}\n previewLabel={previewLabel}\n previewContent={previewContent}\n uploadLabel={uploadLabel}\n loading={loading}\n modified={modified}\n onReset={handleReset}\n error={error}\n disabled={disabled}\n buttonAriaLabel={buttonAriaLabel}\n errorButtonLabel={errorButtonLabel}\n pdfButtonLabel={pdfButtonLabel}\n pdfButtonAriaLabel={pdfButtonAriaLabel}\n >\n {(onDragStart, onDragStop) => (\n <input\n type=\"file\"\n name={name}\n accept={imageTypes}\n disabled={loading || disabled}\n className={style.input}\n onChange={onChange}\n onDragEnter={onDragStart}\n onDrop={onDragStop}\n onDragLeave={onDragStop}\n />\n )}\n </DragAndDrop>\n {labelLink && hrefLink ? (\n <div className={style.templateLink}>\n {labelLink}\n <Link\n type=\"text\"\n customStyle={linkCustomStyle}\n link={{href: hrefLink, download: true}}\n label={labelButtonLink}\n />\n </div>\n ) : null}\n </>\n );\n};\n\nImageUpload.propTypes = {\n ...DragAndDrop.propTypes,\n name: PropTypes.string,\n onChange: PropTypes.func,\n onReset: PropTypes.func,\n imageTypes: ImagePropType,\n error: PropTypes.string,\n buttonAriaLabel: PropTypes.string,\n errorButtonLabel: PropTypes.string,\n labelLink: PropTypes.string,\n hrefLink: PropTypes.string\n};\n\nexport default ImageUpload;\n"],"mappings":"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"}
|
|
@@ -6,7 +6,7 @@ declare namespace DragAndDropWrapper {
|
|
|
6
6
|
name: PropTypes.Requireable<string>;
|
|
7
7
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
8
8
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
|
-
imageTypes:
|
|
9
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
10
10
|
error: PropTypes.Requireable<string>;
|
|
11
11
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
12
12
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -47,7 +47,7 @@ declare namespace TitleAndCheckBoxWrapper {
|
|
|
47
47
|
name: PropTypes.Requireable<string>;
|
|
48
48
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
49
49
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
50
|
-
imageTypes:
|
|
50
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
51
51
|
error: PropTypes.Requireable<string>;
|
|
52
52
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
53
53
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -22,7 +22,7 @@ declare const TitleRadioWrapper: {
|
|
|
22
22
|
name: import("prop-types").Requireable<string>;
|
|
23
23
|
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
24
24
|
onReset: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
25
|
-
imageTypes:
|
|
25
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
26
26
|
error: import("prop-types").Requireable<string>;
|
|
27
27
|
buttonAriaLabel: import("prop-types").Requireable<string>;
|
|
28
28
|
errorButtonLabel: import("prop-types").Requireable<string>;
|
|
@@ -22,7 +22,7 @@ declare const propTypes: {
|
|
|
22
22
|
name: PropTypes.Requireable<string>;
|
|
23
23
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
24
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
-
imageTypes:
|
|
25
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
26
26
|
error: PropTypes.Requireable<string>;
|
|
27
27
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
28
28
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -50,7 +50,7 @@ declare namespace RewardsForm {
|
|
|
50
50
|
name: PropTypes.Requireable<string>;
|
|
51
51
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
52
52
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
53
|
-
imageTypes:
|
|
53
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
54
54
|
error: PropTypes.Requireable<string>;
|
|
55
55
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
56
56
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -23,7 +23,7 @@ declare const SelectOpponents: {
|
|
|
23
23
|
name: import("prop-types").Requireable<string>;
|
|
24
24
|
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
25
25
|
onReset: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
26
|
-
imageTypes:
|
|
26
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
27
27
|
error: import("prop-types").Requireable<string>;
|
|
28
28
|
buttonAriaLabel: import("prop-types").Requireable<string>;
|
|
29
29
|
errorButtonLabel: import("prop-types").Requireable<string>;
|
|
@@ -21,7 +21,7 @@ export declare const propTypes: {
|
|
|
21
21
|
name: PropTypes.Requireable<string>;
|
|
22
22
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
23
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
|
-
imageTypes:
|
|
24
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
25
25
|
error: PropTypes.Requireable<string>;
|
|
26
26
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
27
27
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -68,7 +68,7 @@ declare const TitleAndInput: {
|
|
|
68
68
|
name: import("prop-types").Requireable<string>;
|
|
69
69
|
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
70
70
|
onReset: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
71
|
-
imageTypes:
|
|
71
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
72
72
|
error: import("prop-types").Requireable<string>;
|
|
73
73
|
buttonAriaLabel: import("prop-types").Requireable<string>;
|
|
74
74
|
errorButtonLabel: import("prop-types").Requireable<string>;
|
|
@@ -69,7 +69,7 @@ declare const propTypes: {
|
|
|
69
69
|
name: PropTypes.Requireable<string>;
|
|
70
70
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
71
71
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
72
|
-
imageTypes:
|
|
72
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
73
73
|
error: PropTypes.Requireable<string>;
|
|
74
74
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
75
75
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -247,7 +247,7 @@ declare namespace WizardContents {
|
|
|
247
247
|
name: PropTypes.Requireable<string>;
|
|
248
248
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
249
249
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
250
|
-
imageTypes:
|
|
250
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
251
251
|
error: PropTypes.Requireable<string>;
|
|
252
252
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
253
253
|
errorButtonLabel: PropTypes.Requireable<string>;
|
package/es/util/proptypes.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const UrlPropType: any;
|
|
2
2
|
export const PathPropType: any;
|
|
3
3
|
export const SrcPropType: PropTypes.Requireable<any>;
|
|
4
|
-
export function ImagePropType(
|
|
4
|
+
export function ImagePropType(props: any, propName: any, componentName: any): Error | null;
|
|
5
5
|
export const ColorPropType: any;
|
|
6
6
|
export const HexPropType: any;
|
|
7
7
|
import PropTypes from "prop-types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proptypes.d.ts","sourceRoot":"","sources":["../../src/util/proptypes.js"],"names":[],"mappings":"AASA,8BAAsD;AAGtD,+BAAwD;AAExD,qDAA4E;AAErE
|
|
1
|
+
{"version":3,"file":"proptypes.d.ts","sourceRoot":"","sources":["../../src/util/proptypes.js"],"names":[],"mappings":"AASA,8BAAsD;AAGtD,+BAAwD;AAExD,qDAA4E;AAErE,2FAsBN;AAED,gCAA4C;AAC5C,8BAAwC"}
|
package/es/util/proptypes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import
|
|
2
|
+
import split from 'lodash/fp/split';
|
|
3
3
|
import stringMatching from 'extended-proptypes/lib/validators/stringMatching';
|
|
4
4
|
import _ColorPropType from 'extended-proptypes/lib/validators/color';
|
|
5
5
|
import _HexPropType from 'extended-proptypes/lib/validators/hex';
|
|
@@ -8,9 +8,21 @@ export const UrlPropType = stringMatching(URL_REGEXP);
|
|
|
8
8
|
const PATH_REGEXP = /^\/([-a-zA-Z0-9@:%_\\+.~#?&//=]*)$/;
|
|
9
9
|
export const PathPropType = stringMatching(PATH_REGEXP);
|
|
10
10
|
export const SrcPropType = PropTypes.oneOfType([UrlPropType, PathPropType]);
|
|
11
|
-
export const ImagePropType = (
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export const ImagePropType = (props, propName, componentName) => {
|
|
12
|
+
const validImageTypes = ['image/jpeg', 'image/png', 'image/svg+xml', 'image/*', 'application/pdf'];
|
|
13
|
+
const propValue = props[propName];
|
|
14
|
+
|
|
15
|
+
if (!propValue) {
|
|
16
|
+
return new Error(`Missing prop: ${propName} at component: ${componentName}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const imageTypes = split(',', propValue);
|
|
20
|
+
|
|
21
|
+
if (imageTypes.every(type => validImageTypes.includes(type.trim()))) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return new Error(`Invalid prop value: ${propValue}, at component: ${componentName}. Expected a valid image type: image/jpeg, image/png, image/* image/svg+xml or application/pdf.`);
|
|
14
26
|
};
|
|
15
27
|
export const ColorPropType = _ColorPropType;
|
|
16
28
|
export const HexPropType = _HexPropType;
|
package/es/util/proptypes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proptypes.js","names":["PropTypes","
|
|
1
|
+
{"version":3,"file":"proptypes.js","names":["PropTypes","split","stringMatching","_ColorPropType","_HexPropType","URL_REGEXP","UrlPropType","PATH_REGEXP","PathPropType","SrcPropType","oneOfType","ImagePropType","props","propName","componentName","validImageTypes","propValue","Error","imageTypes","every","type","includes","trim","ColorPropType","HexPropType"],"sources":["../../src/util/proptypes.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport split from 'lodash/fp/split';\nimport stringMatching from 'extended-proptypes/lib/validators/stringMatching';\n\nimport _ColorPropType from 'extended-proptypes/lib/validators/color';\nimport _HexPropType from 'extended-proptypes/lib/validators/hex';\n\nconst URL_REGEXP =\n /^(http(s)?:\\/\\/.)[-a-zA-Z0-9@:%._\\\\+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\\\\+.~#?&//=]*)$/;\nexport const UrlPropType = stringMatching(URL_REGEXP);\n\nconst PATH_REGEXP = /^\\/([-a-zA-Z0-9@:%_\\\\+.~#?&//=]*)$/;\nexport const PathPropType = stringMatching(PATH_REGEXP);\n\nexport const SrcPropType = PropTypes.oneOfType([UrlPropType, PathPropType]);\n\nexport const ImagePropType = (props, propName, componentName) => {\n const validImageTypes = [\n 'image/jpeg',\n 'image/png',\n 'image/svg+xml',\n 'image/*',\n 'application/pdf'\n ];\n\n const propValue = props[propName];\n if (!propValue) {\n return new Error(`Missing prop: ${propName} at component: ${componentName}`);\n }\n\n const imageTypes = split(',', propValue);\n if (imageTypes.every(type => validImageTypes.includes(type.trim()))) {\n return null;\n }\n\n return new Error(\n `Invalid prop value: ${propValue}, at component: ${componentName}. Expected a valid image type: image/jpeg, image/png, image/* image/svg+xml or application/pdf.`\n );\n};\n\nexport const ColorPropType = _ColorPropType;\nexport const HexPropType = _HexPropType;\n"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,iBAAlB;AACA,OAAOC,cAAP,MAA2B,kDAA3B;AAEA,OAAOC,cAAP,MAA2B,yCAA3B;AACA,OAAOC,YAAP,MAAyB,uCAAzB;AAEA,MAAMC,UAAU,GACd,8FADF;AAEA,OAAO,MAAMC,WAAW,GAAGJ,cAAc,CAACG,UAAD,CAAlC;AAEP,MAAME,WAAW,GAAG,oCAApB;AACA,OAAO,MAAMC,YAAY,GAAGN,cAAc,CAACK,WAAD,CAAnC;AAEP,OAAO,MAAME,WAAW,GAAGT,SAAS,CAACU,SAAV,CAAoB,CAACJ,WAAD,EAAcE,YAAd,CAApB,CAApB;AAEP,OAAO,MAAMG,aAAa,GAAG,CAACC,KAAD,EAAQC,QAAR,EAAkBC,aAAlB,KAAoC;EAC/D,MAAMC,eAAe,GAAG,CACtB,YADsB,EAEtB,WAFsB,EAGtB,eAHsB,EAItB,SAJsB,EAKtB,iBALsB,CAAxB;EAQA,MAAMC,SAAS,GAAGJ,KAAK,CAACC,QAAD,CAAvB;;EACA,IAAI,CAACG,SAAL,EAAgB;IACd,OAAO,IAAIC,KAAJ,CAAW,iBAAgBJ,QAAS,kBAAiBC,aAAc,EAAnE,CAAP;EACD;;EAED,MAAMI,UAAU,GAAGjB,KAAK,CAAC,GAAD,EAAMe,SAAN,CAAxB;;EACA,IAAIE,UAAU,CAACC,KAAX,CAAiBC,IAAI,IAAIL,eAAe,CAACM,QAAhB,CAAyBD,IAAI,CAACE,IAAL,EAAzB,CAAzB,CAAJ,EAAqE;IACnE,OAAO,IAAP;EACD;;EAED,OAAO,IAAIL,KAAJ,CACJ,uBAAsBD,SAAU,mBAAkBF,aAAc,iGAD5D,CAAP;AAGD,CAtBM;AAwBP,OAAO,MAAMS,aAAa,GAAGpB,cAAtB;AACP,OAAO,MAAMqB,WAAW,GAAGpB,YAApB"}
|
|
@@ -14,7 +14,7 @@ declare function ImageUpload({ title, description, previewLabel, previewContent,
|
|
|
14
14
|
labelLink: any;
|
|
15
15
|
labelButtonLink: any;
|
|
16
16
|
hrefLink: any;
|
|
17
|
-
imageTypes?: string
|
|
17
|
+
imageTypes?: string | undefined;
|
|
18
18
|
error?: string | undefined;
|
|
19
19
|
buttonAriaLabel: any;
|
|
20
20
|
errorButtonLabel: any;
|
|
@@ -26,7 +26,7 @@ declare namespace ImageUpload {
|
|
|
26
26
|
name: PropTypes.Requireable<string>;
|
|
27
27
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
28
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
29
|
-
imageTypes:
|
|
29
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
30
30
|
error: PropTypes.Requireable<string>;
|
|
31
31
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
32
32
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/image-upload/index.js"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/image-upload/index.js"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;;;;;;;;gBAiFC"}
|
|
@@ -11,10 +11,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _dragAndDrop = _interopRequireDefault(require("../drag-and-drop"));
|
|
13
13
|
|
|
14
|
-
var _proptypes = require("../../util/proptypes");
|
|
15
|
-
|
|
16
14
|
var _buttonLink = _interopRequireDefault(require("../button-link"));
|
|
17
15
|
|
|
16
|
+
var _proptypes = require("../../util/proptypes");
|
|
17
|
+
|
|
18
18
|
var _style = _interopRequireDefault(require("./style.css"));
|
|
19
19
|
|
|
20
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -40,8 +40,7 @@ const ImageUpload = ({
|
|
|
40
40
|
labelLink,
|
|
41
41
|
labelButtonLink,
|
|
42
42
|
hrefLink,
|
|
43
|
-
|
|
44
|
-
imageTypes = ['*'],
|
|
43
|
+
imageTypes = 'image/*',
|
|
45
44
|
error = '',
|
|
46
45
|
buttonAriaLabel,
|
|
47
46
|
errorButtonLabel,
|
|
@@ -99,7 +98,7 @@ ImageUpload.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, _dr
|
|
|
99
98
|
name: _propTypes.default.string,
|
|
100
99
|
onChange: _propTypes.default.func,
|
|
101
100
|
onReset: _propTypes.default.func,
|
|
102
|
-
imageTypes:
|
|
101
|
+
imageTypes: _proptypes.ImagePropType,
|
|
103
102
|
error: _propTypes.default.string,
|
|
104
103
|
buttonAriaLabel: _propTypes.default.string,
|
|
105
104
|
errorButtonLabel: _propTypes.default.string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ImageUpload","title","description","previewLabel","previewContent","uploadLabel","loading","modified","disabled","onChange","onReset","name","labelLink","labelButtonLink","hrefLink","imageTypes","error","buttonAriaLabel","errorButtonLabel","pdfButtonLabel","pdfButtonAriaLabel","handleReset","useCallback","e","preventDefault","linkCustomStyle","width","color","onDragStart","onDragStop","style","input","templateLink","href","download","propTypes","DragAndDrop","PropTypes","string","func","
|
|
1
|
+
{"version":3,"file":"index.js","names":["ImageUpload","title","description","previewLabel","previewContent","uploadLabel","loading","modified","disabled","onChange","onReset","name","labelLink","labelButtonLink","hrefLink","imageTypes","error","buttonAriaLabel","errorButtonLabel","pdfButtonLabel","pdfButtonAriaLabel","handleReset","useCallback","e","preventDefault","linkCustomStyle","width","color","onDragStart","onDragStop","style","input","templateLink","href","download","propTypes","DragAndDrop","PropTypes","string","func","ImagePropType"],"sources":["../../../src/atom/image-upload/index.js"],"sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport {isNil} from 'lodash/fp';\nimport DragAndDrop from '../drag-and-drop';\nimport Link from '../button-link';\nimport {ImagePropType} from '../../util/proptypes';\nimport style from './style.css';\n\nconst ImageUpload = ({\n title,\n description,\n previewLabel,\n previewContent,\n uploadLabel,\n loading,\n modified,\n disabled = false,\n onChange,\n onReset = null,\n name,\n labelLink,\n labelButtonLink,\n hrefLink,\n imageTypes = 'image/*',\n error = '',\n buttonAriaLabel,\n errorButtonLabel,\n pdfButtonLabel,\n pdfButtonAriaLabel\n}) => {\n const handleReset = useCallback(\n e => {\n if (isNil(onReset)) return;\n e.preventDefault();\n return onReset(e);\n },\n [onReset]\n );\n\n const linkCustomStyle = {\n width: '40px',\n color: '#FF541F'\n };\n\n return (\n <>\n <DragAndDrop\n title={title}\n description={description}\n previewLabel={previewLabel}\n previewContent={previewContent}\n uploadLabel={uploadLabel}\n loading={loading}\n modified={modified}\n onReset={handleReset}\n error={error}\n disabled={disabled}\n buttonAriaLabel={buttonAriaLabel}\n errorButtonLabel={errorButtonLabel}\n pdfButtonLabel={pdfButtonLabel}\n pdfButtonAriaLabel={pdfButtonAriaLabel}\n >\n {(onDragStart, onDragStop) => (\n <input\n type=\"file\"\n name={name}\n accept={imageTypes}\n disabled={loading || disabled}\n className={style.input}\n onChange={onChange}\n onDragEnter={onDragStart}\n onDrop={onDragStop}\n onDragLeave={onDragStop}\n />\n )}\n </DragAndDrop>\n {labelLink && hrefLink ? (\n <div className={style.templateLink}>\n {labelLink}\n <Link\n type=\"text\"\n customStyle={linkCustomStyle}\n link={{href: hrefLink, download: true}}\n label={labelButtonLink}\n />\n </div>\n ) : null}\n </>\n );\n};\n\nImageUpload.propTypes = {\n ...DragAndDrop.propTypes,\n name: PropTypes.string,\n onChange: PropTypes.func,\n onReset: PropTypes.func,\n imageTypes: ImagePropType,\n error: PropTypes.string,\n buttonAriaLabel: PropTypes.string,\n errorButtonLabel: PropTypes.string,\n labelLink: PropTypes.string,\n hrefLink: PropTypes.string\n};\n\nexport default ImageUpload;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,WAAW,GAAG,CAAC;EACnBC,KADmB;EAEnBC,WAFmB;EAGnBC,YAHmB;EAInBC,cAJmB;EAKnBC,WALmB;EAMnBC,OANmB;EAOnBC,QAPmB;EAQnBC,QAAQ,GAAG,KARQ;EASnBC,QATmB;EAUnBC,OAAO,GAAG,IAVS;EAWnBC,IAXmB;EAYnBC,SAZmB;EAanBC,eAbmB;EAcnBC,QAdmB;EAenBC,UAAU,GAAG,SAfM;EAgBnBC,KAAK,GAAG,EAhBW;EAiBnBC,eAjBmB;EAkBnBC,gBAlBmB;EAmBnBC,cAnBmB;EAoBnBC;AApBmB,CAAD,KAqBd;EACJ,MAAMC,WAAW,GAAG,IAAAC,kBAAA,EAClBC,CAAC,IAAI;IACH,IAAI,qBAAMb,OAAN,CAAJ,EAAoB;IACpBa,CAAC,CAACC,cAAF;IACA,OAAOd,OAAO,CAACa,CAAD,CAAd;EACD,CALiB,EAMlB,CAACb,OAAD,CANkB,CAApB;EASA,MAAMe,eAAe,GAAG;IACtBC,KAAK,EAAE,MADe;IAEtBC,KAAK,EAAE;EAFe,CAAxB;EAKA,oBACE,yEACE,6BAAC,oBAAD;IACE,KAAK,EAAE1B,KADT;IAEE,WAAW,EAAEC,WAFf;IAGE,YAAY,EAAEC,YAHhB;IAIE,cAAc,EAAEC,cAJlB;IAKE,WAAW,EAAEC,WALf;IAME,OAAO,EAAEC,OANX;IAOE,QAAQ,EAAEC,QAPZ;IAQE,OAAO,EAAEc,WARX;IASE,KAAK,EAAEL,KATT;IAUE,QAAQ,EAAER,QAVZ;IAWE,eAAe,EAAES,eAXnB;IAYE,gBAAgB,EAAEC,gBAZpB;IAaE,cAAc,EAAEC,cAblB;IAcE,kBAAkB,EAAEC;EAdtB,GAgBG,CAACQ,WAAD,EAAcC,UAAd,kBACC;IACE,IAAI,EAAC,MADP;IAEE,IAAI,EAAElB,IAFR;IAGE,MAAM,EAAEI,UAHV;IAIE,QAAQ,EAAET,OAAO,IAAIE,QAJvB;IAKE,SAAS,EAAEsB,cAAA,CAAMC,KALnB;IAME,QAAQ,EAAEtB,QANZ;IAOE,WAAW,EAAEmB,WAPf;IAQE,MAAM,EAAEC,UARV;IASE,WAAW,EAAEA;EATf,EAjBJ,CADF,EA+BGjB,SAAS,IAAIE,QAAb,gBACC;IAAK,SAAS,EAAEgB,cAAA,CAAME;EAAtB,GACGpB,SADH,eAEE,6BAAC,mBAAD;IACE,IAAI,EAAC,MADP;IAEE,WAAW,EAAEa,eAFf;IAGE,IAAI,EAAE;MAACQ,IAAI,EAAEnB,QAAP;MAAiBoB,QAAQ,EAAE;IAA3B,CAHR;IAIE,KAAK,EAAErB;EAJT,EAFF,CADD,GAUG,IAzCN,CADF;AA6CD,CAjFD;;AAmFAb,WAAW,CAACmC,SAAZ,wDACKC,oBAAA,CAAYD,SADjB;EAEExB,IAAI,EAAE0B,kBAAA,CAAUC,MAFlB;EAGE7B,QAAQ,EAAE4B,kBAAA,CAAUE,IAHtB;EAIE7B,OAAO,EAAE2B,kBAAA,CAAUE,IAJrB;EAKExB,UAAU,EAAEyB,wBALd;EAMExB,KAAK,EAAEqB,kBAAA,CAAUC,MANnB;EAOErB,eAAe,EAAEoB,kBAAA,CAAUC,MAP7B;EAQEpB,gBAAgB,EAAEmB,kBAAA,CAAUC,MAR9B;EASE1B,SAAS,EAAEyB,kBAAA,CAAUC,MATvB;EAUExB,QAAQ,EAAEuB,kBAAA,CAAUC;AAVtB;eAaetC,W"}
|
|
@@ -6,7 +6,7 @@ declare namespace DragAndDropWrapper {
|
|
|
6
6
|
name: PropTypes.Requireable<string>;
|
|
7
7
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
8
8
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
|
-
imageTypes:
|
|
9
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
10
10
|
error: PropTypes.Requireable<string>;
|
|
11
11
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
12
12
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -47,7 +47,7 @@ declare namespace TitleAndCheckBoxWrapper {
|
|
|
47
47
|
name: PropTypes.Requireable<string>;
|
|
48
48
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
49
49
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
50
|
-
imageTypes:
|
|
50
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
51
51
|
error: PropTypes.Requireable<string>;
|
|
52
52
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
53
53
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -22,7 +22,7 @@ declare const TitleRadioWrapper: {
|
|
|
22
22
|
name: import("prop-types").Requireable<string>;
|
|
23
23
|
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
24
24
|
onReset: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
25
|
-
imageTypes:
|
|
25
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
26
26
|
error: import("prop-types").Requireable<string>;
|
|
27
27
|
buttonAriaLabel: import("prop-types").Requireable<string>;
|
|
28
28
|
errorButtonLabel: import("prop-types").Requireable<string>;
|
|
@@ -22,7 +22,7 @@ declare const propTypes: {
|
|
|
22
22
|
name: PropTypes.Requireable<string>;
|
|
23
23
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
24
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
-
imageTypes:
|
|
25
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
26
26
|
error: PropTypes.Requireable<string>;
|
|
27
27
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
28
28
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -50,7 +50,7 @@ declare namespace RewardsForm {
|
|
|
50
50
|
name: PropTypes.Requireable<string>;
|
|
51
51
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
52
52
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
53
|
-
imageTypes:
|
|
53
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
54
54
|
error: PropTypes.Requireable<string>;
|
|
55
55
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
56
56
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -23,7 +23,7 @@ declare const SelectOpponents: {
|
|
|
23
23
|
name: import("prop-types").Requireable<string>;
|
|
24
24
|
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
25
25
|
onReset: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
26
|
-
imageTypes:
|
|
26
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
27
27
|
error: import("prop-types").Requireable<string>;
|
|
28
28
|
buttonAriaLabel: import("prop-types").Requireable<string>;
|
|
29
29
|
errorButtonLabel: import("prop-types").Requireable<string>;
|
|
@@ -21,7 +21,7 @@ export declare const propTypes: {
|
|
|
21
21
|
name: PropTypes.Requireable<string>;
|
|
22
22
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
23
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
|
-
imageTypes:
|
|
24
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
25
25
|
error: PropTypes.Requireable<string>;
|
|
26
26
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
27
27
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -68,7 +68,7 @@ declare const TitleAndInput: {
|
|
|
68
68
|
name: import("prop-types").Requireable<string>;
|
|
69
69
|
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
70
70
|
onReset: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
71
|
-
imageTypes:
|
|
71
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
72
72
|
error: import("prop-types").Requireable<string>;
|
|
73
73
|
buttonAriaLabel: import("prop-types").Requireable<string>;
|
|
74
74
|
errorButtonLabel: import("prop-types").Requireable<string>;
|
|
@@ -69,7 +69,7 @@ declare const propTypes: {
|
|
|
69
69
|
name: PropTypes.Requireable<string>;
|
|
70
70
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
71
71
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
72
|
-
imageTypes:
|
|
72
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
73
73
|
error: PropTypes.Requireable<string>;
|
|
74
74
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
75
75
|
errorButtonLabel: PropTypes.Requireable<string>;
|
|
@@ -247,7 +247,7 @@ declare namespace WizardContents {
|
|
|
247
247
|
name: PropTypes.Requireable<string>;
|
|
248
248
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
249
249
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
250
|
-
imageTypes:
|
|
250
|
+
imageTypes: (props: any, propName: any, componentName: any) => Error | null;
|
|
251
251
|
error: PropTypes.Requireable<string>;
|
|
252
252
|
buttonAriaLabel: PropTypes.Requireable<string>;
|
|
253
253
|
errorButtonLabel: PropTypes.Requireable<string>;
|
package/lib/util/proptypes.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const UrlPropType: any;
|
|
2
2
|
export const PathPropType: any;
|
|
3
3
|
export const SrcPropType: PropTypes.Requireable<any>;
|
|
4
|
-
export function ImagePropType(
|
|
4
|
+
export function ImagePropType(props: any, propName: any, componentName: any): Error | null;
|
|
5
5
|
export const ColorPropType: any;
|
|
6
6
|
export const HexPropType: any;
|
|
7
7
|
import PropTypes from "prop-types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proptypes.d.ts","sourceRoot":"","sources":["../../src/util/proptypes.js"],"names":[],"mappings":"AASA,8BAAsD;AAGtD,+BAAwD;AAExD,qDAA4E;AAErE
|
|
1
|
+
{"version":3,"file":"proptypes.d.ts","sourceRoot":"","sources":["../../src/util/proptypes.js"],"names":[],"mappings":"AASA,8BAAsD;AAGtD,+BAAwD;AAExD,qDAA4E;AAErE,2FAsBN;AAED,gCAA4C;AAC5C,8BAAwC"}
|
package/lib/util/proptypes.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.UrlPropType = exports.SrcPropType = exports.PathPropType = exports.Image
|
|
|
5
5
|
|
|
6
6
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _split = _interopRequireDefault(require("lodash/fp/split"));
|
|
9
9
|
|
|
10
10
|
var _stringMatching = _interopRequireDefault(require("extended-proptypes/lib/validators/stringMatching"));
|
|
11
11
|
|
|
@@ -26,9 +26,21 @@ const SrcPropType = _propTypes.default.oneOfType([UrlPropType, PathPropType]);
|
|
|
26
26
|
|
|
27
27
|
exports.SrcPropType = SrcPropType;
|
|
28
28
|
|
|
29
|
-
const ImagePropType = (
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const ImagePropType = (props, propName, componentName) => {
|
|
30
|
+
const validImageTypes = ['image/jpeg', 'image/png', 'image/svg+xml', 'image/*', 'application/pdf'];
|
|
31
|
+
const propValue = props[propName];
|
|
32
|
+
|
|
33
|
+
if (!propValue) {
|
|
34
|
+
return new Error(`Missing prop: ${propName} at component: ${componentName}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const imageTypes = (0, _split.default)(',', propValue);
|
|
38
|
+
|
|
39
|
+
if (imageTypes.every(type => validImageTypes.includes(type.trim()))) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return new Error(`Invalid prop value: ${propValue}, at component: ${componentName}. Expected a valid image type: image/jpeg, image/png, image/* image/svg+xml or application/pdf.`);
|
|
32
44
|
};
|
|
33
45
|
|
|
34
46
|
exports.ImagePropType = ImagePropType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proptypes.js","names":["URL_REGEXP","UrlPropType","stringMatching","PATH_REGEXP","PathPropType","SrcPropType","PropTypes","oneOfType","ImagePropType","
|
|
1
|
+
{"version":3,"file":"proptypes.js","names":["URL_REGEXP","UrlPropType","stringMatching","PATH_REGEXP","PathPropType","SrcPropType","PropTypes","oneOfType","ImagePropType","props","propName","componentName","validImageTypes","propValue","Error","imageTypes","split","every","type","includes","trim","ColorPropType","_ColorPropType","HexPropType","_HexPropType"],"sources":["../../src/util/proptypes.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport split from 'lodash/fp/split';\nimport stringMatching from 'extended-proptypes/lib/validators/stringMatching';\n\nimport _ColorPropType from 'extended-proptypes/lib/validators/color';\nimport _HexPropType from 'extended-proptypes/lib/validators/hex';\n\nconst URL_REGEXP =\n /^(http(s)?:\\/\\/.)[-a-zA-Z0-9@:%._\\\\+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\\\\+.~#?&//=]*)$/;\nexport const UrlPropType = stringMatching(URL_REGEXP);\n\nconst PATH_REGEXP = /^\\/([-a-zA-Z0-9@:%_\\\\+.~#?&//=]*)$/;\nexport const PathPropType = stringMatching(PATH_REGEXP);\n\nexport const SrcPropType = PropTypes.oneOfType([UrlPropType, PathPropType]);\n\nexport const ImagePropType = (props, propName, componentName) => {\n const validImageTypes = [\n 'image/jpeg',\n 'image/png',\n 'image/svg+xml',\n 'image/*',\n 'application/pdf'\n ];\n\n const propValue = props[propName];\n if (!propValue) {\n return new Error(`Missing prop: ${propName} at component: ${componentName}`);\n }\n\n const imageTypes = split(',', propValue);\n if (imageTypes.every(type => validImageTypes.includes(type.trim()))) {\n return null;\n }\n\n return new Error(\n `Invalid prop value: ${propValue}, at component: ${componentName}. Expected a valid image type: image/jpeg, image/png, image/* image/svg+xml or application/pdf.`\n );\n};\n\nexport const ColorPropType = _ColorPropType;\nexport const HexPropType = _HexPropType;\n"],"mappings":";;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAMA,UAAU,GACd,8FADF;AAEO,MAAMC,WAAW,GAAG,IAAAC,uBAAA,EAAeF,UAAf,CAApB;;AAEP,MAAMG,WAAW,GAAG,oCAApB;AACO,MAAMC,YAAY,GAAG,IAAAF,uBAAA,EAAeC,WAAf,CAArB;;;AAEA,MAAME,WAAW,GAAGC,kBAAA,CAAUC,SAAV,CAAoB,CAACN,WAAD,EAAcG,YAAd,CAApB,CAApB;;;;AAEA,MAAMI,aAAa,GAAG,CAACC,KAAD,EAAQC,QAAR,EAAkBC,aAAlB,KAAoC;EAC/D,MAAMC,eAAe,GAAG,CACtB,YADsB,EAEtB,WAFsB,EAGtB,eAHsB,EAItB,SAJsB,EAKtB,iBALsB,CAAxB;EAQA,MAAMC,SAAS,GAAGJ,KAAK,CAACC,QAAD,CAAvB;;EACA,IAAI,CAACG,SAAL,EAAgB;IACd,OAAO,IAAIC,KAAJ,CAAW,iBAAgBJ,QAAS,kBAAiBC,aAAc,EAAnE,CAAP;EACD;;EAED,MAAMI,UAAU,GAAG,IAAAC,cAAA,EAAM,GAAN,EAAWH,SAAX,CAAnB;;EACA,IAAIE,UAAU,CAACE,KAAX,CAAiBC,IAAI,IAAIN,eAAe,CAACO,QAAhB,CAAyBD,IAAI,CAACE,IAAL,EAAzB,CAAzB,CAAJ,EAAqE;IACnE,OAAO,IAAP;EACD;;EAED,OAAO,IAAIN,KAAJ,CACJ,uBAAsBD,SAAU,mBAAkBF,aAAc,iGAD5D,CAAP;AAGD,CAtBM;;;AAwBA,MAAMU,aAAa,GAAGC,cAAtB;;AACA,MAAMC,WAAW,GAAGC,YAApB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/components",
|
|
3
|
-
"version": "11.18.
|
|
3
|
+
"version": "11.18.7-alpha.4+5320c3e52",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -168,5 +168,5 @@
|
|
|
168
168
|
"last 2 versions",
|
|
169
169
|
"IE 11"
|
|
170
170
|
],
|
|
171
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "5320c3e527d5ab5e01ab4a83c6fb5cf0f7f81aff"
|
|
172
172
|
}
|