@itcase/forms 1.0.27 → 1.0.29

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.
@@ -29,7 +29,6 @@
29
29
  align-content: center;
30
30
  align-items: center;
31
31
  cursor: pointer;
32
- grid-column: span 3;
33
32
  &-title {
34
33
  padding: 0 0 8px 0;
35
34
  margin: 0;
@@ -49,12 +48,27 @@
49
48
  }
50
49
  }
51
50
  &__thumb {
52
- display: grid;
53
- column-gap: 8px;
54
- grid-template-columns: min-content 1fr;
55
- grid-template-rows: auto 1fr;
56
51
  padding: 8px 16px 8px 8px;
57
52
  position: relative;
53
+ &_direction {
54
+ &_vertical {
55
+ display: flex;
56
+ flex-flow: column nowrap;
57
+ ^^&-image {
58
+ width: 100%;
59
+ }
60
+ }
61
+ &_horizontal {
62
+ column-gap: 8px;
63
+ display: grid;
64
+ grid-template-columns: min-content 1fr;
65
+ grid-template-rows: auto 1fr;
66
+ ^^&-image {
67
+ width: 160px;
68
+ height: 160px;
69
+ }
70
+ }
71
+ }
58
72
  &-loader {
59
73
  position: absolute;
60
74
  left: 0;
@@ -64,8 +78,6 @@
64
78
  display: flex;
65
79
  }
66
80
  &-image {
67
- width: 160px;
68
- height: 160px;
69
81
  grid-column-start: 1;
70
82
  grid-row-start: span 2;
71
83
  display: flex;
@@ -80,11 +92,13 @@
80
92
  }
81
93
  }
82
94
  &-name {
95
+ width: 100%;
83
96
  padding: 12px 0 0 0;
84
97
  grid-column-start: 2;
85
98
  align-self: flex-start;
86
99
  }
87
100
  &-remove {
101
+ width: 100%;
88
102
  grid-column-start: 2;
89
103
  align-self: flex-start;
90
104
  cursor: pointer;
@@ -125,6 +139,16 @@
125
139
  }
126
140
  }
127
141
  }
142
+ .form-dropzone__dropzone-wrapper_column {
143
+ @each $count in 1, 2, 3, 4, 5 {
144
+ &_$(count) {
145
+ grid-template-columns: repeat($(count), minmax(0, 1fr));
146
+ & .form-dropzone__hint {
147
+ grid-column: span $(count);
148
+ }
149
+ }
150
+ }
151
+ }
128
152
  :root {
129
153
  --fileinput-size-normal-padding: 16px 16px;
130
154
  --fileinput-size-normal-shape-rounded: 6px;
@@ -43,6 +43,9 @@ var castArray__default = /*#__PURE__*/_interopDefault(castArray);
43
43
  var createDecorator__default = /*#__PURE__*/_interopDefault(createDecorator);
44
44
 
45
45
  var phoneValidation = function phoneValidation(value, context) {
46
+ if (!value) {
47
+ return true;
48
+ }
46
49
  return libphonenumberJs.isPossiblePhoneNumber(value, 'RU');
47
50
  };
48
51
  var emailValidation = function emailValidation(value, context) {
@@ -484,13 +487,19 @@ var makeValidate = function makeValidate(schema) {
484
487
  abortEarly: false
485
488
  });
486
489
  case 3:
487
- _context.next = 8;
490
+ _context.next = 12;
488
491
  break;
489
492
  case 5:
490
493
  _context.prev = 5;
491
494
  _context.t0 = _context["catch"](0);
495
+ if (!_context.t0.inner) {
496
+ _context.next = 11;
497
+ break;
498
+ }
492
499
  return _context.abrupt("return", _context.t0.inner.reduce(setInError, emptyObj));
493
- case 8:
500
+ case 11:
501
+ console.warn('itcase-forms schema.validate error: An error not related to the form occurred during validation. Validation ignored.');
502
+ case 12:
494
503
  case "end":
495
504
  return _context.stop();
496
505
  }
@@ -803,6 +812,7 @@ var ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceField(
803
812
  inputProps = props.inputProps,
804
813
  isMultiple = props.isMultiple,
805
814
  isRequired = props.isRequired,
815
+ initialValue = props.initialValue,
806
816
  label = props.label,
807
817
  name = props.name,
808
818
  messageType = props.messageType,
@@ -811,7 +821,8 @@ var ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceField(
811
821
  var _useForm = reactFinalForm.useForm(),
812
822
  change = _useForm.change;
813
823
  return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
814
- name: name
824
+ name: name,
825
+ initialValue: initialValue
815
826
  }, function (_ref) {
816
827
  var input = _ref.input,
817
828
  meta = _ref.meta;
@@ -1199,6 +1210,7 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1199
1210
  thumbNameTextWeight = props.thumbNameTextWeight,
1200
1211
  hintTitleTextColor = props.hintTitleTextColor,
1201
1212
  hintTitleTextWrap = props.hintTitleTextWrap,
1213
+ thumbColumn = props.thumbColumn,
1202
1214
  hintTitleTextWeight = props.hintTitleTextWeight,
1203
1215
  hintDescriptionTextSize = props.hintDescriptionTextSize,
1204
1216
  hintDescriptionTextColor = props.hintDescriptionTextColor,
@@ -1208,6 +1220,8 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1208
1220
  errorMessageTextWeight = props.errorMessageTextWeight,
1209
1221
  errorMessageTextColor = props.errorMessageTextColor,
1210
1222
  inputValue = props.inputValue,
1223
+ maxFiles = props.maxFiles,
1224
+ maxSize = props.maxSize,
1211
1225
  removeThumbText = props.removeThumbText,
1212
1226
  hintTitle = props.hintTitle,
1213
1227
  hintDescription = props.hintDescription,
@@ -1242,7 +1256,9 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1242
1256
 
1243
1257
  // Create dropzone options
1244
1258
  var _useDropzone = reactDropzone.useDropzone(Object.assign({
1245
- maxSize: 5242880
1259
+ maxSize: maxSize || 10485760,
1260
+ // 10mb
1261
+ maxFiles: maxFiles || 5
1246
1262
  }, dropzoneProps, {
1247
1263
  getFilesFromEvent: function () {
1248
1264
  var _getFilesFromEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
@@ -1406,6 +1422,10 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1406
1422
  prefix: 'border-width_',
1407
1423
  propsKey: 'thumbBorderWidth'
1408
1424
  });
1425
+ var thumbDirectionClass = useDeviceTargetClass.useDeviceTargetClass(props, {
1426
+ prefix: 'form-dropzone__thumb_direction_',
1427
+ propsKey: 'thumbDirection'
1428
+ });
1409
1429
  var thumbBorderColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
1410
1430
  prefix: 'border-color_',
1411
1431
  propsKey: 'thumbBorderColor'
@@ -1419,14 +1439,14 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1419
1439
  propsKey: 'thumbBorderType'
1420
1440
  });
1421
1441
  return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, /*#__PURE__*/React__default.default.createElement("div", getRootProps({
1422
- className: "form-dropzone__dropzone dropzone " + className + " form-dropzone__dropzone_size_" + size + " " + shapeClass
1442
+ className: "form-dropzone__dropzone dropzone " + className + " thumbColumn form-dropzone__dropzone_size_" + size + " " + shapeClass
1423
1443
  }), /*#__PURE__*/React__default.default.createElement("input", Object.assign({}, getInputProps(), {
1424
1444
  name: inputName
1425
1445
  })), /*#__PURE__*/React__default.default.createElement("div", {
1426
- className: clsx__default.default('form-dropzone__dropzone-wrapper', fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1446
+ className: clsx__default.default('form-dropzone__dropzone-wrapper', thumbColumn && "form-dropzone__dropzone-wrapper_column_" + thumbColumn, fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1427
1447
  }, files.map(function (file, i) {
1428
1448
  return /*#__PURE__*/React__default.default.createElement("aside", {
1429
- className: clsx__default.default('form-dropzone__thumb', fillClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1449
+ className: clsx__default.default('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1430
1450
  key: "" + (file.id || file.name + "_" + i || 'i' + i)
1431
1451
  }, isPreviews && /*#__PURE__*/React__default.default.createElement("div", {
1432
1452
  className: "form-dropzone__thumb-image"
@@ -1558,9 +1578,13 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
1558
1578
  hintDescriptionTextWrap = props.hintDescriptionTextWrap,
1559
1579
  hintDescriptionTextWeight = props.hintDescriptionTextWeight,
1560
1580
  hideMessage = props.hideMessage,
1581
+ thumbDirection = props.thumbDirection,
1561
1582
  hintDescription = props.hintDescription,
1562
1583
  isShowFilename = props.isShowFilename,
1563
1584
  dropzoneProps = props.dropzoneProps,
1585
+ maxFiles = props.maxFiles,
1586
+ maxSize = props.maxSize,
1587
+ thumbColumn = props.thumbColumn,
1564
1588
  isRequired = props.isRequired,
1565
1589
  isPreviews = props.isPreviews,
1566
1590
  onAddFiles = props.onAddFiles,
@@ -1601,9 +1625,13 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
1601
1625
  thumbBorderType: thumbBorderType,
1602
1626
  fill: fill,
1603
1627
  size: size,
1628
+ maxFiles: maxFiles,
1629
+ maxSize: maxSize,
1604
1630
  removeThumbTextHoverColor: removeThumbTextHoverColor,
1605
1631
  fillHover: fillHover,
1606
1632
  className: className,
1633
+ thumbColumn: thumbColumn,
1634
+ thumbDirection: thumbDirection,
1607
1635
  inputName: input.name,
1608
1636
  inputValue: input.value,
1609
1637
  thumbNameTextSize: thumbNameTextSize,
@@ -1637,7 +1665,9 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
1637
1665
  });
1638
1666
  FileInput.defaultProps = {
1639
1667
  errorMessageTextSize: 's',
1640
- errorMessageTextColor: 'errorTextPrimary'
1668
+ errorMessageTextColor: 'errorTextPrimary',
1669
+ thumbColumn: 1,
1670
+ thumbDirection: 'vertical'
1641
1671
  };
1642
1672
  FileInput.propTypes = {
1643
1673
  name: PropTypes__default.default.string.isRequired,
@@ -33,6 +33,9 @@ import { NotificationItem } from '@itcase/ui/components/Notification';
33
33
  import createDecorator from 'final-form-focus';
34
34
 
35
35
  var phoneValidation = function phoneValidation(value, context) {
36
+ if (!value) {
37
+ return true;
38
+ }
36
39
  return isPossiblePhoneNumber(value, 'RU');
37
40
  };
38
41
  var emailValidation = function emailValidation(value, context) {
@@ -474,13 +477,19 @@ var makeValidate = function makeValidate(schema) {
474
477
  abortEarly: false
475
478
  });
476
479
  case 3:
477
- _context.next = 8;
480
+ _context.next = 12;
478
481
  break;
479
482
  case 5:
480
483
  _context.prev = 5;
481
484
  _context.t0 = _context["catch"](0);
485
+ if (!_context.t0.inner) {
486
+ _context.next = 11;
487
+ break;
488
+ }
482
489
  return _context.abrupt("return", _context.t0.inner.reduce(setInError, emptyObj));
483
- case 8:
490
+ case 11:
491
+ console.warn('itcase-forms schema.validate error: An error not related to the form occurred during validation. Validation ignored.');
492
+ case 12:
484
493
  case "end":
485
494
  return _context.stop();
486
495
  }
@@ -793,6 +802,7 @@ var ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
793
802
  inputProps = props.inputProps,
794
803
  isMultiple = props.isMultiple,
795
804
  isRequired = props.isRequired,
805
+ initialValue = props.initialValue,
796
806
  label = props.label,
797
807
  name = props.name,
798
808
  messageType = props.messageType,
@@ -801,7 +811,8 @@ var ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
801
811
  var _useForm = useForm(),
802
812
  change = _useForm.change;
803
813
  return /*#__PURE__*/React.createElement(Field, {
804
- name: name
814
+ name: name,
815
+ initialValue: initialValue
805
816
  }, function (_ref) {
806
817
  var input = _ref.input,
807
818
  meta = _ref.meta;
@@ -1189,6 +1200,7 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1189
1200
  thumbNameTextWeight = props.thumbNameTextWeight,
1190
1201
  hintTitleTextColor = props.hintTitleTextColor,
1191
1202
  hintTitleTextWrap = props.hintTitleTextWrap,
1203
+ thumbColumn = props.thumbColumn,
1192
1204
  hintTitleTextWeight = props.hintTitleTextWeight,
1193
1205
  hintDescriptionTextSize = props.hintDescriptionTextSize,
1194
1206
  hintDescriptionTextColor = props.hintDescriptionTextColor,
@@ -1198,6 +1210,8 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1198
1210
  errorMessageTextWeight = props.errorMessageTextWeight,
1199
1211
  errorMessageTextColor = props.errorMessageTextColor,
1200
1212
  inputValue = props.inputValue,
1213
+ maxFiles = props.maxFiles,
1214
+ maxSize = props.maxSize,
1201
1215
  removeThumbText = props.removeThumbText,
1202
1216
  hintTitle = props.hintTitle,
1203
1217
  hintDescription = props.hintDescription,
@@ -1232,7 +1246,9 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1232
1246
 
1233
1247
  // Create dropzone options
1234
1248
  var _useDropzone = useDropzone(Object.assign({
1235
- maxSize: 5242880
1249
+ maxSize: maxSize || 10485760,
1250
+ // 10mb
1251
+ maxFiles: maxFiles || 5
1236
1252
  }, dropzoneProps, {
1237
1253
  getFilesFromEvent: function () {
1238
1254
  var _getFilesFromEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
@@ -1396,6 +1412,10 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1396
1412
  prefix: 'border-width_',
1397
1413
  propsKey: 'thumbBorderWidth'
1398
1414
  });
1415
+ var thumbDirectionClass = useDeviceTargetClass(props, {
1416
+ prefix: 'form-dropzone__thumb_direction_',
1417
+ propsKey: 'thumbDirection'
1418
+ });
1399
1419
  var thumbBorderColorClass = useDeviceTargetClass(props, {
1400
1420
  prefix: 'border-color_',
1401
1421
  propsKey: 'thumbBorderColor'
@@ -1409,14 +1429,14 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1409
1429
  propsKey: 'thumbBorderType'
1410
1430
  });
1411
1431
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", getRootProps({
1412
- className: "form-dropzone__dropzone dropzone " + className + " form-dropzone__dropzone_size_" + size + " " + shapeClass
1432
+ className: "form-dropzone__dropzone dropzone " + className + " thumbColumn form-dropzone__dropzone_size_" + size + " " + shapeClass
1413
1433
  }), /*#__PURE__*/React.createElement("input", Object.assign({}, getInputProps(), {
1414
1434
  name: inputName
1415
1435
  })), /*#__PURE__*/React.createElement("div", {
1416
- className: clsx('form-dropzone__dropzone-wrapper', fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1436
+ className: clsx('form-dropzone__dropzone-wrapper', thumbColumn && "form-dropzone__dropzone-wrapper_column_" + thumbColumn, fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1417
1437
  }, files.map(function (file, i) {
1418
1438
  return /*#__PURE__*/React.createElement("aside", {
1419
- className: clsx('form-dropzone__thumb', fillClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1439
+ className: clsx('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1420
1440
  key: "" + (file.id || file.name + "_" + i || 'i' + i)
1421
1441
  }, isPreviews && /*#__PURE__*/React.createElement("div", {
1422
1442
  className: "form-dropzone__thumb-image"
@@ -1548,9 +1568,13 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
1548
1568
  hintDescriptionTextWrap = props.hintDescriptionTextWrap,
1549
1569
  hintDescriptionTextWeight = props.hintDescriptionTextWeight,
1550
1570
  hideMessage = props.hideMessage,
1571
+ thumbDirection = props.thumbDirection,
1551
1572
  hintDescription = props.hintDescription,
1552
1573
  isShowFilename = props.isShowFilename,
1553
1574
  dropzoneProps = props.dropzoneProps,
1575
+ maxFiles = props.maxFiles,
1576
+ maxSize = props.maxSize,
1577
+ thumbColumn = props.thumbColumn,
1554
1578
  isRequired = props.isRequired,
1555
1579
  isPreviews = props.isPreviews,
1556
1580
  onAddFiles = props.onAddFiles,
@@ -1591,9 +1615,13 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
1591
1615
  thumbBorderType: thumbBorderType,
1592
1616
  fill: fill,
1593
1617
  size: size,
1618
+ maxFiles: maxFiles,
1619
+ maxSize: maxSize,
1594
1620
  removeThumbTextHoverColor: removeThumbTextHoverColor,
1595
1621
  fillHover: fillHover,
1596
1622
  className: className,
1623
+ thumbColumn: thumbColumn,
1624
+ thumbDirection: thumbDirection,
1597
1625
  inputName: input.name,
1598
1626
  inputValue: input.value,
1599
1627
  thumbNameTextSize: thumbNameTextSize,
@@ -1627,7 +1655,9 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
1627
1655
  });
1628
1656
  FileInput.defaultProps = {
1629
1657
  errorMessageTextSize: 's',
1630
- errorMessageTextColor: 'errorTextPrimary'
1658
+ errorMessageTextColor: 'errorTextPrimary',
1659
+ thumbColumn: 1,
1660
+ thumbDirection: 'vertical'
1631
1661
  };
1632
1662
  FileInput.propTypes = {
1633
1663
  name: PropTypes.string.isRequired,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/forms",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Forms fields, inputs, etc.",
5
5
  "keywords": [
6
6
  "forms",