kamotive_ui 4.12.25 → 9.12.25

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,3 +1,3 @@
1
- import { FC } from 'react';
2
- import { FileAttachProps } from '../../types';
3
- export declare const FileAttach: FC<FileAttachProps>;
1
+ import React from 'react';
2
+ import { FileAttachProps, FileLoaderHandle } from '../../types';
3
+ export declare const FileAttach: React.ForwardRefExoticComponent<FileAttachProps & React.RefAttributes<FileLoaderHandle>>;
@@ -1,20 +1,20 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import styles from './FileAttach.module.css';
3
3
  import classNames from 'classnames';
4
4
  import { FileLoader } from '../FileLoader/FileLoader';
5
5
  import { FileListAttaсhed } from '../FileListAttached/FileListAttaсhed';
6
- export const FileAttach = ({ filesList = [], maxFileSize = 2, maxFileCount = 10, acceptedFormats = {
6
+ export const FileAttach = forwardRef(({ filesList = [], maxFileSize = 2, maxFileCount = 10, maxFileName = 0, acceptedFormats = {
7
7
  'image/*': ['.png', '.gif', '.jpeg', '.jpg'],
8
8
  'application/pdf': ['.pdf'],
9
9
  'application/msword': ['.doc', '.docx'],
10
10
  'model/gltf-binary': ['.glb'],
11
11
  'application/octet-stream': ['.prt', '.step', '.stp'],
12
12
  'text/plain': ['.syslog'],
13
- }, addedFiles, setAddedFiles, onDownload, onDelete, canAdd = true, canDelete = true, canDownload = true, position = 'bottom', lng = 'ru', className, style, fileValidator, }) => {
13
+ }, addedFiles, setAddedFiles, onDownload, onDelete, canAdd = true, canDelete = true, canDownload = true, position = 'bottom', lng = 'ru', className, style, fileValidator, }, ref) => {
14
14
  const fileAttachClasses = classNames(styles['fileAttach'], className, {
15
15
  [styles[`fileAttach_position_${position}`]]: position,
16
16
  });
17
17
  return (React.createElement("div", { className: fileAttachClasses, style: style },
18
- React.createElement(FileLoader, { maxFileSize: maxFileSize, maxFileCount: maxFileCount, acceptedFormats: acceptedFormats, addedFiles: addedFiles, setAddedFiles: setAddedFiles, filesList: filesList, canAdd: canAdd, lng: lng, fileValidator: fileValidator }),
18
+ React.createElement(FileLoader, { ref: ref, maxFileSize: maxFileSize, maxFileCount: maxFileCount, maxFileName: maxFileName, acceptedFormats: acceptedFormats, addedFiles: addedFiles, setAddedFiles: setAddedFiles, filesList: filesList, canAdd: canAdd, lng: lng, fileValidator: fileValidator }),
19
19
  React.createElement(FileListAttaсhed, { filesList: filesList, onDelete: onDelete, onDownload: onDownload, canDelete: canDelete, canDownload: canDownload, lng: lng })));
20
- };
20
+ });
@@ -5,7 +5,7 @@ import { Typography } from '../Typography/Typography';
5
5
  import { IconUpload } from '../../Icons';
6
6
  import { FileItem } from '../FileItem/FileItem';
7
7
  import classNames from 'classnames';
8
- export const FileLoader = forwardRef(({ maxFileSize = 2, maxFileCount = 10, acceptedFormats = {
8
+ export const FileLoader = forwardRef(({ maxFileSize = 2, maxFileCount = 10, maxFileName = 0, acceptedFormats = {
9
9
  'image/*': ['.png', '.gif', '.jpeg', '.jpg'],
10
10
  'application/pdf': ['.pdf'],
11
11
  'application/msword': ['.doc', '.docx', '.log', '.syslog', '.txt'],
@@ -28,7 +28,7 @@ export const FileLoader = forwardRef(({ maxFileSize = 2, maxFileCount = 10, acce
28
28
  const fileValidatorInner = (file) => {
29
29
  if (file.size > maxFileSize * 1024 * 1024 * 1024) {
30
30
  return {
31
- code: 'name-too-large',
31
+ code: 'size-too-large',
32
32
  message: lng === 'ru' || lng.includes('ru')
33
33
  ? `Максимальный размер файла ${maxFileSize.toFixed(0)} ГБ`
34
34
  : `Maximum file size ${maxFileSize.toFixed(0)} GB`,
@@ -54,6 +54,12 @@ export const FileLoader = forwardRef(({ maxFileSize = 2, maxFileCount = 10, acce
54
54
  message: lng === 'ru' || lng.includes('ru') ? `Максимальное количество файлов ${maxFileCount}` : `Maximum number of files ${maxFileCount}`,
55
55
  };
56
56
  }
57
+ if (maxFileName && file.name.length > maxFileName) {
58
+ return {
59
+ code: 'name-too-large',
60
+ message: lng === 'ru' || lng.includes('ru') ? `Имя файла не может превышать ${maxFileName} символов` : `File name must be under ${maxFileName} symbols`,
61
+ };
62
+ }
57
63
  if (acceptedFormats && !rejectedFormats) {
58
64
  const acceptedExtensions = Object.values(acceptedFormats)
59
65
  .reduce((acc, val) => acc.concat(val), []);
@@ -387,6 +387,8 @@ export interface FileAttachProps {
387
387
  maxFileSize?: number;
388
388
  /** Максимальное количество файлов */
389
389
  maxFileCount?: number;
390
+ /** Максимальное количество символов в названии файла */
391
+ maxFileName?: number;
390
392
  /**Поддерживаемые форматы файлов */
391
393
  acceptedFormats?: Accept;
392
394
  /**Добавленные файлы */
@@ -465,6 +467,8 @@ export interface FileLoaderProps {
465
467
  maxFileSize?: number;
466
468
  /** Максимальное количество файлов */
467
469
  maxFileCount?: number;
470
+ /** Максимальное количество символов в названии файла */
471
+ maxFileName?: number;
468
472
  /**Поддерживаемые форматы файлов */
469
473
  acceptedFormats?: Accept;
470
474
  /** Неподдерживаемые форматы файлов */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kamotive_ui",
3
- "version": "4.12.25",
3
+ "version": "9.12.25",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [