@itcase/forms 1.0.27 → 1.0.28

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
  }
@@ -1199,6 +1208,7 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1199
1208
  thumbNameTextWeight = props.thumbNameTextWeight,
1200
1209
  hintTitleTextColor = props.hintTitleTextColor,
1201
1210
  hintTitleTextWrap = props.hintTitleTextWrap,
1211
+ thumbColumn = props.thumbColumn,
1202
1212
  hintTitleTextWeight = props.hintTitleTextWeight,
1203
1213
  hintDescriptionTextSize = props.hintDescriptionTextSize,
1204
1214
  hintDescriptionTextColor = props.hintDescriptionTextColor,
@@ -1208,6 +1218,8 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1208
1218
  errorMessageTextWeight = props.errorMessageTextWeight,
1209
1219
  errorMessageTextColor = props.errorMessageTextColor,
1210
1220
  inputValue = props.inputValue,
1221
+ maxFiles = props.maxFiles,
1222
+ maxSize = props.maxSize,
1211
1223
  removeThumbText = props.removeThumbText,
1212
1224
  hintTitle = props.hintTitle,
1213
1225
  hintDescription = props.hintDescription,
@@ -1242,7 +1254,9 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1242
1254
 
1243
1255
  // Create dropzone options
1244
1256
  var _useDropzone = reactDropzone.useDropzone(Object.assign({
1245
- maxSize: 5242880
1257
+ maxSize: maxSize || 10485760,
1258
+ // 10mb
1259
+ maxFiles: maxFiles || 5
1246
1260
  }, dropzoneProps, {
1247
1261
  getFilesFromEvent: function () {
1248
1262
  var _getFilesFromEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
@@ -1406,6 +1420,10 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1406
1420
  prefix: 'border-width_',
1407
1421
  propsKey: 'thumbBorderWidth'
1408
1422
  });
1423
+ var thumbDirectionClass = useDeviceTargetClass.useDeviceTargetClass(props, {
1424
+ prefix: 'form-dropzone__thumb_direction_',
1425
+ propsKey: 'thumbDirection'
1426
+ });
1409
1427
  var thumbBorderColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
1410
1428
  prefix: 'border-color_',
1411
1429
  propsKey: 'thumbBorderColor'
@@ -1419,14 +1437,14 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
1419
1437
  propsKey: 'thumbBorderType'
1420
1438
  });
1421
1439
  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
1440
+ className: "form-dropzone__dropzone dropzone " + className + " thumbColumn form-dropzone__dropzone_size_" + size + " " + shapeClass
1423
1441
  }), /*#__PURE__*/React__default.default.createElement("input", Object.assign({}, getInputProps(), {
1424
1442
  name: inputName
1425
1443
  })), /*#__PURE__*/React__default.default.createElement("div", {
1426
- className: clsx__default.default('form-dropzone__dropzone-wrapper', fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1444
+ className: clsx__default.default('form-dropzone__dropzone-wrapper', thumbColumn && "form-dropzone__dropzone-wrapper_column_" + thumbColumn, fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1427
1445
  }, files.map(function (file, i) {
1428
1446
  return /*#__PURE__*/React__default.default.createElement("aside", {
1429
- className: clsx__default.default('form-dropzone__thumb', fillClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1447
+ className: clsx__default.default('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1430
1448
  key: "" + (file.id || file.name + "_" + i || 'i' + i)
1431
1449
  }, isPreviews && /*#__PURE__*/React__default.default.createElement("div", {
1432
1450
  className: "form-dropzone__thumb-image"
@@ -1558,9 +1576,13 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
1558
1576
  hintDescriptionTextWrap = props.hintDescriptionTextWrap,
1559
1577
  hintDescriptionTextWeight = props.hintDescriptionTextWeight,
1560
1578
  hideMessage = props.hideMessage,
1579
+ thumbDirection = props.thumbDirection,
1561
1580
  hintDescription = props.hintDescription,
1562
1581
  isShowFilename = props.isShowFilename,
1563
1582
  dropzoneProps = props.dropzoneProps,
1583
+ maxFiles = props.maxFiles,
1584
+ maxSize = props.maxSize,
1585
+ thumbColumn = props.thumbColumn,
1564
1586
  isRequired = props.isRequired,
1565
1587
  isPreviews = props.isPreviews,
1566
1588
  onAddFiles = props.onAddFiles,
@@ -1601,9 +1623,13 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
1601
1623
  thumbBorderType: thumbBorderType,
1602
1624
  fill: fill,
1603
1625
  size: size,
1626
+ maxFiles: maxFiles,
1627
+ maxSize: maxSize,
1604
1628
  removeThumbTextHoverColor: removeThumbTextHoverColor,
1605
1629
  fillHover: fillHover,
1606
1630
  className: className,
1631
+ thumbColumn: thumbColumn,
1632
+ thumbDirection: thumbDirection,
1607
1633
  inputName: input.name,
1608
1634
  inputValue: input.value,
1609
1635
  thumbNameTextSize: thumbNameTextSize,
@@ -1637,7 +1663,9 @@ var FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(prop
1637
1663
  });
1638
1664
  FileInput.defaultProps = {
1639
1665
  errorMessageTextSize: 's',
1640
- errorMessageTextColor: 'errorTextPrimary'
1666
+ errorMessageTextColor: 'errorTextPrimary',
1667
+ thumbColumn: 1,
1668
+ thumbDirection: 'vertical'
1641
1669
  };
1642
1670
  FileInput.propTypes = {
1643
1671
  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
  }
@@ -1189,6 +1198,7 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1189
1198
  thumbNameTextWeight = props.thumbNameTextWeight,
1190
1199
  hintTitleTextColor = props.hintTitleTextColor,
1191
1200
  hintTitleTextWrap = props.hintTitleTextWrap,
1201
+ thumbColumn = props.thumbColumn,
1192
1202
  hintTitleTextWeight = props.hintTitleTextWeight,
1193
1203
  hintDescriptionTextSize = props.hintDescriptionTextSize,
1194
1204
  hintDescriptionTextColor = props.hintDescriptionTextColor,
@@ -1198,6 +1208,8 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1198
1208
  errorMessageTextWeight = props.errorMessageTextWeight,
1199
1209
  errorMessageTextColor = props.errorMessageTextColor,
1200
1210
  inputValue = props.inputValue,
1211
+ maxFiles = props.maxFiles,
1212
+ maxSize = props.maxSize,
1201
1213
  removeThumbText = props.removeThumbText,
1202
1214
  hintTitle = props.hintTitle,
1203
1215
  hintDescription = props.hintDescription,
@@ -1232,7 +1244,9 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1232
1244
 
1233
1245
  // Create dropzone options
1234
1246
  var _useDropzone = useDropzone(Object.assign({
1235
- maxSize: 5242880
1247
+ maxSize: maxSize || 10485760,
1248
+ // 10mb
1249
+ maxFiles: maxFiles || 5
1236
1250
  }, dropzoneProps, {
1237
1251
  getFilesFromEvent: function () {
1238
1252
  var _getFilesFromEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
@@ -1396,6 +1410,10 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1396
1410
  prefix: 'border-width_',
1397
1411
  propsKey: 'thumbBorderWidth'
1398
1412
  });
1413
+ var thumbDirectionClass = useDeviceTargetClass(props, {
1414
+ prefix: 'form-dropzone__thumb_direction_',
1415
+ propsKey: 'thumbDirection'
1416
+ });
1399
1417
  var thumbBorderColorClass = useDeviceTargetClass(props, {
1400
1418
  prefix: 'border-color_',
1401
1419
  propsKey: 'thumbBorderColor'
@@ -1409,14 +1427,14 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1409
1427
  propsKey: 'thumbBorderType'
1410
1428
  });
1411
1429
  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
1430
+ className: "form-dropzone__dropzone dropzone " + className + " thumbColumn form-dropzone__dropzone_size_" + size + " " + shapeClass
1413
1431
  }), /*#__PURE__*/React.createElement("input", Object.assign({}, getInputProps(), {
1414
1432
  name: inputName
1415
1433
  })), /*#__PURE__*/React.createElement("div", {
1416
- className: clsx('form-dropzone__dropzone-wrapper', fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1434
+ className: clsx('form-dropzone__dropzone-wrapper', thumbColumn && "form-dropzone__dropzone-wrapper_column_" + thumbColumn, fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1417
1435
  }, files.map(function (file, i) {
1418
1436
  return /*#__PURE__*/React.createElement("aside", {
1419
- className: clsx('form-dropzone__thumb', fillClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1437
+ className: clsx('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1420
1438
  key: "" + (file.id || file.name + "_" + i || 'i' + i)
1421
1439
  }, isPreviews && /*#__PURE__*/React.createElement("div", {
1422
1440
  className: "form-dropzone__thumb-image"
@@ -1548,9 +1566,13 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
1548
1566
  hintDescriptionTextWrap = props.hintDescriptionTextWrap,
1549
1567
  hintDescriptionTextWeight = props.hintDescriptionTextWeight,
1550
1568
  hideMessage = props.hideMessage,
1569
+ thumbDirection = props.thumbDirection,
1551
1570
  hintDescription = props.hintDescription,
1552
1571
  isShowFilename = props.isShowFilename,
1553
1572
  dropzoneProps = props.dropzoneProps,
1573
+ maxFiles = props.maxFiles,
1574
+ maxSize = props.maxSize,
1575
+ thumbColumn = props.thumbColumn,
1554
1576
  isRequired = props.isRequired,
1555
1577
  isPreviews = props.isPreviews,
1556
1578
  onAddFiles = props.onAddFiles,
@@ -1591,9 +1613,13 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
1591
1613
  thumbBorderType: thumbBorderType,
1592
1614
  fill: fill,
1593
1615
  size: size,
1616
+ maxFiles: maxFiles,
1617
+ maxSize: maxSize,
1594
1618
  removeThumbTextHoverColor: removeThumbTextHoverColor,
1595
1619
  fillHover: fillHover,
1596
1620
  className: className,
1621
+ thumbColumn: thumbColumn,
1622
+ thumbDirection: thumbDirection,
1597
1623
  inputName: input.name,
1598
1624
  inputValue: input.value,
1599
1625
  thumbNameTextSize: thumbNameTextSize,
@@ -1627,7 +1653,9 @@ var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
1627
1653
  });
1628
1654
  FileInput.defaultProps = {
1629
1655
  errorMessageTextSize: 's',
1630
- errorMessageTextColor: 'errorTextPrimary'
1656
+ errorMessageTextColor: 'errorTextPrimary',
1657
+ thumbColumn: 1,
1658
+ thumbDirection: 'vertical'
1631
1659
  };
1632
1660
  FileInput.propTypes = {
1633
1661
  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.28",
4
4
  "description": "Forms fields, inputs, etc.",
5
5
  "keywords": [
6
6
  "forms",