@itcase/forms 1.0.24 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.form-dropzone {
|
|
2
|
+
flex-direction: column;
|
|
2
3
|
&__dropzone {
|
|
3
4
|
width: 100%;
|
|
4
5
|
box-shadow: none;
|
|
@@ -6,10 +7,9 @@
|
|
|
6
7
|
outline: 0;
|
|
7
8
|
@mixin easing easeOutQuart, all, 0.2s;
|
|
8
9
|
&-wrapper {
|
|
9
|
-
display:
|
|
10
|
-
gap:
|
|
11
|
-
|
|
12
|
-
flex-flow: row wrap;
|
|
10
|
+
display: grid;
|
|
11
|
+
gap: 16px;
|
|
12
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
13
13
|
}
|
|
14
14
|
&_size {
|
|
15
15
|
@each $size in normal, compact {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
align-content: center;
|
|
30
30
|
align-items: center;
|
|
31
31
|
cursor: pointer;
|
|
32
|
+
grid-column: span 3;
|
|
32
33
|
&-title {
|
|
33
34
|
padding: 0 0 8px 0;
|
|
34
35
|
margin: 0;
|
|
@@ -48,13 +49,20 @@
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
&__thumb {
|
|
51
|
-
flex: 30%;
|
|
52
52
|
display: grid;
|
|
53
53
|
column-gap: 8px;
|
|
54
54
|
grid-template-columns: min-content 1fr;
|
|
55
55
|
grid-template-rows: auto 1fr;
|
|
56
|
-
margin: 0 0 16px 0;
|
|
57
56
|
padding: 8px 16px 8px 8px;
|
|
57
|
+
position: relative;
|
|
58
|
+
&-loader {
|
|
59
|
+
position: absolute;
|
|
60
|
+
left: 0;
|
|
61
|
+
top: 0;
|
|
62
|
+
width: 100%;
|
|
63
|
+
height: 100%;
|
|
64
|
+
display: flex;
|
|
65
|
+
}
|
|
58
66
|
&-image {
|
|
59
67
|
width: 160px;
|
|
60
68
|
height: 160px;
|
package/dist/itcase-forms.cjs.js
CHANGED
|
@@ -12,12 +12,14 @@ var Text = require('@itcase/ui/components/Text');
|
|
|
12
12
|
var useDeviceTargetClass = require('@itcase/ui/hooks/useDeviceTargetClass');
|
|
13
13
|
var useStyles = require('@itcase/ui/hooks/useStyles');
|
|
14
14
|
var Choice = require('@itcase/ui/components/Choice');
|
|
15
|
+
var Code = require('@itcase/ui/components/Code');
|
|
15
16
|
var DatePicker = require('@itcase/ui/components/DatePicker');
|
|
16
17
|
var axios = require('axios');
|
|
17
18
|
var reactDropzone = require('react-dropzone');
|
|
18
19
|
var fileSelector = require('file-selector');
|
|
19
20
|
var castArray = require('lodash/castArray');
|
|
20
21
|
var common = require('@itcase/common');
|
|
22
|
+
var Loader = require('@itcase/ui/components/Loader');
|
|
21
23
|
var Title = require('@itcase/ui/components/Title');
|
|
22
24
|
var Input = require('@itcase/ui/components/Input');
|
|
23
25
|
var Icon = require('@itcase/ui/components/Icon');
|
|
@@ -28,7 +30,6 @@ var Switch = require('@itcase/ui/components/Switch');
|
|
|
28
30
|
var Textarea = require('@itcase/ui/components/Textarea');
|
|
29
31
|
var Button = require('@itcase/ui/components/Button');
|
|
30
32
|
var Group$1 = require('@itcase/ui/components/Group');
|
|
31
|
-
var Loader = require('@itcase/ui/components/Loader');
|
|
32
33
|
var Notification = require('@itcase/ui/components/Notification');
|
|
33
34
|
var createDecorator = require('final-form-focus');
|
|
34
35
|
|
|
@@ -814,6 +815,22 @@ var ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceField(
|
|
|
814
815
|
}, function (_ref) {
|
|
815
816
|
var input = _ref.input,
|
|
816
817
|
meta = _ref.meta;
|
|
818
|
+
var activeOption = React.useMemo(function () {
|
|
819
|
+
var emptyOption = {
|
|
820
|
+
value: null,
|
|
821
|
+
label: null
|
|
822
|
+
};
|
|
823
|
+
if (input.value) {
|
|
824
|
+
var currentOption = options.find(function (option) {
|
|
825
|
+
return option.value === input.value;
|
|
826
|
+
});
|
|
827
|
+
return currentOption || emptyOption;
|
|
828
|
+
}
|
|
829
|
+
return emptyOption;
|
|
830
|
+
}, [input.value]);
|
|
831
|
+
var setActiveSegment = React.useCallback(function (option) {
|
|
832
|
+
change(name, option.value);
|
|
833
|
+
}, [change]);
|
|
817
834
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
818
835
|
className: clsx__default.default('form-field_type_choice', 'form__item_type_choice', classNameGroupItem),
|
|
819
836
|
inputName: input.name,
|
|
@@ -836,7 +853,8 @@ var ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceField(
|
|
|
836
853
|
isMultiple: isMultiple,
|
|
837
854
|
isRequired: isRequired,
|
|
838
855
|
placeholder: placeholder,
|
|
839
|
-
|
|
856
|
+
active: activeOption,
|
|
857
|
+
setActiveSegment: setActiveSegment
|
|
840
858
|
}, inputProps)));
|
|
841
859
|
});
|
|
842
860
|
});
|
|
@@ -894,6 +912,53 @@ CustomField.propTypes = {
|
|
|
894
912
|
inputProps: PropTypes__default.default.object
|
|
895
913
|
};
|
|
896
914
|
|
|
915
|
+
var CodeField = /*#__PURE__*/React__default.default.memo(function CodeField(props) {
|
|
916
|
+
var isRequired = props.isRequired,
|
|
917
|
+
name = props.name,
|
|
918
|
+
fieldProps = props.fieldProps,
|
|
919
|
+
inputProps = props.inputProps,
|
|
920
|
+
classNameGroupItem = props.classNameGroupItem,
|
|
921
|
+
hideMessage = props.hideMessage;
|
|
922
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
923
|
+
name: name
|
|
924
|
+
}, function (_ref) {
|
|
925
|
+
var input = _ref.input,
|
|
926
|
+
meta = _ref.meta;
|
|
927
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
928
|
+
className: clsx__default.default('form-field_type_code', 'form__item_type_code', classNameGroupItem),
|
|
929
|
+
fieldClassName: 'form-code',
|
|
930
|
+
inputName: input.name,
|
|
931
|
+
inputValue: input.value,
|
|
932
|
+
isRequired: isRequired,
|
|
933
|
+
metaActive: meta.active,
|
|
934
|
+
metaError: meta.error,
|
|
935
|
+
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
936
|
+
metaSubmitError: meta.submitError,
|
|
937
|
+
metaSubmitFailed: meta.submitFailed,
|
|
938
|
+
metaTouched: meta.touched,
|
|
939
|
+
metaValid: meta.valid,
|
|
940
|
+
hideMessage: hideMessage
|
|
941
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Code.Code, Object.assign({
|
|
942
|
+
autoComplete: "nope",
|
|
943
|
+
name: input.name,
|
|
944
|
+
value: input.value,
|
|
945
|
+
onBlur: input.onBlur,
|
|
946
|
+
onChange: input.onChange,
|
|
947
|
+
onFocus: input.onFocus
|
|
948
|
+
}, inputProps)));
|
|
949
|
+
});
|
|
950
|
+
});
|
|
951
|
+
CodeField.defaultProps = {
|
|
952
|
+
inputProps: {},
|
|
953
|
+
fieldProps: {}
|
|
954
|
+
};
|
|
955
|
+
CodeField.propTypes = {
|
|
956
|
+
name: PropTypes__default.default.string.isRequired,
|
|
957
|
+
isRequired: PropTypes__default.default.bool,
|
|
958
|
+
fieldProps: PropTypes__default.default.object,
|
|
959
|
+
inputProps: PropTypes__default.default.object
|
|
960
|
+
};
|
|
961
|
+
|
|
897
962
|
function DatePickerField(props) {
|
|
898
963
|
var isRequired = props.isRequired,
|
|
899
964
|
fieldProps = props.fieldProps,
|
|
@@ -1139,6 +1204,9 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
|
|
|
1139
1204
|
hintDescriptionTextColor = props.hintDescriptionTextColor,
|
|
1140
1205
|
hintDescriptionTextWrap = props.hintDescriptionTextWrap,
|
|
1141
1206
|
hintDescriptionTextWeight = props.hintDescriptionTextWeight,
|
|
1207
|
+
errorMessageTextSize = props.errorMessageTextSize,
|
|
1208
|
+
errorMessageTextWeight = props.errorMessageTextWeight,
|
|
1209
|
+
errorMessageTextColor = props.errorMessageTextColor,
|
|
1142
1210
|
inputValue = props.inputValue,
|
|
1143
1211
|
removeThumbText = props.removeThumbText,
|
|
1144
1212
|
hintTitle = props.hintTitle,
|
|
@@ -1306,20 +1374,6 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
|
|
|
1306
1374
|
};
|
|
1307
1375
|
}, []); // eslint-disable-line
|
|
1308
1376
|
|
|
1309
|
-
// prettier-ignore
|
|
1310
|
-
/*
|
|
1311
|
-
const itemClass = useMemo(
|
|
1312
|
-
() => clsx(
|
|
1313
|
-
'form__item',
|
|
1314
|
-
'form__item_type_dropzone',
|
|
1315
|
-
// itemClassName,
|
|
1316
|
-
// metaError || fileError && 'form__item_state_error',
|
|
1317
|
-
files.length && 'form__item_state_success'
|
|
1318
|
-
),
|
|
1319
|
-
[files.length]
|
|
1320
|
-
)
|
|
1321
|
-
*/
|
|
1322
|
-
|
|
1323
1377
|
var fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1324
1378
|
prefix: 'fill_',
|
|
1325
1379
|
propsKey: 'fill'
|
|
@@ -1374,7 +1428,9 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
|
|
|
1374
1428
|
return /*#__PURE__*/React__default.default.createElement("aside", {
|
|
1375
1429
|
className: clsx__default.default('form-dropzone__thumb', fillClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
|
|
1376
1430
|
key: "" + (file.id || file.name + "_" + i || 'i' + i)
|
|
1377
|
-
},
|
|
1431
|
+
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
1432
|
+
className: "form-dropzone__thumb-loading"
|
|
1433
|
+
}, fileIsLoading && (loadingText || 'Loading...')), isPreviews && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1378
1434
|
className: "form-dropzone__thumb-image"
|
|
1379
1435
|
}, /*#__PURE__*/React__default.default.createElement("img", {
|
|
1380
1436
|
className: "form-dropzone__thumb-image-inner",
|
|
@@ -1392,8 +1448,14 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
|
|
|
1392
1448
|
textWeight: thumbNameTextWeight,
|
|
1393
1449
|
className: "form-dropzone__thumb-name-inner"
|
|
1394
1450
|
}, file.name)), fileIsLoading && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1395
|
-
className: "form-dropzone__thumb-
|
|
1396
|
-
},
|
|
1451
|
+
className: "form-dropzone__thumb-loader"
|
|
1452
|
+
}, /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
1453
|
+
fill: "surfacePrimary",
|
|
1454
|
+
height: "fill",
|
|
1455
|
+
itemFill: "surfaceItemAccent",
|
|
1456
|
+
set: "simple",
|
|
1457
|
+
width: "fill"
|
|
1458
|
+
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
1397
1459
|
className: "form-dropzone__thumb-remove",
|
|
1398
1460
|
onClick: function onClick(event) {
|
|
1399
1461
|
return removeFile(event, i);
|
|
@@ -1434,8 +1496,13 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
|
|
|
1434
1496
|
textWeight: hintDescriptionTextWeight,
|
|
1435
1497
|
className: "form-dropzone__hint-text"
|
|
1436
1498
|
}, hintDescription)))), fileError && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1437
|
-
className: "
|
|
1438
|
-
},
|
|
1499
|
+
className: "form-field__message"
|
|
1500
|
+
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1501
|
+
className: "form-field__message-item form-field__message-item_type_message",
|
|
1502
|
+
size: errorMessageTextSize,
|
|
1503
|
+
textWeight: errorMessageTextWeight,
|
|
1504
|
+
textColor: errorMessageTextColor
|
|
1505
|
+
}, fileError)));
|
|
1439
1506
|
});
|
|
1440
1507
|
FileInputDropzone.propTypes = {
|
|
1441
1508
|
dropzoneProps: PropTypes__default.default.object,
|
|
@@ -1480,6 +1547,9 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
|
|
|
1480
1547
|
removeThumbTextColor = props.removeThumbTextColor,
|
|
1481
1548
|
removeThumbTextWeight = props.removeThumbTextWeight,
|
|
1482
1549
|
hintTitle = props.hintTitle,
|
|
1550
|
+
errorMessageTextSize = props.errorMessageTextSize,
|
|
1551
|
+
errorMessageTextWeight = props.errorMessageTextWeight,
|
|
1552
|
+
errorMessageTextColor = props.errorMessageTextColor,
|
|
1483
1553
|
fieldProps = props.fieldProps,
|
|
1484
1554
|
hintTitleTextSize = props.hintTitleTextSize,
|
|
1485
1555
|
hintTitleTextColor = props.hintTitleTextColor,
|
|
@@ -1553,6 +1623,9 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
|
|
|
1553
1623
|
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
1554
1624
|
hintDescriptionTextWrap: hintDescriptionTextWrap,
|
|
1555
1625
|
hintDescriptionTextWeight: hintDescriptionTextWeight,
|
|
1626
|
+
errorMessageTextSize: errorMessageTextSize,
|
|
1627
|
+
errorMessageWeight: errorMessageTextWeight,
|
|
1628
|
+
errorMessageTextColor: errorMessageTextColor,
|
|
1556
1629
|
isPreviews: isPreviews,
|
|
1557
1630
|
shape: shape,
|
|
1558
1631
|
isShowFilename: isShowFilename,
|
|
@@ -1564,6 +1637,10 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
|
|
|
1564
1637
|
}));
|
|
1565
1638
|
});
|
|
1566
1639
|
});
|
|
1640
|
+
FileInput.defaultProps = {
|
|
1641
|
+
errorMessageTextSize: 's',
|
|
1642
|
+
errorMessageTextColor: 'errorTextPrimary'
|
|
1643
|
+
};
|
|
1567
1644
|
FileInput.propTypes = {
|
|
1568
1645
|
name: PropTypes__default.default.string.isRequired,
|
|
1569
1646
|
className: PropTypes__default.default.string,
|
|
@@ -2348,6 +2425,7 @@ var formTypes = {
|
|
|
2348
2425
|
checkbox: 'checkbox',
|
|
2349
2426
|
custom: 'custom',
|
|
2350
2427
|
choice: 'choice',
|
|
2428
|
+
code: 'code',
|
|
2351
2429
|
datePicker: 'datePicker',
|
|
2352
2430
|
dateRangePicker: 'dateRangePicker',
|
|
2353
2431
|
fileInput: 'fileInput',
|
|
@@ -2373,6 +2451,12 @@ function generateField(field, config, props) {
|
|
|
2373
2451
|
key: config.key
|
|
2374
2452
|
}, field, props));
|
|
2375
2453
|
}
|
|
2454
|
+
case formTypes.code:
|
|
2455
|
+
{
|
|
2456
|
+
return /*#__PURE__*/React__default.default.createElement(CodeField, Object.assign({
|
|
2457
|
+
key: config.key
|
|
2458
|
+
}, field, props));
|
|
2459
|
+
}
|
|
2376
2460
|
case formTypes["switch"]:
|
|
2377
2461
|
{
|
|
2378
2462
|
return /*#__PURE__*/React__default.default.createElement(SwitchField, Object.assign({
|
|
@@ -2718,6 +2802,7 @@ Object.defineProperty(exports, 'useFormState', {
|
|
|
2718
2802
|
});
|
|
2719
2803
|
exports.Checkbox = CheckboxField;
|
|
2720
2804
|
exports.ChoiceField = ChoiceField;
|
|
2805
|
+
exports.CodeField = CodeField;
|
|
2721
2806
|
exports.CustomField = CustomField;
|
|
2722
2807
|
exports.DatePickerField = DatePickerField;
|
|
2723
2808
|
exports.FieldWrapper = FieldWrapper;
|
package/dist/itcase-forms.esm.js
CHANGED
|
@@ -11,12 +11,14 @@ import { Text } from '@itcase/ui/components/Text';
|
|
|
11
11
|
import { useDeviceTargetClass } from '@itcase/ui/hooks/useDeviceTargetClass';
|
|
12
12
|
import { useStyles } from '@itcase/ui/hooks/useStyles';
|
|
13
13
|
import { Choice } from '@itcase/ui/components/Choice';
|
|
14
|
+
import { Code } from '@itcase/ui/components/Code';
|
|
14
15
|
import { DatePickerInput } from '@itcase/ui/components/DatePicker';
|
|
15
16
|
import axios from 'axios';
|
|
16
17
|
import { useDropzone } from 'react-dropzone';
|
|
17
18
|
import { fromEvent } from 'file-selector';
|
|
18
19
|
import castArray from 'lodash/castArray';
|
|
19
20
|
import { createFileFromDataURL } from '@itcase/common';
|
|
21
|
+
import { Loader } from '@itcase/ui/components/Loader';
|
|
20
22
|
import { Title } from '@itcase/ui/components/Title';
|
|
21
23
|
import { Input } from '@itcase/ui/components/Input';
|
|
22
24
|
import { Icon } from '@itcase/ui/components/Icon';
|
|
@@ -27,7 +29,6 @@ import { Switch } from '@itcase/ui/components/Switch';
|
|
|
27
29
|
import { Textarea } from '@itcase/ui/components/Textarea';
|
|
28
30
|
import { Button } from '@itcase/ui/components/Button';
|
|
29
31
|
import { Group as Group$1 } from '@itcase/ui/components/Group';
|
|
30
|
-
import { Loader } from '@itcase/ui/components/Loader';
|
|
31
32
|
import { NotificationItem } from '@itcase/ui/components/Notification';
|
|
32
33
|
import createDecorator from 'final-form-focus';
|
|
33
34
|
|
|
@@ -804,6 +805,22 @@ var ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
|
|
|
804
805
|
}, function (_ref) {
|
|
805
806
|
var input = _ref.input,
|
|
806
807
|
meta = _ref.meta;
|
|
808
|
+
var activeOption = useMemo(function () {
|
|
809
|
+
var emptyOption = {
|
|
810
|
+
value: null,
|
|
811
|
+
label: null
|
|
812
|
+
};
|
|
813
|
+
if (input.value) {
|
|
814
|
+
var currentOption = options.find(function (option) {
|
|
815
|
+
return option.value === input.value;
|
|
816
|
+
});
|
|
817
|
+
return currentOption || emptyOption;
|
|
818
|
+
}
|
|
819
|
+
return emptyOption;
|
|
820
|
+
}, [input.value]);
|
|
821
|
+
var setActiveSegment = useCallback(function (option) {
|
|
822
|
+
change(name, option.value);
|
|
823
|
+
}, [change]);
|
|
807
824
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
808
825
|
className: clsx('form-field_type_choice', 'form__item_type_choice', classNameGroupItem),
|
|
809
826
|
inputName: input.name,
|
|
@@ -826,7 +843,8 @@ var ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
|
|
|
826
843
|
isMultiple: isMultiple,
|
|
827
844
|
isRequired: isRequired,
|
|
828
845
|
placeholder: placeholder,
|
|
829
|
-
|
|
846
|
+
active: activeOption,
|
|
847
|
+
setActiveSegment: setActiveSegment
|
|
830
848
|
}, inputProps)));
|
|
831
849
|
});
|
|
832
850
|
});
|
|
@@ -884,6 +902,53 @@ CustomField.propTypes = {
|
|
|
884
902
|
inputProps: PropTypes.object
|
|
885
903
|
};
|
|
886
904
|
|
|
905
|
+
var CodeField = /*#__PURE__*/React.memo(function CodeField(props) {
|
|
906
|
+
var isRequired = props.isRequired,
|
|
907
|
+
name = props.name,
|
|
908
|
+
fieldProps = props.fieldProps,
|
|
909
|
+
inputProps = props.inputProps,
|
|
910
|
+
classNameGroupItem = props.classNameGroupItem,
|
|
911
|
+
hideMessage = props.hideMessage;
|
|
912
|
+
return /*#__PURE__*/React.createElement(Field, {
|
|
913
|
+
name: name
|
|
914
|
+
}, function (_ref) {
|
|
915
|
+
var input = _ref.input,
|
|
916
|
+
meta = _ref.meta;
|
|
917
|
+
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
918
|
+
className: clsx('form-field_type_code', 'form__item_type_code', classNameGroupItem),
|
|
919
|
+
fieldClassName: 'form-code',
|
|
920
|
+
inputName: input.name,
|
|
921
|
+
inputValue: input.value,
|
|
922
|
+
isRequired: isRequired,
|
|
923
|
+
metaActive: meta.active,
|
|
924
|
+
metaError: meta.error,
|
|
925
|
+
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
926
|
+
metaSubmitError: meta.submitError,
|
|
927
|
+
metaSubmitFailed: meta.submitFailed,
|
|
928
|
+
metaTouched: meta.touched,
|
|
929
|
+
metaValid: meta.valid,
|
|
930
|
+
hideMessage: hideMessage
|
|
931
|
+
}, fieldProps), /*#__PURE__*/React.createElement(Code, Object.assign({
|
|
932
|
+
autoComplete: "nope",
|
|
933
|
+
name: input.name,
|
|
934
|
+
value: input.value,
|
|
935
|
+
onBlur: input.onBlur,
|
|
936
|
+
onChange: input.onChange,
|
|
937
|
+
onFocus: input.onFocus
|
|
938
|
+
}, inputProps)));
|
|
939
|
+
});
|
|
940
|
+
});
|
|
941
|
+
CodeField.defaultProps = {
|
|
942
|
+
inputProps: {},
|
|
943
|
+
fieldProps: {}
|
|
944
|
+
};
|
|
945
|
+
CodeField.propTypes = {
|
|
946
|
+
name: PropTypes.string.isRequired,
|
|
947
|
+
isRequired: PropTypes.bool,
|
|
948
|
+
fieldProps: PropTypes.object,
|
|
949
|
+
inputProps: PropTypes.object
|
|
950
|
+
};
|
|
951
|
+
|
|
887
952
|
function DatePickerField(props) {
|
|
888
953
|
var isRequired = props.isRequired,
|
|
889
954
|
fieldProps = props.fieldProps,
|
|
@@ -1129,6 +1194,9 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
|
|
|
1129
1194
|
hintDescriptionTextColor = props.hintDescriptionTextColor,
|
|
1130
1195
|
hintDescriptionTextWrap = props.hintDescriptionTextWrap,
|
|
1131
1196
|
hintDescriptionTextWeight = props.hintDescriptionTextWeight,
|
|
1197
|
+
errorMessageTextSize = props.errorMessageTextSize,
|
|
1198
|
+
errorMessageTextWeight = props.errorMessageTextWeight,
|
|
1199
|
+
errorMessageTextColor = props.errorMessageTextColor,
|
|
1132
1200
|
inputValue = props.inputValue,
|
|
1133
1201
|
removeThumbText = props.removeThumbText,
|
|
1134
1202
|
hintTitle = props.hintTitle,
|
|
@@ -1296,20 +1364,6 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
|
|
|
1296
1364
|
};
|
|
1297
1365
|
}, []); // eslint-disable-line
|
|
1298
1366
|
|
|
1299
|
-
// prettier-ignore
|
|
1300
|
-
/*
|
|
1301
|
-
const itemClass = useMemo(
|
|
1302
|
-
() => clsx(
|
|
1303
|
-
'form__item',
|
|
1304
|
-
'form__item_type_dropzone',
|
|
1305
|
-
// itemClassName,
|
|
1306
|
-
// metaError || fileError && 'form__item_state_error',
|
|
1307
|
-
files.length && 'form__item_state_success'
|
|
1308
|
-
),
|
|
1309
|
-
[files.length]
|
|
1310
|
-
)
|
|
1311
|
-
*/
|
|
1312
|
-
|
|
1313
1367
|
var fillClass = useDeviceTargetClass(props, {
|
|
1314
1368
|
prefix: 'fill_',
|
|
1315
1369
|
propsKey: 'fill'
|
|
@@ -1364,7 +1418,9 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
|
|
|
1364
1418
|
return /*#__PURE__*/React.createElement("aside", {
|
|
1365
1419
|
className: clsx('form-dropzone__thumb', fillClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
|
|
1366
1420
|
key: "" + (file.id || file.name + "_" + i || 'i' + i)
|
|
1367
|
-
},
|
|
1421
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1422
|
+
className: "form-dropzone__thumb-loading"
|
|
1423
|
+
}, fileIsLoading && (loadingText || 'Loading...')), isPreviews && /*#__PURE__*/React.createElement("div", {
|
|
1368
1424
|
className: "form-dropzone__thumb-image"
|
|
1369
1425
|
}, /*#__PURE__*/React.createElement("img", {
|
|
1370
1426
|
className: "form-dropzone__thumb-image-inner",
|
|
@@ -1382,8 +1438,14 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
|
|
|
1382
1438
|
textWeight: thumbNameTextWeight,
|
|
1383
1439
|
className: "form-dropzone__thumb-name-inner"
|
|
1384
1440
|
}, file.name)), fileIsLoading && /*#__PURE__*/React.createElement("div", {
|
|
1385
|
-
className: "form-dropzone__thumb-
|
|
1386
|
-
},
|
|
1441
|
+
className: "form-dropzone__thumb-loader"
|
|
1442
|
+
}, /*#__PURE__*/React.createElement(Loader, {
|
|
1443
|
+
fill: "surfacePrimary",
|
|
1444
|
+
height: "fill",
|
|
1445
|
+
itemFill: "surfaceItemAccent",
|
|
1446
|
+
set: "simple",
|
|
1447
|
+
width: "fill"
|
|
1448
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
1387
1449
|
className: "form-dropzone__thumb-remove",
|
|
1388
1450
|
onClick: function onClick(event) {
|
|
1389
1451
|
return removeFile(event, i);
|
|
@@ -1424,8 +1486,13 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
|
|
|
1424
1486
|
textWeight: hintDescriptionTextWeight,
|
|
1425
1487
|
className: "form-dropzone__hint-text"
|
|
1426
1488
|
}, hintDescription)))), fileError && /*#__PURE__*/React.createElement("div", {
|
|
1427
|
-
className: "
|
|
1428
|
-
},
|
|
1489
|
+
className: "form-field__message"
|
|
1490
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
1491
|
+
className: "form-field__message-item form-field__message-item_type_message",
|
|
1492
|
+
size: errorMessageTextSize,
|
|
1493
|
+
textWeight: errorMessageTextWeight,
|
|
1494
|
+
textColor: errorMessageTextColor
|
|
1495
|
+
}, fileError)));
|
|
1429
1496
|
});
|
|
1430
1497
|
FileInputDropzone.propTypes = {
|
|
1431
1498
|
dropzoneProps: PropTypes.object,
|
|
@@ -1470,6 +1537,9 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
|
|
|
1470
1537
|
removeThumbTextColor = props.removeThumbTextColor,
|
|
1471
1538
|
removeThumbTextWeight = props.removeThumbTextWeight,
|
|
1472
1539
|
hintTitle = props.hintTitle,
|
|
1540
|
+
errorMessageTextSize = props.errorMessageTextSize,
|
|
1541
|
+
errorMessageTextWeight = props.errorMessageTextWeight,
|
|
1542
|
+
errorMessageTextColor = props.errorMessageTextColor,
|
|
1473
1543
|
fieldProps = props.fieldProps,
|
|
1474
1544
|
hintTitleTextSize = props.hintTitleTextSize,
|
|
1475
1545
|
hintTitleTextColor = props.hintTitleTextColor,
|
|
@@ -1543,6 +1613,9 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
|
|
|
1543
1613
|
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
1544
1614
|
hintDescriptionTextWrap: hintDescriptionTextWrap,
|
|
1545
1615
|
hintDescriptionTextWeight: hintDescriptionTextWeight,
|
|
1616
|
+
errorMessageTextSize: errorMessageTextSize,
|
|
1617
|
+
errorMessageWeight: errorMessageTextWeight,
|
|
1618
|
+
errorMessageTextColor: errorMessageTextColor,
|
|
1546
1619
|
isPreviews: isPreviews,
|
|
1547
1620
|
shape: shape,
|
|
1548
1621
|
isShowFilename: isShowFilename,
|
|
@@ -1554,6 +1627,10 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
|
|
|
1554
1627
|
}));
|
|
1555
1628
|
});
|
|
1556
1629
|
});
|
|
1630
|
+
FileInput.defaultProps = {
|
|
1631
|
+
errorMessageTextSize: 's',
|
|
1632
|
+
errorMessageTextColor: 'errorTextPrimary'
|
|
1633
|
+
};
|
|
1557
1634
|
FileInput.propTypes = {
|
|
1558
1635
|
name: PropTypes.string.isRequired,
|
|
1559
1636
|
className: PropTypes.string,
|
|
@@ -2338,6 +2415,7 @@ var formTypes = {
|
|
|
2338
2415
|
checkbox: 'checkbox',
|
|
2339
2416
|
custom: 'custom',
|
|
2340
2417
|
choice: 'choice',
|
|
2418
|
+
code: 'code',
|
|
2341
2419
|
datePicker: 'datePicker',
|
|
2342
2420
|
dateRangePicker: 'dateRangePicker',
|
|
2343
2421
|
fileInput: 'fileInput',
|
|
@@ -2363,6 +2441,12 @@ function generateField(field, config, props) {
|
|
|
2363
2441
|
key: config.key
|
|
2364
2442
|
}, field, props));
|
|
2365
2443
|
}
|
|
2444
|
+
case formTypes.code:
|
|
2445
|
+
{
|
|
2446
|
+
return /*#__PURE__*/React.createElement(CodeField, Object.assign({
|
|
2447
|
+
key: config.key
|
|
2448
|
+
}, field, props));
|
|
2449
|
+
}
|
|
2366
2450
|
case formTypes["switch"]:
|
|
2367
2451
|
{
|
|
2368
2452
|
return /*#__PURE__*/React.createElement(SwitchField, Object.assign({
|
|
@@ -2694,4 +2778,4 @@ FinalForm.defaultProps = {
|
|
|
2694
2778
|
disableFieldsAutoComplete: false
|
|
2695
2779
|
};
|
|
2696
2780
|
|
|
2697
|
-
export { CheckboxField as Checkbox, ChoiceField, CustomField, DatePickerField, FieldWrapper, FieldWrapperBase, FileInput, FinalForm, Group, InputField, RadioGroup, SegmentedField, SelectField, SwitchField as Switch, TextareaField as Textarea, addRequiredFieldsParamToSchema, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|
|
2781
|
+
export { CheckboxField as Checkbox, ChoiceField, CodeField, CustomField, DatePickerField, FieldWrapper, FieldWrapperBase, FileInput, FinalForm, Group, InputField, RadioGroup, SegmentedField, SelectField, SwitchField as Switch, TextareaField as Textarea, addRequiredFieldsParamToSchema, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/forms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "Forms fields, inputs, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"forms",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@itcase/common": "^1.1.6",
|
|
38
|
-
"@itcase/ui": "^1.0.
|
|
38
|
+
"@itcase/ui": "^1.0.48",
|
|
39
39
|
"axios": "^1.5.0",
|
|
40
40
|
"clsx": "^2.0.0",
|
|
41
41
|
"date-fns": "2.0.0-alpha.7",
|