@coorpacademy/components 11.13.4 → 11.13.6-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/form-text-input/index.d.ts +28 -0
- package/es/atom/form-text-input/index.d.ts.map +1 -0
- package/es/atom/form-text-input/index.js +113 -0
- package/es/atom/form-text-input/index.js.map +1 -0
- package/es/atom/form-text-input/prop-types.d.ts +59 -0
- package/es/atom/form-text-input/prop-types.d.ts.map +1 -0
- package/es/atom/form-text-input/prop-types.js +36 -0
- package/es/atom/form-text-input/prop-types.js.map +1 -0
- package/es/atom/form-text-input/style.css +53 -0
- package/es/molecule/questions/qcm-graphic/style.css +2 -1
- package/lib/atom/form-text-input/index.d.ts +28 -0
- package/lib/atom/form-text-input/index.d.ts.map +1 -0
- package/lib/atom/form-text-input/index.js +128 -0
- package/lib/atom/form-text-input/index.js.map +1 -0
- package/lib/atom/form-text-input/prop-types.d.ts +59 -0
- package/lib/atom/form-text-input/prop-types.d.ts.map +1 -0
- package/lib/atom/form-text-input/prop-types.js +47 -0
- package/lib/atom/form-text-input/prop-types.js.map +1 -0
- package/lib/atom/form-text-input/style.css +53 -0
- package/lib/molecule/questions/qcm-graphic/style.css +2 -1
- package/package.json +2 -2
- package/locales/.mtslconfig.json +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormTextInputProps } from './prop-types';
|
|
3
|
+
declare const FormTextInput: {
|
|
4
|
+
({ "aria-label": ariaLabel, autocomplete, "data-testid": dataTestid, disabled, hint, inputClassName, isRequired, label, maxlength, name, onChange, passwordRules, placeholder, type, value, equals, wrapperClassName }: FormTextInputProps): JSX.Element;
|
|
5
|
+
propTypes: {
|
|
6
|
+
'aria-label': import("prop-types").Requireable<string>;
|
|
7
|
+
autocomplete: import("prop-types").Requireable<string>;
|
|
8
|
+
'data-testid': import("prop-types").Requireable<string>;
|
|
9
|
+
disabled: import("prop-types").Requireable<boolean>;
|
|
10
|
+
equals: import("prop-types").Requireable<NonNullable<string | number | null | undefined>>;
|
|
11
|
+
hint: import("prop-types").Requireable<string>;
|
|
12
|
+
inputClassName: import("prop-types").Requireable<string>;
|
|
13
|
+
isRequired: import("prop-types").Requireable<boolean>;
|
|
14
|
+
label: import("prop-types").Requireable<string>;
|
|
15
|
+
maxlength: import("prop-types").Requireable<number>;
|
|
16
|
+
name: import("prop-types").Requireable<string>;
|
|
17
|
+
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
18
|
+
passwordRules: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
19
|
+
minLength: import("prop-types").Requireable<number>;
|
|
20
|
+
}>>;
|
|
21
|
+
placeholder: import("prop-types").Requireable<string>;
|
|
22
|
+
type: import("prop-types").Requireable<string>;
|
|
23
|
+
value: import("prop-types").Requireable<NonNullable<string | number | null | undefined>>;
|
|
24
|
+
wrapperClassName: import("prop-types").Requireable<string>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default FormTextInput;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/form-text-input/index.tsx"],"names":[],"mappings":";AAYA,OAAkB,EAAa,kBAAkB,EAAY,MAAM,cAAc,CAAC;AAqBlF,QAAA,MAAM,aAAa;4NAkBhB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;CAyEpB,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useMemo, useState, useEffect } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import getOr from 'lodash/fp/getOr';
|
|
6
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
7
|
+
import isEqual from 'lodash/fp/isEqual';
|
|
8
|
+
import noop from 'lodash/fp/noop';
|
|
9
|
+
import size from 'lodash/fp/size'; // import {
|
|
10
|
+
// NovaCompositionNavigationArrowRight as ArrowRight,
|
|
11
|
+
// NovaCompositionCoorpacademyInformationIcon as InformationIcon
|
|
12
|
+
// } from '@coorpacademy/nova-icons';
|
|
13
|
+
// import Provider, {GetTranslateFromContext} from '../provider';
|
|
14
|
+
|
|
15
|
+
import propTypes, { TextInput } from './prop-types';
|
|
16
|
+
import style from './style.css';
|
|
17
|
+
|
|
18
|
+
const validate = (fieldValue, fieldEqualsValue) => {
|
|
19
|
+
return isEqual(fieldValue, fieldEqualsValue);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const VALID_EMAIL_PATTERN = /[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
|
23
|
+
|
|
24
|
+
const validatePattern = (fieldValue, pattern) => {
|
|
25
|
+
return pattern.test(fieldValue);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const DEFAULT_MIN_LENGTH = 8;
|
|
29
|
+
|
|
30
|
+
const isEqualsDefined = equals => !isEmpty(equals); // autocorrect="off"
|
|
31
|
+
// autocapitalize="none"
|
|
32
|
+
// ng-pattern="/[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const FormTextInput = ({
|
|
36
|
+
'aria-label': ariaLabel,
|
|
37
|
+
autocomplete,
|
|
38
|
+
'data-testid': dataTestid = 'form-text-input',
|
|
39
|
+
disabled,
|
|
40
|
+
hint,
|
|
41
|
+
inputClassName,
|
|
42
|
+
isRequired,
|
|
43
|
+
label,
|
|
44
|
+
maxlength = 150,
|
|
45
|
+
name,
|
|
46
|
+
onChange = noop,
|
|
47
|
+
passwordRules,
|
|
48
|
+
placeholder,
|
|
49
|
+
type = 'default',
|
|
50
|
+
value,
|
|
51
|
+
equals,
|
|
52
|
+
wrapperClassName
|
|
53
|
+
}) => {
|
|
54
|
+
const [newValue, setNewValue] = useState(value);
|
|
55
|
+
const [isValid, setIsValid] = useState(true);
|
|
56
|
+
const isDefaultType = useMemo(() => !type || type === TextInput.default, [type]);
|
|
57
|
+
const isPasswordInput = useMemo(() => type === TextInput.password || type === TextInput.passwordConfirmation, [type]);
|
|
58
|
+
const isEmailInput = useMemo(() => type === TextInput.email, [type]);
|
|
59
|
+
const handleInputChange = useCallback(event => {
|
|
60
|
+
const newInput = event.target.value;
|
|
61
|
+
setNewValue(() => {
|
|
62
|
+
const isNewValueValid = !isEqualsDefined(equals) || validate(newInput, equals);
|
|
63
|
+
const validPattern = !isEmailInput || validatePattern(newInput, VALID_EMAIL_PATTERN);
|
|
64
|
+
const passwordLengthCheck = !isPasswordInput || size(newInput) >= getOr(DEFAULT_MIN_LENGTH, ['minLength'], passwordRules);
|
|
65
|
+
setIsValid(passwordLengthCheck && isNewValueValid && validPattern);
|
|
66
|
+
return newInput;
|
|
67
|
+
});
|
|
68
|
+
}, [equals, isEmailInput, isPasswordInput, passwordRules]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
onChange(newValue, isValid);
|
|
71
|
+
return;
|
|
72
|
+
}, [isValid, newValue, onChange]);
|
|
73
|
+
const fieldLabel = useMemo(() => `${label} ${isRequired ? '*' : ''}`, [isRequired, label]);
|
|
74
|
+
const errorStyle = useMemo(() => isValid ? undefined : {
|
|
75
|
+
border: '2px solid rgb(247, 63, 82)'
|
|
76
|
+
}, [isValid]);
|
|
77
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: classnames(style.wrapper, wrapperClassName)
|
|
79
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
80
|
+
className: style.formLabel,
|
|
81
|
+
htmlFor: name
|
|
82
|
+
}, fieldLabel), /*#__PURE__*/React.createElement("input", _extends({}, !isPasswordInput && !isEmailInput && {
|
|
83
|
+
maxLength: maxlength
|
|
84
|
+
}, isEmailInput && {
|
|
85
|
+
autoCapitalize: 'none'
|
|
86
|
+
}, isRequired && {
|
|
87
|
+
required: true
|
|
88
|
+
}, !isValid && {
|
|
89
|
+
'aria-invalid': true
|
|
90
|
+
}, {
|
|
91
|
+
type: isDefaultType ? 'text' : type,
|
|
92
|
+
"aria-label": ariaLabel,
|
|
93
|
+
autoComplete: isDefaultType ? 'on' : autocomplete,
|
|
94
|
+
autoCorrect: 'off',
|
|
95
|
+
className: classnames(style.textInput, inputClassName),
|
|
96
|
+
"data-testid": dataTestid,
|
|
97
|
+
disabled: disabled,
|
|
98
|
+
id: name,
|
|
99
|
+
name: name,
|
|
100
|
+
onInput: handleInputChange,
|
|
101
|
+
placeholder: placeholder,
|
|
102
|
+
value: value,
|
|
103
|
+
style: errorStyle
|
|
104
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
105
|
+
className: style.hintWrapper
|
|
106
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
107
|
+
className: style.hint
|
|
108
|
+
}, hint)));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
FormTextInput.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
112
|
+
export default FormTextInput;
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useMemo","useState","useEffect","classnames","getOr","isEmpty","isEqual","noop","size","propTypes","TextInput","style","validate","fieldValue","fieldEqualsValue","VALID_EMAIL_PATTERN","validatePattern","pattern","test","DEFAULT_MIN_LENGTH","isEqualsDefined","equals","FormTextInput","ariaLabel","autocomplete","dataTestid","disabled","hint","inputClassName","isRequired","label","maxlength","name","onChange","passwordRules","placeholder","type","value","wrapperClassName","newValue","setNewValue","isValid","setIsValid","isDefaultType","default","isPasswordInput","password","passwordConfirmation","isEmailInput","email","handleInputChange","event","newInput","target","isNewValueValid","validPattern","passwordLengthCheck","fieldLabel","errorStyle","undefined","border","wrapper","formLabel","maxLength","autoCapitalize","required","textInput","hintWrapper"],"sources":["../../../src/atom/form-text-input/index.tsx"],"sourcesContent":["import React, {useCallback, useMemo, useState, useEffect, FormEvent} from 'react';\nimport classnames from 'classnames';\nimport getOr from 'lodash/fp/getOr';\nimport isEmpty from 'lodash/fp/isEmpty';\nimport isEqual from 'lodash/fp/isEqual';\nimport noop from 'lodash/fp/noop';\nimport size from 'lodash/fp/size';\n// import {\n// NovaCompositionNavigationArrowRight as ArrowRight,\n// NovaCompositionCoorpacademyInformationIcon as InformationIcon\n// } from '@coorpacademy/nova-icons';\n// import Provider, {GetTranslateFromContext} from '../provider';\nimport propTypes, {FieldValue, FormTextInputProps, TextInput} from './prop-types';\nimport style from './style.css';\n\nconst validate = (fieldValue: FieldValue, fieldEqualsValue: FieldValue) => {\n return isEqual(fieldValue, fieldEqualsValue);\n};\n\nconst VALID_EMAIL_PATTERN =\n /[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;\n\nconst validatePattern = (fieldValue: string, pattern: RegExp) => {\n return pattern.test(fieldValue);\n};\n\nconst DEFAULT_MIN_LENGTH = 8;\n\nconst isEqualsDefined = (equals: FieldValue | undefined): equals is FieldValue => !isEmpty(equals);\n\n// autocorrect=\"off\"\n// autocapitalize=\"none\"\n// ng-pattern=\"/[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/\"\nconst FormTextInput = ({\n 'aria-label': ariaLabel,\n autocomplete,\n 'data-testid': dataTestid = 'form-text-input',\n disabled,\n hint,\n inputClassName,\n isRequired,\n label,\n maxlength = 150,\n name,\n onChange = noop,\n passwordRules,\n placeholder,\n type = 'default',\n value,\n equals,\n wrapperClassName\n}: FormTextInputProps) => {\n const [newValue, setNewValue] = useState<FieldValue>(value);\n\n const [isValid, setIsValid] = useState<boolean>(true);\n\n const isDefaultType = useMemo(() => !type || type === TextInput.default, [type]);\n\n const isPasswordInput = useMemo(\n () => type === TextInput.password || type === TextInput.passwordConfirmation,\n [type]\n );\n\n const isEmailInput = useMemo(() => type === TextInput.email, [type]);\n\n const handleInputChange = useCallback(\n (event: FormEvent<HTMLInputElement>) => {\n const newInput: FieldValue = (event.target as HTMLInputElement).value;\n setNewValue(() => {\n const isNewValueValid = !isEqualsDefined(equals) || validate(newInput, equals);\n const validPattern = !isEmailInput || validatePattern(newInput, VALID_EMAIL_PATTERN);\n const passwordLengthCheck =\n !isPasswordInput ||\n size(newInput) >= getOr(DEFAULT_MIN_LENGTH, ['minLength'], passwordRules);\n\n setIsValid(passwordLengthCheck && isNewValueValid && validPattern);\n\n return newInput;\n });\n },\n [equals, isEmailInput, isPasswordInput, passwordRules]\n );\n\n useEffect(() => {\n onChange(newValue, isValid);\n return;\n }, [isValid, newValue, onChange]);\n\n const fieldLabel = useMemo(() => `${label} ${isRequired ? '*' : ''}`, [isRequired, label]);\n\n const errorStyle = useMemo(\n () => (isValid ? undefined : {border: '2px solid rgb(247, 63, 82)'}),\n [isValid]\n );\n\n return (\n <div className={classnames(style.wrapper, wrapperClassName)}>\n <label className={style.formLabel} htmlFor={name}>\n {fieldLabel}\n </label>\n <input\n {...(!isPasswordInput && !isEmailInput && {maxLength: maxlength})}\n {...(isEmailInput && {autoCapitalize: 'none'})}\n {...(isRequired && {required: true})}\n {...(!isValid && {'aria-invalid': true})}\n type={isDefaultType ? 'text' : type}\n aria-label={ariaLabel}\n autoComplete={isDefaultType ? 'on' : autocomplete}\n autoCorrect={'off'}\n className={classnames(style.textInput, inputClassName)}\n data-testid={dataTestid}\n disabled={disabled}\n id={name}\n name={name}\n onInput={handleInputChange}\n placeholder={placeholder}\n value={value}\n style={errorStyle}\n />\n <div className={style.hintWrapper}>\n <span className={style.hint}>{hint}</span>\n </div>\n </div>\n );\n};\n\nFormTextInput.propTypes = propTypes;\n\nexport default FormTextInput;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,OAA5B,EAAqCC,QAArC,EAA+CC,SAA/C,QAA0E,OAA1E;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,KAAP,MAAkB,iBAAlB;AACA,OAAOC,OAAP,MAAoB,mBAApB;AACA,OAAOC,OAAP,MAAoB,mBAApB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,IAAP,MAAiB,gBAAjB,C,CACA;AACA;AACA;AACA;AACA;;AACA,OAAOC,SAAP,IAAmDC,SAAnD,QAAmE,cAAnE;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,QAAQ,GAAG,CAACC,UAAD,EAAyBC,gBAAzB,KAA0D;EACzE,OAAOR,OAAO,CAACO,UAAD,EAAaC,gBAAb,CAAd;AACD,CAFD;;AAIA,MAAMC,mBAAmB,GACvB,mIADF;;AAGA,MAAMC,eAAe,GAAG,CAACH,UAAD,EAAqBI,OAArB,KAAyC;EAC/D,OAAOA,OAAO,CAACC,IAAR,CAAaL,UAAb,CAAP;AACD,CAFD;;AAIA,MAAMM,kBAAkB,GAAG,CAA3B;;AAEA,MAAMC,eAAe,GAAIC,MAAD,IAA0D,CAAChB,OAAO,CAACgB,MAAD,CAA1F,C,CAEA;AACA;AACA;;;AACA,MAAMC,aAAa,G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E,IAAI,EAAEE,aAAa,GAAG,MAAH,GAAYP,IALjC;IAME,cAAYb,SANd;IAOE,YAAY,EAAEoB,aAAa,GAAG,IAAH,GAAUnB,YAPvC;IAQE,WAAW,EAAE,KARf;IASE,SAAS,EAAErB,UAAU,CAACQ,KAAK,CAACuD,SAAP,EAAkBtC,cAAlB,CATvB;IAUE,eAAaH,UAVf;IAWE,QAAQ,EAAEC,QAXZ;IAYE,EAAE,EAAEM,IAZN;IAaE,IAAI,EAAEA,IAbR;IAcE,OAAO,EAAEkB,iBAdX;IAeE,WAAW,EAAEf,WAff;IAgBE,KAAK,EAAEE,KAhBT;IAiBE,KAAK,EAAEqB;EAjBT,GAJF,eAuBE;IAAK,SAAS,EAAE/C,KAAK,CAACwD;EAAtB,gBACE;IAAM,SAAS,EAAExD,KAAK,CAACgB;EAAvB,GAA8BA,IAA9B,CADF,CAvBF,CADF;AA6BD,CA3FD;;AA6FAL,aAAa,CAACb,SAAd,2CAA0BA,SAA1B;AAEA,eAAea,aAAf"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
export declare const TextInput: {
|
|
3
|
+
readonly country: "country";
|
|
4
|
+
readonly email: "email";
|
|
5
|
+
readonly firstName: "firstName";
|
|
6
|
+
readonly lastName: "lastName";
|
|
7
|
+
readonly language: "language";
|
|
8
|
+
readonly login: "login";
|
|
9
|
+
readonly password: "password";
|
|
10
|
+
readonly passwordConfirmation: "passwordConfirmation";
|
|
11
|
+
readonly default: "default";
|
|
12
|
+
};
|
|
13
|
+
declare const propTypes: {
|
|
14
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
15
|
+
autocomplete: PropTypes.Requireable<string>;
|
|
16
|
+
'data-testid': PropTypes.Requireable<string>;
|
|
17
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
18
|
+
equals: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
19
|
+
hint: PropTypes.Requireable<string>;
|
|
20
|
+
inputClassName: PropTypes.Requireable<string>;
|
|
21
|
+
isRequired: PropTypes.Requireable<boolean>;
|
|
22
|
+
label: PropTypes.Requireable<string>;
|
|
23
|
+
maxlength: PropTypes.Requireable<number>;
|
|
24
|
+
name: PropTypes.Requireable<string>;
|
|
25
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
26
|
+
passwordRules: PropTypes.Requireable<PropTypes.InferProps<{
|
|
27
|
+
minLength: PropTypes.Requireable<number>;
|
|
28
|
+
}>>;
|
|
29
|
+
placeholder: PropTypes.Requireable<string>;
|
|
30
|
+
type: PropTypes.Requireable<string>;
|
|
31
|
+
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
32
|
+
wrapperClassName: PropTypes.Requireable<string>;
|
|
33
|
+
};
|
|
34
|
+
declare type TextInputType = keyof typeof TextInput;
|
|
35
|
+
export declare type FieldValue = string | number;
|
|
36
|
+
export declare type PasswordRulesConfig = {
|
|
37
|
+
minLength: number;
|
|
38
|
+
};
|
|
39
|
+
export declare type FormTextInputProps = {
|
|
40
|
+
'aria-label'?: string;
|
|
41
|
+
autocomplete?: string;
|
|
42
|
+
'data-testid'?: string;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
equals?: FieldValue;
|
|
45
|
+
hint?: string;
|
|
46
|
+
inputClassName?: string | null;
|
|
47
|
+
isRequired?: boolean;
|
|
48
|
+
label: string;
|
|
49
|
+
maxlength?: number;
|
|
50
|
+
name: string;
|
|
51
|
+
onChange?: (value: FieldValue, isValid?: boolean) => void;
|
|
52
|
+
passwordRules?: PasswordRulesConfig;
|
|
53
|
+
placeholder?: string;
|
|
54
|
+
type?: TextInputType;
|
|
55
|
+
value: FieldValue;
|
|
56
|
+
wrapperClassName?: string | null;
|
|
57
|
+
};
|
|
58
|
+
export default propTypes;
|
|
59
|
+
//# sourceMappingURL=prop-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-types.d.ts","sourceRoot":"","sources":["../../../src/atom/form-text-input/prop-types.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAGnC,eAAO,MAAM,SAAS;;;;;;;;;;CAUZ,CAAC;AAEX,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBd,CAAC;AAEF,aAAK,aAAa,GAAG,MAAM,OAAO,SAAS,CAAC;AAE5C,oBAAY,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC,oBAAY,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import keys from 'lodash/fp/keys';
|
|
3
|
+
export const TextInput = {
|
|
4
|
+
country: 'country',
|
|
5
|
+
email: 'email',
|
|
6
|
+
firstName: 'firstName',
|
|
7
|
+
lastName: 'lastName',
|
|
8
|
+
language: 'language',
|
|
9
|
+
login: 'login',
|
|
10
|
+
password: 'password',
|
|
11
|
+
passwordConfirmation: 'passwordConfirmation',
|
|
12
|
+
default: 'default'
|
|
13
|
+
};
|
|
14
|
+
const propTypes = {
|
|
15
|
+
'aria-label': PropTypes.string,
|
|
16
|
+
autocomplete: PropTypes.string,
|
|
17
|
+
'data-testid': PropTypes.string,
|
|
18
|
+
disabled: PropTypes.bool,
|
|
19
|
+
equals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
20
|
+
hint: PropTypes.string,
|
|
21
|
+
inputClassName: PropTypes.string,
|
|
22
|
+
isRequired: PropTypes.bool,
|
|
23
|
+
label: PropTypes.string,
|
|
24
|
+
maxlength: PropTypes.number,
|
|
25
|
+
name: PropTypes.string,
|
|
26
|
+
onChange: PropTypes.func,
|
|
27
|
+
passwordRules: PropTypes.shape({
|
|
28
|
+
minLength: PropTypes.number
|
|
29
|
+
}),
|
|
30
|
+
placeholder: PropTypes.string,
|
|
31
|
+
type: PropTypes.oneOf(keys(TextInput)),
|
|
32
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
33
|
+
wrapperClassName: PropTypes.string
|
|
34
|
+
};
|
|
35
|
+
export default propTypes;
|
|
36
|
+
//# sourceMappingURL=prop-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-types.js","names":["PropTypes","keys","TextInput","country","email","firstName","lastName","language","login","password","passwordConfirmation","default","propTypes","string","autocomplete","disabled","bool","equals","oneOfType","number","hint","inputClassName","isRequired","label","maxlength","name","onChange","func","passwordRules","shape","minLength","placeholder","type","oneOf","value","wrapperClassName"],"sources":["../../../src/atom/form-text-input/prop-types.ts"],"sourcesContent":["import PropTypes from 'prop-types';\nimport keys from 'lodash/fp/keys';\n\nexport const TextInput = {\n country: 'country',\n email: 'email',\n firstName: 'firstName',\n lastName: 'lastName',\n language: 'language',\n login: 'login',\n password: 'password',\n passwordConfirmation: 'passwordConfirmation',\n default: 'default'\n} as const;\n\nconst propTypes = {\n 'aria-label': PropTypes.string,\n autocomplete: PropTypes.string,\n 'data-testid': PropTypes.string,\n disabled: PropTypes.bool,\n equals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n hint: PropTypes.string,\n inputClassName: PropTypes.string,\n isRequired: PropTypes.bool,\n label: PropTypes.string,\n maxlength: PropTypes.number,\n name: PropTypes.string,\n onChange: PropTypes.func,\n passwordRules: PropTypes.shape({\n minLength: PropTypes.number\n }),\n placeholder: PropTypes.string,\n type: PropTypes.oneOf(keys(TextInput)),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n wrapperClassName: PropTypes.string\n};\n\ntype TextInputType = keyof typeof TextInput;\n\nexport type FieldValue = string | number;\n\nexport type PasswordRulesConfig = {\n minLength: number;\n};\n\nexport type FormTextInputProps = {\n 'aria-label'?: string;\n autocomplete?: string;\n 'data-testid'?: string;\n disabled?: boolean;\n equals?: FieldValue;\n hint?: string;\n inputClassName?: string | null;\n isRequired?: boolean;\n label: string;\n maxlength?: number;\n name: string;\n onChange?: (value: FieldValue, isValid?: boolean) => void;\n passwordRules?: PasswordRulesConfig;\n placeholder?: string;\n type?: TextInputType;\n value: FieldValue;\n wrapperClassName?: string | null;\n};\n\nexport default propTypes;\n"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AAEA,OAAO,MAAMC,SAAS,GAAG;EACvBC,OAAO,EAAE,SADc;EAEvBC,KAAK,EAAE,OAFgB;EAGvBC,SAAS,EAAE,WAHY;EAIvBC,QAAQ,EAAE,UAJa;EAKvBC,QAAQ,EAAE,UALa;EAMvBC,KAAK,EAAE,OANgB;EAOvBC,QAAQ,EAAE,UAPa;EAQvBC,oBAAoB,EAAE,sBARC;EASvBC,OAAO,EAAE;AATc,CAAlB;AAYP,MAAMC,SAAS,GAAG;EAChB,cAAcZ,SAAS,CAACa,MADR;EAEhBC,YAAY,EAAEd,SAAS,CAACa,MAFR;EAGhB,eAAeb,SAAS,CAACa,MAHT;EAIhBE,QAAQ,EAAEf,SAAS,CAACgB,IAJJ;EAKhBC,MAAM,EAAEjB,SAAS,CAACkB,SAAV,CAAoB,CAAClB,SAAS,CAACa,MAAX,EAAmBb,SAAS,CAACmB,MAA7B,CAApB,CALQ;EAMhBC,IAAI,EAAEpB,SAAS,CAACa,MANA;EAOhBQ,cAAc,EAAErB,SAAS,CAACa,MAPV;EAQhBS,UAAU,EAAEtB,SAAS,CAACgB,IARN;EAShBO,KAAK,EAAEvB,SAAS,CAACa,MATD;EAUhBW,SAAS,EAAExB,SAAS,CAACmB,MAVL;EAWhBM,IAAI,EAAEzB,SAAS,CAACa,MAXA;EAYhBa,QAAQ,EAAE1B,SAAS,CAAC2B,IAZJ;EAahBC,aAAa,EAAE5B,SAAS,CAAC6B,KAAV,CAAgB;IAC7BC,SAAS,EAAE9B,SAAS,CAACmB;EADQ,CAAhB,CAbC;EAgBhBY,WAAW,EAAE/B,SAAS,CAACa,MAhBP;EAiBhBmB,IAAI,EAAEhC,SAAS,CAACiC,KAAV,CAAgBhC,IAAI,CAACC,SAAD,CAApB,CAjBU;EAkBhBgC,KAAK,EAAElC,SAAS,CAACkB,SAAV,CAAoB,CAAClB,SAAS,CAACa,MAAX,EAAmBb,SAAS,CAACmB,MAA7B,CAApB,CAlBS;EAmBhBgB,gBAAgB,EAAEnC,SAAS,CAACa;AAnBZ,CAAlB;AAkDA,eAAeD,SAAf"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@value colors: "../../variables/colors.css";
|
|
2
|
+
@value dark from colors;
|
|
3
|
+
@value cm_grey_400 from colors;
|
|
4
|
+
@value cm_grey_450 from colors;
|
|
5
|
+
@value white from colors;
|
|
6
|
+
|
|
7
|
+
.wrapper {
|
|
8
|
+
margin: 10px 0;
|
|
9
|
+
position: relative;
|
|
10
|
+
font-family: 'Gilroy';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.formLabel {
|
|
14
|
+
font-size: 13px;
|
|
15
|
+
text-align: left;
|
|
16
|
+
/* temporal */
|
|
17
|
+
color: dark;
|
|
18
|
+
display: block;
|
|
19
|
+
margin-bottom: 7px;
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.textInput {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 59px;
|
|
26
|
+
background-color: white;
|
|
27
|
+
border: solid 1px cm_grey_450;
|
|
28
|
+
text-align: left;
|
|
29
|
+
margin-bottom: 26px;
|
|
30
|
+
|
|
31
|
+
appearance: none;
|
|
32
|
+
padding: 0 8px 0 15px;
|
|
33
|
+
border-radius: 0;
|
|
34
|
+
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
cursor: text;
|
|
37
|
+
|
|
38
|
+
color: inherit;
|
|
39
|
+
font: inherit;
|
|
40
|
+
overflow: visible;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.hintWrapper {
|
|
44
|
+
font-size: 12px;
|
|
45
|
+
margin-top: -20px;
|
|
46
|
+
margin-bottom: 20px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.hint {
|
|
50
|
+
color: cm_grey_400;
|
|
51
|
+
text-align: left;
|
|
52
|
+
font-style: italic;
|
|
53
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormTextInputProps } from './prop-types';
|
|
3
|
+
declare const FormTextInput: {
|
|
4
|
+
({ "aria-label": ariaLabel, autocomplete, "data-testid": dataTestid, disabled, hint, inputClassName, isRequired, label, maxlength, name, onChange, passwordRules, placeholder, type, value, equals, wrapperClassName }: FormTextInputProps): JSX.Element;
|
|
5
|
+
propTypes: {
|
|
6
|
+
'aria-label': import("prop-types").Requireable<string>;
|
|
7
|
+
autocomplete: import("prop-types").Requireable<string>;
|
|
8
|
+
'data-testid': import("prop-types").Requireable<string>;
|
|
9
|
+
disabled: import("prop-types").Requireable<boolean>;
|
|
10
|
+
equals: import("prop-types").Requireable<NonNullable<string | number | null | undefined>>;
|
|
11
|
+
hint: import("prop-types").Requireable<string>;
|
|
12
|
+
inputClassName: import("prop-types").Requireable<string>;
|
|
13
|
+
isRequired: import("prop-types").Requireable<boolean>;
|
|
14
|
+
label: import("prop-types").Requireable<string>;
|
|
15
|
+
maxlength: import("prop-types").Requireable<number>;
|
|
16
|
+
name: import("prop-types").Requireable<string>;
|
|
17
|
+
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
18
|
+
passwordRules: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
19
|
+
minLength: import("prop-types").Requireable<number>;
|
|
20
|
+
}>>;
|
|
21
|
+
placeholder: import("prop-types").Requireable<string>;
|
|
22
|
+
type: import("prop-types").Requireable<string>;
|
|
23
|
+
value: import("prop-types").Requireable<NonNullable<string | number | null | undefined>>;
|
|
24
|
+
wrapperClassName: import("prop-types").Requireable<string>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default FormTextInput;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/form-text-input/index.tsx"],"names":[],"mappings":";AAYA,OAAkB,EAAa,kBAAkB,EAAY,MAAM,cAAc,CAAC;AAqBlF,QAAA,MAAM,aAAa;4NAkBhB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;CAyEpB,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
|
|
10
|
+
var _getOr = _interopRequireDefault(require("lodash/fp/getOr"));
|
|
11
|
+
|
|
12
|
+
var _isEmpty = _interopRequireDefault(require("lodash/fp/isEmpty"));
|
|
13
|
+
|
|
14
|
+
var _isEqual = _interopRequireDefault(require("lodash/fp/isEqual"));
|
|
15
|
+
|
|
16
|
+
var _noop = _interopRequireDefault(require("lodash/fp/noop"));
|
|
17
|
+
|
|
18
|
+
var _size = _interopRequireDefault(require("lodash/fp/size"));
|
|
19
|
+
|
|
20
|
+
var _propTypes = _interopRequireWildcard(require("./prop-types"));
|
|
21
|
+
|
|
22
|
+
var _style = _interopRequireDefault(require("./style.css"));
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
31
|
+
|
|
32
|
+
const validate = (fieldValue, fieldEqualsValue) => {
|
|
33
|
+
return (0, _isEqual.default)(fieldValue, fieldEqualsValue);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const VALID_EMAIL_PATTERN = /[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
|
37
|
+
|
|
38
|
+
const validatePattern = (fieldValue, pattern) => {
|
|
39
|
+
return pattern.test(fieldValue);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const DEFAULT_MIN_LENGTH = 8;
|
|
43
|
+
|
|
44
|
+
const isEqualsDefined = equals => !(0, _isEmpty.default)(equals); // autocorrect="off"
|
|
45
|
+
// autocapitalize="none"
|
|
46
|
+
// ng-pattern="/[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const FormTextInput = ({
|
|
50
|
+
'aria-label': ariaLabel,
|
|
51
|
+
autocomplete,
|
|
52
|
+
'data-testid': dataTestid = 'form-text-input',
|
|
53
|
+
disabled,
|
|
54
|
+
hint,
|
|
55
|
+
inputClassName,
|
|
56
|
+
isRequired,
|
|
57
|
+
label,
|
|
58
|
+
maxlength = 150,
|
|
59
|
+
name,
|
|
60
|
+
onChange = _noop.default,
|
|
61
|
+
passwordRules,
|
|
62
|
+
placeholder,
|
|
63
|
+
type = 'default',
|
|
64
|
+
value,
|
|
65
|
+
equals,
|
|
66
|
+
wrapperClassName
|
|
67
|
+
}) => {
|
|
68
|
+
const [newValue, setNewValue] = (0, _react.useState)(value);
|
|
69
|
+
const [isValid, setIsValid] = (0, _react.useState)(true);
|
|
70
|
+
const isDefaultType = (0, _react.useMemo)(() => !type || type === _propTypes.TextInput.default, [type]);
|
|
71
|
+
const isPasswordInput = (0, _react.useMemo)(() => type === _propTypes.TextInput.password || type === _propTypes.TextInput.passwordConfirmation, [type]);
|
|
72
|
+
const isEmailInput = (0, _react.useMemo)(() => type === _propTypes.TextInput.email, [type]);
|
|
73
|
+
const handleInputChange = (0, _react.useCallback)(event => {
|
|
74
|
+
const newInput = event.target.value;
|
|
75
|
+
setNewValue(() => {
|
|
76
|
+
const isNewValueValid = !isEqualsDefined(equals) || validate(newInput, equals);
|
|
77
|
+
const validPattern = !isEmailInput || validatePattern(newInput, VALID_EMAIL_PATTERN);
|
|
78
|
+
const passwordLengthCheck = !isPasswordInput || (0, _size.default)(newInput) >= (0, _getOr.default)(DEFAULT_MIN_LENGTH, ['minLength'], passwordRules);
|
|
79
|
+
setIsValid(passwordLengthCheck && isNewValueValid && validPattern);
|
|
80
|
+
return newInput;
|
|
81
|
+
});
|
|
82
|
+
}, [equals, isEmailInput, isPasswordInput, passwordRules]);
|
|
83
|
+
(0, _react.useEffect)(() => {
|
|
84
|
+
onChange(newValue, isValid);
|
|
85
|
+
return;
|
|
86
|
+
}, [isValid, newValue, onChange]);
|
|
87
|
+
const fieldLabel = (0, _react.useMemo)(() => `${label} ${isRequired ? '*' : ''}`, [isRequired, label]);
|
|
88
|
+
const errorStyle = (0, _react.useMemo)(() => isValid ? undefined : {
|
|
89
|
+
border: '2px solid rgb(247, 63, 82)'
|
|
90
|
+
}, [isValid]);
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
92
|
+
className: (0, _classnames.default)(_style.default.wrapper, wrapperClassName)
|
|
93
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
94
|
+
className: _style.default.formLabel,
|
|
95
|
+
htmlFor: name
|
|
96
|
+
}, fieldLabel), /*#__PURE__*/_react.default.createElement("input", _extends({}, !isPasswordInput && !isEmailInput && {
|
|
97
|
+
maxLength: maxlength
|
|
98
|
+
}, isEmailInput && {
|
|
99
|
+
autoCapitalize: 'none'
|
|
100
|
+
}, isRequired && {
|
|
101
|
+
required: true
|
|
102
|
+
}, !isValid && {
|
|
103
|
+
'aria-invalid': true
|
|
104
|
+
}, {
|
|
105
|
+
type: isDefaultType ? 'text' : type,
|
|
106
|
+
"aria-label": ariaLabel,
|
|
107
|
+
autoComplete: isDefaultType ? 'on' : autocomplete,
|
|
108
|
+
autoCorrect: 'off',
|
|
109
|
+
className: (0, _classnames.default)(_style.default.textInput, inputClassName),
|
|
110
|
+
"data-testid": dataTestid,
|
|
111
|
+
disabled: disabled,
|
|
112
|
+
id: name,
|
|
113
|
+
name: name,
|
|
114
|
+
onInput: handleInputChange,
|
|
115
|
+
placeholder: placeholder,
|
|
116
|
+
value: value,
|
|
117
|
+
style: errorStyle
|
|
118
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
119
|
+
className: _style.default.hintWrapper
|
|
120
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
121
|
+
className: _style.default.hint
|
|
122
|
+
}, hint)));
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
FormTextInput.propTypes = process.env.NODE_ENV !== "production" ? _propTypes.default : {};
|
|
126
|
+
var _default = FormTextInput;
|
|
127
|
+
exports.default = _default;
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["validate","fieldValue","fieldEqualsValue","isEqual","VALID_EMAIL_PATTERN","validatePattern","pattern","test","DEFAULT_MIN_LENGTH","isEqualsDefined","equals","isEmpty","FormTextInput","ariaLabel","autocomplete","dataTestid","disabled","hint","inputClassName","isRequired","label","maxlength","name","onChange","noop","passwordRules","placeholder","type","value","wrapperClassName","newValue","setNewValue","useState","isValid","setIsValid","isDefaultType","useMemo","TextInput","default","isPasswordInput","password","passwordConfirmation","isEmailInput","email","handleInputChange","useCallback","event","newInput","target","isNewValueValid","validPattern","passwordLengthCheck","size","getOr","useEffect","fieldLabel","errorStyle","undefined","border","classnames","style","wrapper","formLabel","maxLength","autoCapitalize","required","textInput","hintWrapper","propTypes"],"sources":["../../../src/atom/form-text-input/index.tsx"],"sourcesContent":["import React, {useCallback, useMemo, useState, useEffect, FormEvent} from 'react';\nimport classnames from 'classnames';\nimport getOr from 'lodash/fp/getOr';\nimport isEmpty from 'lodash/fp/isEmpty';\nimport isEqual from 'lodash/fp/isEqual';\nimport noop from 'lodash/fp/noop';\nimport size from 'lodash/fp/size';\n// import {\n// NovaCompositionNavigationArrowRight as ArrowRight,\n// NovaCompositionCoorpacademyInformationIcon as InformationIcon\n// } from '@coorpacademy/nova-icons';\n// import Provider, {GetTranslateFromContext} from '../provider';\nimport propTypes, {FieldValue, FormTextInputProps, TextInput} from './prop-types';\nimport style from './style.css';\n\nconst validate = (fieldValue: FieldValue, fieldEqualsValue: FieldValue) => {\n return isEqual(fieldValue, fieldEqualsValue);\n};\n\nconst VALID_EMAIL_PATTERN =\n /[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;\n\nconst validatePattern = (fieldValue: string, pattern: RegExp) => {\n return pattern.test(fieldValue);\n};\n\nconst DEFAULT_MIN_LENGTH = 8;\n\nconst isEqualsDefined = (equals: FieldValue | undefined): equals is FieldValue => !isEmpty(equals);\n\n// autocorrect=\"off\"\n// autocapitalize=\"none\"\n// ng-pattern=\"/[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/\"\nconst FormTextInput = ({\n 'aria-label': ariaLabel,\n autocomplete,\n 'data-testid': dataTestid = 'form-text-input',\n disabled,\n hint,\n inputClassName,\n isRequired,\n label,\n maxlength = 150,\n name,\n onChange = noop,\n passwordRules,\n placeholder,\n type = 'default',\n value,\n equals,\n wrapperClassName\n}: FormTextInputProps) => {\n const [newValue, setNewValue] = useState<FieldValue>(value);\n\n const [isValid, setIsValid] = useState<boolean>(true);\n\n const isDefaultType = useMemo(() => !type || type === TextInput.default, [type]);\n\n const isPasswordInput = useMemo(\n () => type === TextInput.password || type === TextInput.passwordConfirmation,\n [type]\n );\n\n const isEmailInput = useMemo(() => type === TextInput.email, [type]);\n\n const handleInputChange = useCallback(\n (event: FormEvent<HTMLInputElement>) => {\n const newInput: FieldValue = (event.target as HTMLInputElement).value;\n setNewValue(() => {\n const isNewValueValid = !isEqualsDefined(equals) || validate(newInput, equals);\n const validPattern = !isEmailInput || validatePattern(newInput, VALID_EMAIL_PATTERN);\n const passwordLengthCheck =\n !isPasswordInput ||\n size(newInput) >= getOr(DEFAULT_MIN_LENGTH, ['minLength'], passwordRules);\n\n setIsValid(passwordLengthCheck && isNewValueValid && validPattern);\n\n return newInput;\n });\n },\n [equals, isEmailInput, isPasswordInput, passwordRules]\n );\n\n useEffect(() => {\n onChange(newValue, isValid);\n return;\n }, [isValid, newValue, onChange]);\n\n const fieldLabel = useMemo(() => `${label} ${isRequired ? '*' : ''}`, [isRequired, label]);\n\n const errorStyle = useMemo(\n () => (isValid ? undefined : {border: '2px solid rgb(247, 63, 82)'}),\n [isValid]\n );\n\n return (\n <div className={classnames(style.wrapper, wrapperClassName)}>\n <label className={style.formLabel} htmlFor={name}>\n {fieldLabel}\n </label>\n <input\n {...(!isPasswordInput && !isEmailInput && {maxLength: maxlength})}\n {...(isEmailInput && {autoCapitalize: 'none'})}\n {...(isRequired && {required: true})}\n {...(!isValid && {'aria-invalid': true})}\n type={isDefaultType ? 'text' : type}\n aria-label={ariaLabel}\n autoComplete={isDefaultType ? 'on' : autocomplete}\n autoCorrect={'off'}\n className={classnames(style.textInput, inputClassName)}\n data-testid={dataTestid}\n disabled={disabled}\n id={name}\n name={name}\n onInput={handleInputChange}\n placeholder={placeholder}\n value={value}\n style={errorStyle}\n />\n <div className={style.hintWrapper}>\n <span className={style.hint}>{hint}</span>\n </div>\n </div>\n );\n};\n\nFormTextInput.propTypes = propTypes;\n\nexport default FormTextInput;\n"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;;;;;;;;;AAEA,MAAMA,QAAQ,GAAG,CAACC,UAAD,EAAyBC,gBAAzB,KAA0D;EACzE,OAAO,IAAAC,gBAAA,EAAQF,UAAR,EAAoBC,gBAApB,CAAP;AACD,CAFD;;AAIA,MAAME,mBAAmB,GACvB,mIADF;;AAGA,MAAMC,eAAe,GAAG,CAACJ,UAAD,EAAqBK,OAArB,KAAyC;EAC/D,OAAOA,OAAO,CAACC,IAAR,CAAaN,UAAb,CAAP;AACD,CAFD;;AAIA,MAAMO,kBAAkB,GAAG,CAA3B;;AAEA,MAAMC,eAAe,GAAIC,MAAD,IAA0D,CAAC,IAAAC,gBAAA,EAAQD,MAAR,CAAnF,C,CAEA;AACA;AACA;;;AACA,MAAME,aAAa,GAAG,CAAC;EACrB,cAAcC,SADO;EAErBC,YAFqB;EAGrB,eAAeC,UAAU,GAAG,iBAHP;EAIrBC,QAJqB;EAKrBC,IALqB;EAMrBC,cANqB;EAOrBC,UAPqB;EAQrBC,KARqB;EASrBC,SAAS,GAAG,GATS;EAUrBC,IAVqB;EAWrBC,QAAQ,GAAGC,aAXU;EAYrBC,aAZqB;EAarBC,WAbqB;EAcrBC,IAAI,GAAG,SAdc;EAerBC,KAfqB;EAgBrBlB,MAhBqB;EAiBrBmB;AAjBqB,CAAD,KAkBI;EACxB,MAAM,CAACC,QAAD,EAAWC,WAAX,IAA0B,IAAAC,eAAA,EAAqB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IAeE,WAAW,EAAElB,WAff;IAgBE,KAAK,EAAEE,KAhBT;IAiBE,KAAK,EAAE4B;EAjBT,GAJF,eAuBE;IAAK,SAAS,EAAEI,cAAA,CAAMO;EAAtB,gBACE;IAAM,SAAS,EAAEP,cAAA,CAAM3C;EAAvB,GAA8BA,IAA9B,CADF,CAvBF,CADF;AA6BD,CA3FD;;AA6FAL,aAAa,CAACwD,SAAd,2CAA0BA,kBAA1B;eAEexD,a"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
export declare const TextInput: {
|
|
3
|
+
readonly country: "country";
|
|
4
|
+
readonly email: "email";
|
|
5
|
+
readonly firstName: "firstName";
|
|
6
|
+
readonly lastName: "lastName";
|
|
7
|
+
readonly language: "language";
|
|
8
|
+
readonly login: "login";
|
|
9
|
+
readonly password: "password";
|
|
10
|
+
readonly passwordConfirmation: "passwordConfirmation";
|
|
11
|
+
readonly default: "default";
|
|
12
|
+
};
|
|
13
|
+
declare const propTypes: {
|
|
14
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
15
|
+
autocomplete: PropTypes.Requireable<string>;
|
|
16
|
+
'data-testid': PropTypes.Requireable<string>;
|
|
17
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
18
|
+
equals: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
19
|
+
hint: PropTypes.Requireable<string>;
|
|
20
|
+
inputClassName: PropTypes.Requireable<string>;
|
|
21
|
+
isRequired: PropTypes.Requireable<boolean>;
|
|
22
|
+
label: PropTypes.Requireable<string>;
|
|
23
|
+
maxlength: PropTypes.Requireable<number>;
|
|
24
|
+
name: PropTypes.Requireable<string>;
|
|
25
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
26
|
+
passwordRules: PropTypes.Requireable<PropTypes.InferProps<{
|
|
27
|
+
minLength: PropTypes.Requireable<number>;
|
|
28
|
+
}>>;
|
|
29
|
+
placeholder: PropTypes.Requireable<string>;
|
|
30
|
+
type: PropTypes.Requireable<string>;
|
|
31
|
+
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
32
|
+
wrapperClassName: PropTypes.Requireable<string>;
|
|
33
|
+
};
|
|
34
|
+
declare type TextInputType = keyof typeof TextInput;
|
|
35
|
+
export declare type FieldValue = string | number;
|
|
36
|
+
export declare type PasswordRulesConfig = {
|
|
37
|
+
minLength: number;
|
|
38
|
+
};
|
|
39
|
+
export declare type FormTextInputProps = {
|
|
40
|
+
'aria-label'?: string;
|
|
41
|
+
autocomplete?: string;
|
|
42
|
+
'data-testid'?: string;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
equals?: FieldValue;
|
|
45
|
+
hint?: string;
|
|
46
|
+
inputClassName?: string | null;
|
|
47
|
+
isRequired?: boolean;
|
|
48
|
+
label: string;
|
|
49
|
+
maxlength?: number;
|
|
50
|
+
name: string;
|
|
51
|
+
onChange?: (value: FieldValue, isValid?: boolean) => void;
|
|
52
|
+
passwordRules?: PasswordRulesConfig;
|
|
53
|
+
placeholder?: string;
|
|
54
|
+
type?: TextInputType;
|
|
55
|
+
value: FieldValue;
|
|
56
|
+
wrapperClassName?: string | null;
|
|
57
|
+
};
|
|
58
|
+
export default propTypes;
|
|
59
|
+
//# sourceMappingURL=prop-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-types.d.ts","sourceRoot":"","sources":["../../../src/atom/form-text-input/prop-types.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAGnC,eAAO,MAAM,SAAS;;;;;;;;;;CAUZ,CAAC;AAEX,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBd,CAAC;AAEF,aAAK,aAAa,GAAG,MAAM,OAAO,SAAS,CAAC;AAE5C,oBAAY,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC,oBAAY,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = exports.TextInput = void 0;
|
|
5
|
+
|
|
6
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
|
+
|
|
8
|
+
var _keys = _interopRequireDefault(require("lodash/fp/keys"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const TextInput = {
|
|
13
|
+
country: 'country',
|
|
14
|
+
email: 'email',
|
|
15
|
+
firstName: 'firstName',
|
|
16
|
+
lastName: 'lastName',
|
|
17
|
+
language: 'language',
|
|
18
|
+
login: 'login',
|
|
19
|
+
password: 'password',
|
|
20
|
+
passwordConfirmation: 'passwordConfirmation',
|
|
21
|
+
default: 'default'
|
|
22
|
+
};
|
|
23
|
+
exports.TextInput = TextInput;
|
|
24
|
+
const propTypes = {
|
|
25
|
+
'aria-label': _propTypes.default.string,
|
|
26
|
+
autocomplete: _propTypes.default.string,
|
|
27
|
+
'data-testid': _propTypes.default.string,
|
|
28
|
+
disabled: _propTypes.default.bool,
|
|
29
|
+
equals: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
30
|
+
hint: _propTypes.default.string,
|
|
31
|
+
inputClassName: _propTypes.default.string,
|
|
32
|
+
isRequired: _propTypes.default.bool,
|
|
33
|
+
label: _propTypes.default.string,
|
|
34
|
+
maxlength: _propTypes.default.number,
|
|
35
|
+
name: _propTypes.default.string,
|
|
36
|
+
onChange: _propTypes.default.func,
|
|
37
|
+
passwordRules: _propTypes.default.shape({
|
|
38
|
+
minLength: _propTypes.default.number
|
|
39
|
+
}),
|
|
40
|
+
placeholder: _propTypes.default.string,
|
|
41
|
+
type: _propTypes.default.oneOf((0, _keys.default)(TextInput)),
|
|
42
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
43
|
+
wrapperClassName: _propTypes.default.string
|
|
44
|
+
};
|
|
45
|
+
var _default = propTypes;
|
|
46
|
+
exports.default = _default;
|
|
47
|
+
//# sourceMappingURL=prop-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-types.js","names":["TextInput","country","email","firstName","lastName","language","login","password","passwordConfirmation","default","propTypes","PropTypes","string","autocomplete","disabled","bool","equals","oneOfType","number","hint","inputClassName","isRequired","label","maxlength","name","onChange","func","passwordRules","shape","minLength","placeholder","type","oneOf","keys","value","wrapperClassName"],"sources":["../../../src/atom/form-text-input/prop-types.ts"],"sourcesContent":["import PropTypes from 'prop-types';\nimport keys from 'lodash/fp/keys';\n\nexport const TextInput = {\n country: 'country',\n email: 'email',\n firstName: 'firstName',\n lastName: 'lastName',\n language: 'language',\n login: 'login',\n password: 'password',\n passwordConfirmation: 'passwordConfirmation',\n default: 'default'\n} as const;\n\nconst propTypes = {\n 'aria-label': PropTypes.string,\n autocomplete: PropTypes.string,\n 'data-testid': PropTypes.string,\n disabled: PropTypes.bool,\n equals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n hint: PropTypes.string,\n inputClassName: PropTypes.string,\n isRequired: PropTypes.bool,\n label: PropTypes.string,\n maxlength: PropTypes.number,\n name: PropTypes.string,\n onChange: PropTypes.func,\n passwordRules: PropTypes.shape({\n minLength: PropTypes.number\n }),\n placeholder: PropTypes.string,\n type: PropTypes.oneOf(keys(TextInput)),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n wrapperClassName: PropTypes.string\n};\n\ntype TextInputType = keyof typeof TextInput;\n\nexport type FieldValue = string | number;\n\nexport type PasswordRulesConfig = {\n minLength: number;\n};\n\nexport type FormTextInputProps = {\n 'aria-label'?: string;\n autocomplete?: string;\n 'data-testid'?: string;\n disabled?: boolean;\n equals?: FieldValue;\n hint?: string;\n inputClassName?: string | null;\n isRequired?: boolean;\n label: string;\n maxlength?: number;\n name: string;\n onChange?: (value: FieldValue, isValid?: boolean) => void;\n passwordRules?: PasswordRulesConfig;\n placeholder?: string;\n type?: TextInputType;\n value: FieldValue;\n wrapperClassName?: string | null;\n};\n\nexport default propTypes;\n"],"mappings":";;;;;AAAA;;AACA;;;;AAEO,MAAMA,SAAS,GAAG;EACvBC,OAAO,EAAE,SADc;EAEvBC,KAAK,EAAE,OAFgB;EAGvBC,SAAS,EAAE,WAHY;EAIvBC,QAAQ,EAAE,UAJa;EAKvBC,QAAQ,EAAE,UALa;EAMvBC,KAAK,EAAE,OANgB;EAOvBC,QAAQ,EAAE,UAPa;EAQvBC,oBAAoB,EAAE,sBARC;EASvBC,OAAO,EAAE;AATc,CAAlB;;AAYP,MAAMC,SAAS,GAAG;EAChB,cAAcC,kBAAA,CAAUC,MADR;EAEhBC,YAAY,EAAEF,kBAAA,CAAUC,MAFR;EAGhB,eAAeD,kBAAA,CAAUC,MAHT;EAIhBE,QAAQ,EAAEH,kBAAA,CAAUI,IAJJ;EAKhBC,MAAM,EAAEL,kBAAA,CAAUM,SAAV,CAAoB,CAACN,kBAAA,CAAUC,MAAX,EAAmBD,kBAAA,CAAUO,MAA7B,CAApB,CALQ;EAMhBC,IAAI,EAAER,kBAAA,CAAUC,MANA;EAOhBQ,cAAc,EAAET,kBAAA,CAAUC,MAPV;EAQhBS,UAAU,EAAEV,kBAAA,CAAUI,IARN;EAShBO,KAAK,EAAEX,kBAAA,CAAUC,MATD;EAUhBW,SAAS,EAAEZ,kBAAA,CAAUO,MAVL;EAWhBM,IAAI,EAAEb,kBAAA,CAAUC,MAXA;EAYhBa,QAAQ,EAAEd,kBAAA,CAAUe,IAZJ;EAahBC,aAAa,EAAEhB,kBAAA,CAAUiB,KAAV,CAAgB;IAC7BC,SAAS,EAAElB,kBAAA,CAAUO;EADQ,CAAhB,CAbC;EAgBhBY,WAAW,EAAEnB,kBAAA,CAAUC,MAhBP;EAiBhBmB,IAAI,EAAEpB,kBAAA,CAAUqB,KAAV,CAAgB,IAAAC,aAAA,EAAKjC,SAAL,CAAhB,CAjBU;EAkBhBkC,KAAK,EAAEvB,kBAAA,CAAUM,SAAV,CAAoB,CAACN,kBAAA,CAAUC,MAAX,EAAmBD,kBAAA,CAAUO,MAA7B,CAApB,CAlBS;EAmBhBiB,gBAAgB,EAAExB,kBAAA,CAAUC;AAnBZ,CAAlB;eAkDeF,S"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@value colors: "../../variables/colors.css";
|
|
2
|
+
@value dark from colors;
|
|
3
|
+
@value cm_grey_400 from colors;
|
|
4
|
+
@value cm_grey_450 from colors;
|
|
5
|
+
@value white from colors;
|
|
6
|
+
|
|
7
|
+
.wrapper {
|
|
8
|
+
margin: 10px 0;
|
|
9
|
+
position: relative;
|
|
10
|
+
font-family: 'Gilroy';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.formLabel {
|
|
14
|
+
font-size: 13px;
|
|
15
|
+
text-align: left;
|
|
16
|
+
/* temporal */
|
|
17
|
+
color: dark;
|
|
18
|
+
display: block;
|
|
19
|
+
margin-bottom: 7px;
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.textInput {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 59px;
|
|
26
|
+
background-color: white;
|
|
27
|
+
border: solid 1px cm_grey_450;
|
|
28
|
+
text-align: left;
|
|
29
|
+
margin-bottom: 26px;
|
|
30
|
+
|
|
31
|
+
appearance: none;
|
|
32
|
+
padding: 0 8px 0 15px;
|
|
33
|
+
border-radius: 0;
|
|
34
|
+
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
cursor: text;
|
|
37
|
+
|
|
38
|
+
color: inherit;
|
|
39
|
+
font: inherit;
|
|
40
|
+
overflow: visible;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.hintWrapper {
|
|
44
|
+
font-size: 12px;
|
|
45
|
+
margin-top: -20px;
|
|
46
|
+
margin-bottom: 20px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.hint {
|
|
50
|
+
color: cm_grey_400;
|
|
51
|
+
text-align: left;
|
|
52
|
+
font-style: italic;
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/components",
|
|
3
|
-
"version": "11.13.4",
|
|
3
|
+
"version": "11.13.6-alpha.4+04c04f1af",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -166,5 +166,5 @@
|
|
|
166
166
|
"last 2 versions",
|
|
167
167
|
"IE 11"
|
|
168
168
|
],
|
|
169
|
-
"gitHead": "
|
|
169
|
+
"gitHead": "04c04f1afd7592264895a6ff26be7300e0bc64b4"
|
|
170
170
|
}
|
package/locales/.mtslconfig.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"ignore_dirs":[]}
|