@skbkontur/react-ui 6.5.2 → 6.5.4-f56fc.0
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/CHANGELOG.md +12 -0
- package/components/FileUploader/FileUploader.d.ts +16 -1
- package/components/FileUploader/FileUploader.js +76 -23
- package/components/FileUploader/FileUploader.js.map +1 -1
- package/components/FileUploader/FileUploaderCustomView.d.ts +17 -0
- package/components/FileUploader/FileUploaderCustomView.js +10 -0
- package/components/FileUploader/FileUploaderCustomView.js.map +1 -0
- package/components/FileUploader/FileUploaderDropzone.d.ts +8 -0
- package/components/FileUploader/FileUploaderDropzone.js +12 -0
- package/components/FileUploader/FileUploaderDropzone.js.map +1 -0
- package/components/FileUploader/FileUploaderFiles.d.ts +9 -0
- package/components/FileUploader/FileUploaderFiles.js +25 -0
- package/components/FileUploader/FileUploaderFiles.js.map +1 -0
- package/components/FileUploader/FileUploaderSummary.d.ts +11 -0
- package/components/FileUploader/FileUploaderSummary.js +16 -0
- package/components/FileUploader/FileUploaderSummary.js.map +1 -0
- package/components/FileUploader/FileUploaderUploader.d.ts +9 -0
- package/components/FileUploader/FileUploaderUploader.js +47 -0
- package/components/FileUploader/FileUploaderUploader.js.map +1 -0
- package/components/FileUploader/index.d.ts +4 -0
- package/components/FileUploader/index.js.map +1 -1
- package/components/Toast/ToastView.js +1 -1
- package/components/Toast/ToastView.js.map +1 -1
- package/components/Toast/ToastView.styles.d.ts +1 -1
- package/components/Toast/ToastView.styles.js +4 -2
- package/components/Toast/ToastView.styles.js.map +1 -1
- package/hooks/useDrop.d.ts +4 -3
- package/hooks/useDrop.js +21 -8
- package/hooks/useDrop.js.map +1 -1
- package/lib/dom/tabbableHelpers.js +23 -1
- package/lib/dom/tabbableHelpers.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.5.3](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@6.5.2...@skbkontur/react-ui@6.5.3) (2026-11-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **Loader:** fallback for tabbable selector in old browsers ([32b3b58](https://github.com/skbkontur/retail-ui/commit/32b3b587acfb3ca580ad8df3d1603e6f6e1ac053))
|
|
12
|
+
* **Toast:** keep height for notification without text ([539f493](https://github.com/skbkontur/retail-ui/commit/539f49321221f29e7dffbd4cb4791504d7223b93))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [6.5.2](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@6.5.1...@skbkontur/react-ui@6.5.2) (2026-11-10)
|
|
7
19
|
|
|
8
20
|
|
|
@@ -5,7 +5,11 @@ import type { InstanceWithRootNode } from '../../lib/rootNode/index.js';
|
|
|
5
5
|
import type { SizeProp } from '../../lib/types/props.js';
|
|
6
6
|
import type { Nullable } from '../../typings/utility-types.js';
|
|
7
7
|
import type { FileUploaderControlProviderProps } from './FileUploaderControlProvider.js';
|
|
8
|
+
import { FileUploaderDropzone } from './FileUploaderDropzone.js';
|
|
8
9
|
import type { FileUploaderFileProps } from './FileUploaderFile.js';
|
|
10
|
+
import { FileUploaderFiles } from './FileUploaderFiles.js';
|
|
11
|
+
import { FileUploaderSummary } from './FileUploaderSummary.js';
|
|
12
|
+
import { FileUploaderUploader } from './FileUploaderUploader.js';
|
|
9
13
|
import type { FileUploaderAttachedFile, FileUploaderUploadButtonPosition, FileUploaderValidationSummary, FileUploaderView } from './fileUtils.js';
|
|
10
14
|
import { FileUploaderFileStatus } from './fileUtils.js';
|
|
11
15
|
type FileUploaderOverriddenProps = 'size';
|
|
@@ -75,6 +79,10 @@ interface _FileUploaderProps extends CommonProps, Omit<React.InputHTMLAttributes
|
|
|
75
79
|
* @default (props: FileUploaderFileProps) => <FileUploaderFile {...props} />
|
|
76
80
|
*/
|
|
77
81
|
renderFile?: (props: FileUploaderFileProps) => React.ReactNode;
|
|
82
|
+
/** Произвольная компоновка через FileUploader.Uploader, Files, Summary и Dropzone.
|
|
83
|
+
* В этом режиме встроенная кнопка и список не выводятся: uploaderText, uploaderIcon,
|
|
84
|
+
* uploadButtonPosition и validationSummary к слотам не применяются. */
|
|
85
|
+
children?: React.ReactNode;
|
|
78
86
|
}
|
|
79
87
|
export interface FileUploaderRef extends InstanceWithRootNode {
|
|
80
88
|
/** Устанавливает фокус на скрытом `input` выбора файла. */
|
|
@@ -98,5 +106,12 @@ export interface FileUploaderProps extends _FileUploaderProps, FileUploaderContr
|
|
|
98
106
|
/**
|
|
99
107
|
* Контрол для выбора пользователем файла на компьютере и отображения статуса его отправки на сервер.
|
|
100
108
|
*/
|
|
101
|
-
|
|
109
|
+
declare const FileUploaderBase: React.ForwardRefExoticComponent<FileUploaderProps & FileUploaderControlProviderProps & React.RefAttributes<FileUploaderRef>>;
|
|
110
|
+
/** Слоты для произвольной компоновки FileUploader. */
|
|
111
|
+
export declare const FileUploader: typeof FileUploaderBase & {
|
|
112
|
+
Uploader: typeof FileUploaderUploader;
|
|
113
|
+
Files: typeof FileUploaderFiles;
|
|
114
|
+
Summary: typeof FileUploaderSummary;
|
|
115
|
+
Dropzone: typeof FileUploaderDropzone;
|
|
116
|
+
};
|
|
102
117
|
export {};
|
|
@@ -63,15 +63,19 @@ import { CommonWrapper } from '../../internal/CommonWrapper/index.js';
|
|
|
63
63
|
import { FocusControlWrapper } from '../../internal/FocusControlWrapper/index.js';
|
|
64
64
|
import { useKeyListener } from '../../lib/events/keyListener.js';
|
|
65
65
|
import { forwardRefAndName } from '../../lib/forwardRefAndName.js';
|
|
66
|
-
import { isBrowser } from '../../lib/globalObject.js';
|
|
67
66
|
import { useEmotion, useGlobal, useStyles } from '../../lib/renderEnvironment/index.js';
|
|
68
67
|
import { useSizeControl } from '../../lib/size/useSizeControl.js';
|
|
69
68
|
import { ThemeContext } from '../../lib/theming/ThemeContext.js';
|
|
70
69
|
import { getJsRowStyles, getJsStyles, getJsTileStyles, globalClasses } from './FileUploader.styles.js';
|
|
71
70
|
import { FileUploaderControlContext } from './FileUploaderControlContext.js';
|
|
71
|
+
import { FileUploaderCustomViewContext } from './FileUploaderCustomView.js';
|
|
72
|
+
import { FileUploaderDropzone } from './FileUploaderDropzone.js';
|
|
72
73
|
import { FileUploaderFile } from './FileUploaderFile.js';
|
|
73
74
|
import { FileUploaderFileList } from './FileUploaderFileList/FileUploaderFileList.js';
|
|
75
|
+
import { FileUploaderFiles } from './FileUploaderFiles.js';
|
|
74
76
|
import { FileUploaderFileValidationResult } from './FileUploaderFileValidationResult.js';
|
|
77
|
+
import { FileUploaderSummary } from './FileUploaderSummary.js';
|
|
78
|
+
import { FileUploaderUploader } from './FileUploaderUploader.js';
|
|
75
79
|
import { FileUploaderFileStatus, getAttachedFile } from './fileUtils.js';
|
|
76
80
|
import { useControlLocale } from './hooks/useControlLocale.js';
|
|
77
81
|
import { useFileUploaderSize } from './hooks/useFileUploaderSize.js';
|
|
@@ -96,7 +100,7 @@ var _FileUploader = forwardRefAndName('FileUploader', function (props, ref) {
|
|
|
96
100
|
var jsRowStyles = useStyles(getJsRowStyles);
|
|
97
101
|
var jsTileStyles = useStyles(getJsTileStyles);
|
|
98
102
|
var keyListener = useKeyListener();
|
|
99
|
-
var disabled = props.disabled, error = props.error, warning = props.warning, _j = props.withValidationTooltip, withValidationTooltip = _j === void 0 ? false : _j, validationTooltipPosition = props.validationTooltipPosition, _k = props.withWarningIcon, withWarningIcon = _k === void 0 ? false : _k, _l = props.multiple, multiple = _l === void 0 ? false : _l, uploaderText = props.uploaderText, uploaderIcon = props.uploaderIcon, _m = props.view, view = _m === void 0 ? 'row' : _m, _o = props.uploadButtonPosition, uploadButtonPosition = _o === void 0 ? 'start' : _o, _p = props.validationSummary, validationSummary = _p === void 0 ? 'auto' : _p, _q = props.validationSummaryStart, validationSummaryStart = _q === void 0 ? 5 : _q, _r = props.width, width = _r === void 0 ? theme.fileUploaderWidth : _r, _s = props.hideFiles, hideFiles = _s === void 0 ? false : _s, onBlur = props.onBlur, onFocus = props.onFocus, onChange = props.onChange, request = props.request, validateBeforeUpload = props.validateBeforeUpload, onRequestSuccess = props.onRequestSuccess, onRequestError = props.onRequestError, sizeProp = props.size, _t = props.renderFile, renderFile = _t === void 0 ? defaultRenderFile : _t, inputProps = __rest(props, ["disabled", "error", "warning", "withValidationTooltip", "validationTooltipPosition", "withWarningIcon", "multiple", "uploaderText", "uploaderIcon", "view", "uploadButtonPosition", "validationSummary", "validationSummaryStart", "width", "hideFiles", "onBlur", "onFocus", "onChange", "request", "validateBeforeUpload", "onRequestSuccess", "onRequestError", "size", "renderFile"]);
|
|
103
|
+
var disabled = props.disabled, error = props.error, warning = props.warning, _j = props.withValidationTooltip, withValidationTooltip = _j === void 0 ? false : _j, validationTooltipPosition = props.validationTooltipPosition, _k = props.withWarningIcon, withWarningIcon = _k === void 0 ? false : _k, _l = props.multiple, multiple = _l === void 0 ? false : _l, uploaderText = props.uploaderText, uploaderIcon = props.uploaderIcon, _m = props.view, view = _m === void 0 ? 'row' : _m, _o = props.uploadButtonPosition, uploadButtonPosition = _o === void 0 ? 'start' : _o, _p = props.validationSummary, validationSummary = _p === void 0 ? 'auto' : _p, _q = props.validationSummaryStart, validationSummaryStart = _q === void 0 ? 5 : _q, _r = props.width, width = _r === void 0 ? theme.fileUploaderWidth : _r, _s = props.hideFiles, hideFiles = _s === void 0 ? false : _s, onBlur = props.onBlur, onFocus = props.onFocus, onChange = props.onChange, request = props.request, validateBeforeUpload = props.validateBeforeUpload, onRequestSuccess = props.onRequestSuccess, onRequestError = props.onRequestError, sizeProp = props.size, _t = props.renderFile, renderFile = _t === void 0 ? defaultRenderFile : _t, children = props.children, inputProps = __rest(props, ["disabled", "error", "warning", "withValidationTooltip", "validationTooltipPosition", "withWarningIcon", "multiple", "uploaderText", "uploaderIcon", "view", "uploadButtonPosition", "validationSummary", "validationSummaryStart", "width", "hideFiles", "onBlur", "onFocus", "onChange", "request", "validateBeforeUpload", "onRequestSuccess", "onRequestError", "size", "renderFile", "children"]);
|
|
100
104
|
var size = useSizeControl(sizeProp);
|
|
101
105
|
var _u = useContext(FileUploaderControlContext), files = _u.files, setFiles = _u.setFiles, removeFile = _u.removeFile, reset = _u.reset, setFileValidationResult = _u.setFileValidationResult;
|
|
102
106
|
var locale = useControlLocale();
|
|
@@ -207,10 +211,8 @@ var _FileUploader = forwardRefAndName('FileUploader', function (props, ref) {
|
|
|
207
211
|
}
|
|
208
212
|
}, [handleChange, disabled]);
|
|
209
213
|
var _w = useDrop({ onDrop: handleDrop }), isDraggable = _w.isDraggable, labelRef = _w.ref;
|
|
210
|
-
var
|
|
211
|
-
|
|
212
|
-
windowRef.current = globalObject.document;
|
|
213
|
-
}
|
|
214
|
+
var getInputDocument = useCallback(function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument; }, []);
|
|
215
|
+
var isWindowDraggable = useDrop({ parent: getInputDocument }).isDraggable;
|
|
214
216
|
var focus = useCallback(function () {
|
|
215
217
|
var _a;
|
|
216
218
|
keyListener.isTabPressed = true;
|
|
@@ -220,24 +222,43 @@ var _FileUploader = forwardRefAndName('FileUploader', function (props, ref) {
|
|
|
220
222
|
var _a;
|
|
221
223
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
222
224
|
}, []);
|
|
225
|
+
var openFileDialog = useCallback(function () {
|
|
226
|
+
var _a;
|
|
227
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
228
|
+
}, []);
|
|
223
229
|
var removeFileFromNativeInput = useCallback(function (fileId) {
|
|
224
|
-
var
|
|
230
|
+
var _a, _b;
|
|
231
|
+
var input = inputRef.current;
|
|
232
|
+
var DataTransferConstructor = (_b = (_a = input === null || input === void 0 ? void 0 : input.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.DataTransfer) !== null && _b !== void 0 ? _b : globalObject.DataTransfer;
|
|
233
|
+
if (!input || !DataTransferConstructor) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
var dataTransfer = new DataTransferConstructor();
|
|
225
237
|
files
|
|
226
238
|
.filter(function (f) { return f.id !== fileId; })
|
|
227
239
|
.forEach(function (file) {
|
|
228
240
|
dataTransfer.items.add(file.originalFile);
|
|
229
241
|
});
|
|
230
|
-
|
|
242
|
+
input.files = dataTransfer.files;
|
|
231
243
|
}, [files]);
|
|
232
244
|
var handleRemoveFile = useCallback(function (fileId) {
|
|
233
245
|
removeFile(fileId);
|
|
234
246
|
removeFileFromNativeInput(fileId);
|
|
235
247
|
}, [removeFileFromNativeInput, removeFile]);
|
|
236
248
|
var handleReset = useCallback(function () {
|
|
249
|
+
var _a, _b;
|
|
237
250
|
reset();
|
|
238
|
-
var
|
|
239
|
-
|
|
240
|
-
|
|
251
|
+
var input = inputRef.current;
|
|
252
|
+
var DataTransferConstructor = (_b = (_a = input === null || input === void 0 ? void 0 : input.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.DataTransfer) !== null && _b !== void 0 ? _b : globalObject.DataTransfer;
|
|
253
|
+
if (input) {
|
|
254
|
+
if (DataTransferConstructor) {
|
|
255
|
+
input.files = new DataTransferConstructor().files;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
input.value = '';
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}, [reset]);
|
|
241
262
|
useImperativeHandle(ref, function () { return ({
|
|
242
263
|
focus: focus,
|
|
243
264
|
blur: blur,
|
|
@@ -245,7 +266,7 @@ var _FileUploader = forwardRefAndName('FileUploader', function (props, ref) {
|
|
|
245
266
|
removeFile: handleRemoveFile,
|
|
246
267
|
getRootNode: function () { return rootNodeRef.current; },
|
|
247
268
|
}); }, [ref, blur, focus, handleReset, handleRemoveFile]);
|
|
248
|
-
var
|
|
269
|
+
var _x = useState(false), focusedByTab = _x[0], setFocusedByTab = _x[1];
|
|
249
270
|
var handleInputChange = function (event) {
|
|
250
271
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
251
272
|
handleChange(event.target.files);
|
|
@@ -304,12 +325,15 @@ var _FileUploader = forwardRefAndName('FileUploader', function (props, ref) {
|
|
|
304
325
|
var afterLinkTextClassNames = cx(globalClasses.afterLinkText, hasOneFileForSingle ? jsStyles.afterLinkText_HasFiles() : jsStyles.afterLinkText());
|
|
305
326
|
var linkClassNames = cx(jsStyles.link(theme), !disabled && hovered && jsStyles.linkHovered(theme), disabled && jsStyles.linkDisabled(theme));
|
|
306
327
|
useEffect(function () {
|
|
307
|
-
|
|
328
|
+
var _a, _b;
|
|
329
|
+
var input = inputRef.current;
|
|
330
|
+
var DataTransferConstructor = (_b = (_a = input === null || input === void 0 ? void 0 : input.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.DataTransfer) !== null && _b !== void 0 ? _b : globalObject.DataTransfer;
|
|
331
|
+
if (!files.length || !input || !DataTransferConstructor) {
|
|
308
332
|
return;
|
|
309
333
|
}
|
|
310
|
-
var dataTransfer = new
|
|
334
|
+
var dataTransfer = new DataTransferConstructor();
|
|
311
335
|
files.forEach(function (file) { return dataTransfer.items.add(file.originalFile); });
|
|
312
|
-
|
|
336
|
+
input.files = dataTransfer.files;
|
|
313
337
|
}, []);
|
|
314
338
|
var rootNodeRef = useRef(null);
|
|
315
339
|
var icon = uploaderIcon !== null && uploaderIcon !== void 0 ? uploaderIcon : React.createElement(UploadIcon, { size: size, view: view });
|
|
@@ -324,7 +348,7 @@ var _FileUploader = forwardRefAndName('FileUploader', function (props, ref) {
|
|
|
324
348
|
!isSingleMode &&
|
|
325
349
|
!!files.length && (React.createElement(FileUploaderFileList, { renderFile: renderFile, size: size, view: view, onRemove: handleRemoveFile, validationTooltipPosition: validationTooltipPosition, withValidationTooltip: withValidationTooltip, validationSummary: validationSummary, validationSummaryStart: validationSummaryStart, withWarningIcon: withWarningIcon, disabled: disabled })));
|
|
326
350
|
};
|
|
327
|
-
var fileProps = {
|
|
351
|
+
var fileProps = useMemoObject({
|
|
328
352
|
file: files[0],
|
|
329
353
|
size: size,
|
|
330
354
|
view: view,
|
|
@@ -336,24 +360,53 @@ var _FileUploader = forwardRefAndName('FileUploader', function (props, ref) {
|
|
|
336
360
|
withWarningIcon: withWarningIcon,
|
|
337
361
|
hovered: hovered,
|
|
338
362
|
disabled: disabled,
|
|
339
|
-
};
|
|
340
|
-
var fileElement = renderFile(fileProps);
|
|
363
|
+
});
|
|
364
|
+
var fileElement = children ? null : renderFile(fileProps);
|
|
365
|
+
var input = (React.createElement(FocusControlWrapper, { onBlurWhenDisabled: function () { return setFocusedByTab(false); } },
|
|
366
|
+
React.createElement("input", __assign({}, inputProps, { "data-tid": FileUploaderDataTids.input, ref: inputRef, tabIndex: disabled ? -1 : 0, type: "file", disabled: disabled, multiple: multiple, className: jsStyles.visuallyHidden(), onClick: stopPropagation, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur }))));
|
|
367
|
+
var customView = useMemoObject({
|
|
368
|
+
files: files,
|
|
369
|
+
disabled: !!disabled,
|
|
370
|
+
multiple: multiple,
|
|
371
|
+
input: input,
|
|
372
|
+
openFileDialog: openFileDialog,
|
|
373
|
+
onDrop: handleDrop,
|
|
374
|
+
onRemove: handleRemoveFile,
|
|
375
|
+
renderFile: renderFile,
|
|
376
|
+
fileProps: fileProps,
|
|
377
|
+
});
|
|
378
|
+
var rootStyle = useMemoObject({
|
|
379
|
+
width: isTileView && !multiple && props.width === undefined ? theme.fileUploaderTileWidth : width,
|
|
380
|
+
});
|
|
381
|
+
var uploadButtonWrapperStyle = useMemoObject({
|
|
382
|
+
width: isTileView && !multiple && props.width !== undefined ? width : undefined,
|
|
383
|
+
});
|
|
384
|
+
if (children) {
|
|
385
|
+
return (React.createElement(CommonWrapper, __assign({}, props),
|
|
386
|
+
React.createElement("div", { "data-tid": FileUploaderDataTids.root, style: props.width === undefined ? undefined : rootStyle, ref: rootNodeRef },
|
|
387
|
+
React.createElement(FileUploaderCustomViewContext.Provider, { value: customView }, children))));
|
|
388
|
+
}
|
|
341
389
|
return (React.createElement(CommonWrapper, __assign({}, props),
|
|
342
|
-
React.createElement("div", { "data-tid": FileUploaderDataTids.root, className: rootClassNames, style:
|
|
390
|
+
React.createElement("div", { "data-tid": FileUploaderDataTids.root, className: rootClassNames, style: rootStyle, ref: rootNodeRef },
|
|
343
391
|
uploadButtonPosition === 'end' && renderFileList(),
|
|
344
|
-
React.createElement("div", { className: uploadButtonWrapperClassNames },
|
|
392
|
+
React.createElement("div", { className: uploadButtonWrapperClassNames, style: uploadButtonWrapperStyle },
|
|
345
393
|
React.createElement("label", { onMouseEnter: function () { return setHovered(true); }, onMouseLeave: function () { return setHovered(false); }, ref: labelRef, className: uploadButtonClassNames },
|
|
346
394
|
!hasOneFileForSingle && React.createElement("div", { className: uploadButtonIconClassNames }, icon),
|
|
347
395
|
React.createElement("div", { "data-tid": FileUploaderDataTids.content, className: contentClassNames },
|
|
348
396
|
renderChooseFileText(),
|
|
349
397
|
React.createElement("div", { className: afterLinkTextClassNames }, hasOneFileForSingle && (React.createElement("div", { ref: fileDivRef, className: jsStyles.singleFile() }, fileElement)))),
|
|
350
|
-
|
|
351
|
-
React.createElement("input", __assign({}, inputProps, { "data-tid": FileUploaderDataTids.input, ref: inputRef, tabIndex: disabled ? -1 : 0, type: "file", disabled: disabled, multiple: multiple, className: jsStyles.visuallyHidden(), onClick: stopPropagation, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur }))))),
|
|
398
|
+
input)),
|
|
352
399
|
uploadButtonPosition === 'start' && renderFileList())));
|
|
353
400
|
});
|
|
354
401
|
/**
|
|
355
402
|
* Контрол для выбора пользователем файла на компьютере и отображения статуса его отправки на сервер.
|
|
356
403
|
*/
|
|
357
|
-
|
|
404
|
+
var FileUploaderBase = withFileUploaderControlProvider(React.memo(_FileUploader));
|
|
405
|
+
/** Слоты для произвольной компоновки FileUploader. */
|
|
406
|
+
export var FileUploader = FileUploaderBase;
|
|
407
|
+
FileUploader.Uploader = FileUploaderUploader;
|
|
408
|
+
FileUploader.Files = FileUploaderFiles;
|
|
409
|
+
FileUploader.Summary = FileUploaderSummary;
|
|
410
|
+
FileUploader.Dropzone = FileUploaderDropzone;
|
|
358
411
|
FileUploader.displayName = 'FileUploader';
|
|
359
412
|
//# sourceMappingURL=FileUploader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploader.js","sourceRoot":"","sources":["FileUploader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzG,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,0BA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import React, { useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';\n\nimport { useDrop } from '../../hooks/useDrop.js';\nimport { useMemoObject } from '../../hooks/useMemoObject.js';\nimport type { CommonProps } from '../../internal/CommonWrapper/index.js';\nimport { CommonWrapper } from '../../internal/CommonWrapper/index.js';\nimport { FocusControlWrapper } from '../../internal/FocusControlWrapper/index.js';\nimport type { PopupPositionsType, ShortPopupPositionsType } from '../../internal/Popup/index.js';\nimport { useKeyListener } from '../../lib/events/keyListener.js';\nimport { forwardRefAndName } from '../../lib/forwardRefAndName.js';\nimport { isBrowser } from '../../lib/globalObject.js';\nimport { useEmotion, useGlobal, useStyles } from '../../lib/renderEnvironment/index.js';\nimport type { InstanceWithRootNode } from '../../lib/rootNode/index.js';\nimport { useSizeControl } from '../../lib/size/useSizeControl.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport type { SizeProp } from '../../lib/types/props.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport { getJsRowStyles, getJsStyles, getJsTileStyles, globalClasses } from './FileUploader.styles.js';\nimport { FileUploaderControlContext } from './FileUploaderControlContext.js';\nimport type { FileUploaderControlProviderProps } from './FileUploaderControlProvider.js';\nimport { FileUploaderFile } from './FileUploaderFile.js';\nimport type { FileUploaderFileProps } from './FileUploaderFile.js';\nimport { FileUploaderFileList } from './FileUploaderFileList/FileUploaderFileList.js';\nimport { FileUploaderFileValidationResult } from './FileUploaderFileValidationResult.js';\nimport type {\n FileUploaderAttachedFile,\n FileUploaderUploadButtonPosition,\n FileUploaderValidationSummary,\n FileUploaderView,\n} from './fileUtils.js';\nimport { FileUploaderFileStatus, getAttachedFile } from './fileUtils.js';\nimport { useControlLocale } from './hooks/useControlLocale.js';\nimport { useFileUploaderSize } from './hooks/useFileUploaderSize.js';\nimport { useUpload } from './hooks/useUpload.js';\nimport { UploadIcon } from './icons/UploadIcon.js';\nimport { withFileUploaderControlProvider } from './withFileUploaderControlProvider.js';\n\nconst stopPropagation: React.ReactEventHandler = (e) => e.stopPropagation();\n\ntype FileUploaderOverriddenProps = 'size';\n\ninterface _FileUploaderProps\n extends CommonProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, FileUploaderOverriddenProps> {\n /** Переводит контрол в состояние ошибки. */\n /** Состояние ошибки всего контрола */\n error?: boolean;\n\n /** Переводит контрол в состояние предупреждения. */\n /** Состояние предупреждения всего контрола. */\n warning?: boolean;\n\n /** Расположение тултипа с текстом валидации файла.\n * @default 'top left' */\n validationTooltipPosition?: ShortPopupPositionsType | PopupPositionsType;\n\n /** Включает отображение текста валидации файла во всплывающей подсказке вместо строки рядом с именем.\n * @default false */\n withValidationTooltip?: boolean;\n\n /** Включает отображение иконки предупреждения (восклицательный знак) при статусе предупреждения у файла.\n * @default false */\n withWarningIcon?: boolean;\n\n /** Ширина контрола. */\n width?: React.CSSProperties['width'];\n\n /** Размер контрола и вложенных элементов.\n * @default small */\n size?: SizeProp;\n\n /** Скрывает встроенный список файлов.\n * @default false */\n hideFiles?: boolean;\n\n /** Текст ссылки выбора файла.\n * @default \"Выберите файл\"\n */\n uploaderText?: string;\n\n /** Иконка в кнопке загрузки.\n */\n uploaderIcon?: React.ReactNode;\n\n /** Режим отображения списка файлов: строка (`row`) или плитка (`tile`).\n * @default row\n */\n view?: FileUploaderView;\n\n /** Режим блока-саммари по ошибкам и предупреждениям:\n * - `auto` — от порога `validationSummaryStart`,\n * - `enabled` / `disabled` — всегда или никогда.\n * @default auto\n */\n validationSummary?: FileUploaderValidationSummary;\n\n /** Порог числа файлов для показа саммари при `validationSummary=\"auto\"`.\n * @default 5 */\n validationSummaryStart?: number;\n\n /** Расположение кнопки загрузки относительно списка: в начале или в конце.\n * @default start */\n uploadButtonPosition?: FileUploaderUploadButtonPosition;\n\n /** Включает асинхронный режим загрузки файлов.\n * Отклонённый промис помечает файл(ы) ошибкой загрузки.\n */\n request?: (file: FileUploaderAttachedFile) => Promise<void>;\n\n /** Колбэк после успешного завершения `request` для файла. */\n onRequestSuccess?: (fileId: string) => void;\n\n /** Колбэк после ошибки `request` для файла. */\n onRequestError?: (fileId: string) => void;\n\n /** Проверка файла после выбора и до `request`: строка или `{ message, status }` — ошибка/предупреждение. Пустой результат — файл проходит.\n */\n validateBeforeUpload?: (\n file: FileUploaderAttachedFile,\n ) => Promise<Nullable<string | { message: string; status: FileUploaderFileStatus }>>;\n\n /**\n * Задаёт метод отрисовки файлов.\n * @default (props: FileUploaderFileProps) => <FileUploaderFile {...props} />\n */\n renderFile?: (props: FileUploaderFileProps) => React.ReactNode;\n}\n\nexport interface FileUploaderRef extends InstanceWithRootNode {\n /** Устанавливает фокус на скрытом `input` выбора файла. */\n focus: () => void;\n /** Снимает фокус с `input` выбора файла. */\n blur: () => void;\n /** Очищает список файлов и значения `input`. */\n reset: () => void;\n /** Удаляет файл по id с вызовом `onRemove` и `onValueChange`. */\n removeFile: (fileId: string) => void;\n}\n\nexport type FileUploader = FileUploaderRef;\n\nexport const FileUploaderDataTids = {\n root: 'FileUploader__root',\n content: 'FileUploader__content',\n link: 'FileUploader__link',\n input: 'FileUploader__input',\n} as const;\n\nconst defaultRenderFile = (props: FileUploaderFileProps) => <FileUploaderFile {...props} />;\n\nconst _FileUploader = forwardRefAndName<FileUploaderRef, _FileUploaderProps>('FileUploader', (props, ref) => {\n const theme = useContext(ThemeContext);\n const globalObject = useGlobal();\n const { cx } = useEmotion();\n const jsStyles = useStyles(getJsStyles);\n const jsRowStyles = useStyles(getJsRowStyles);\n const jsTileStyles = useStyles(getJsTileStyles);\n const keyListener = useKeyListener();\n\n const {\n disabled,\n error,\n warning,\n withValidationTooltip = false,\n validationTooltipPosition,\n withWarningIcon = false,\n multiple = false,\n uploaderText,\n uploaderIcon,\n view = 'row',\n uploadButtonPosition = 'start',\n validationSummary = 'auto',\n validationSummaryStart = 5,\n width = theme.fileUploaderWidth,\n hideFiles = false,\n onBlur,\n onFocus,\n onChange,\n request,\n validateBeforeUpload,\n onRequestSuccess,\n onRequestError,\n size: sizeProp,\n renderFile = defaultRenderFile,\n ...inputProps\n } = props;\n const size = useSizeControl(sizeProp);\n\n const { files, setFiles, removeFile, reset, setFileValidationResult } = useContext(FileUploaderControlContext);\n\n const locale = useControlLocale();\n\n const inputRef = useRef<HTMLInputElement>(null);\n const fileDivRef = useRef<HTMLDivElement>(null);\n\n const isAsync = !!request;\n const isSingleMode = !multiple;\n\n const [hovered, setHovered] = useState(false);\n const upload = useUpload(request, onRequestSuccess, onRequestError);\n\n const tryValidateAndUpload = useCallback(\n (files: FileUploaderAttachedFile[]) => {\n files.forEach(async (file) => {\n const validationMessage = validateBeforeUpload && (await validateBeforeUpload(file));\n\n if (!validationMessage) {\n isAsync && upload(file);\n } else if (typeof validationMessage === 'object') {\n setFileValidationResult(\n file.id,\n FileUploaderFileValidationResult.error(validationMessage.message),\n validationMessage.status,\n );\n } else {\n setFileValidationResult(\n file.id,\n FileUploaderFileValidationResult.error(validationMessage),\n FileUploaderFileStatus.Error,\n );\n }\n });\n },\n [validateBeforeUpload, isAsync, upload, setFileValidationResult],\n );\n\n const isTileView = view === 'tile';\n const jsViewStyles = isTileView ? jsTileStyles : jsRowStyles;\n\n const sizeClassName = useFileUploaderSize(size, {\n small: jsViewStyles.sizeSmall(theme),\n medium: jsViewStyles.sizeMedium(theme),\n large: jsViewStyles.sizeLarge(theme),\n });\n\n const uploadButtonTileWithFileClassName = useFileUploaderSize(size, {\n small: jsTileStyles.uploadButtonTileWithFileSmall(theme),\n medium: jsTileStyles.uploadButtonTileWithFileMedium(theme),\n large: jsTileStyles.uploadButtonTileWithFileLarge(theme),\n });\n\n const uploadButtonIconGapClass = useFileUploaderSize(size, {\n small: jsViewStyles.uploadButtonIconGapSmall(theme),\n medium: jsViewStyles.uploadButtonIconGapMedium(theme),\n large: jsViewStyles.uploadButtonIconGapLarge(theme),\n });\n\n const sizeIconClass = useFileUploaderSize(size, {\n small: jsStyles.iconSmall(theme),\n medium: jsStyles.iconMedium(theme),\n large: jsStyles.iconLarge(theme),\n });\n\n const sizeWrapperClass = useFileUploaderSize(size, {\n small: jsTileStyles.uploadButtonWrapperSmall(theme),\n medium: jsTileStyles.uploadButtonWrapperMedium(theme),\n large: jsTileStyles.uploadButtonWrapperLarge(theme),\n });\n\n const sizeWrapperEmptyFileClass = useFileUploaderSize(size, {\n small: jsTileStyles.uploadButtonWrapperEmptyFileSmall(theme),\n medium: jsTileStyles.uploadButtonWrapperEmptyFileMedium(theme),\n large: jsTileStyles.uploadButtonWrapperEmptyFileLarge(theme),\n });\n\n const contentInnerClass = useFileUploaderSize(size, {\n small: jsStyles.contentInnerSmall(theme),\n medium: jsStyles.contentInnerMedium(theme),\n large: jsStyles.contentInnerLarge(theme),\n });\n\n /** common part **/\n const handleChange = useCallback(\n (newFiles: FileList | null) => {\n if (!newFiles || !newFiles.length) {\n return;\n }\n\n let filesArray = Array.from(newFiles);\n\n if (isSingleMode) {\n filesArray = [filesArray[0]];\n }\n\n const attachedFiles = filesArray.map(getAttachedFile);\n\n if (isSingleMode && attachedFiles.length && files.length) {\n removeFile(files[0].id);\n }\n\n if (attachedFiles.length) {\n setFiles(attachedFiles);\n tryValidateAndUpload(attachedFiles);\n }\n },\n [tryValidateAndUpload, setFiles, isSingleMode, files, removeFile],\n );\n\n const handleDrop = useCallback(\n (event: DragEvent) => {\n if (disabled) {\n return;\n }\n\n const { dataTransfer } = event;\n if (dataTransfer) {\n if (isSingleMode && dataTransfer.files.length > 1) {\n dataTransfer.dropEffect = 'none';\n return;\n }\n if (dataTransfer.files?.length > 0) {\n inputRef.current && (inputRef.current.files = dataTransfer.files);\n handleChange(dataTransfer.files);\n }\n }\n },\n [handleChange, disabled],\n );\n\n const { isDraggable, ref: labelRef } = useDrop<HTMLLabelElement>({ onDrop: handleDrop });\n const { isDraggable: isWindowDraggable, ref: windowRef } = useDrop<Document>();\n\n if (isBrowser(globalObject)) {\n windowRef.current = globalObject.document;\n }\n\n const focus = useCallback(() => {\n keyListener.isTabPressed = true;\n inputRef.current?.focus();\n }, []);\n\n const blur = useCallback(() => {\n inputRef.current?.blur();\n }, []);\n\n const removeFileFromNativeInput = useCallback(\n (fileId: string) => {\n const dataTransfer = new DataTransfer();\n files\n .filter((f) => f.id !== fileId)\n .forEach((file) => {\n dataTransfer.items.add(file.originalFile);\n });\n inputRef.current && (inputRef.current.files = dataTransfer.files);\n },\n [files],\n );\n\n const handleRemoveFile = useCallback(\n (fileId: string) => {\n removeFile(fileId);\n removeFileFromNativeInput(fileId);\n },\n [removeFileFromNativeInput, removeFile],\n );\n\n const handleReset = useCallback(() => {\n reset();\n const dataTransfer = new DataTransfer();\n inputRef.current && (inputRef.current.files = dataTransfer.files);\n }, [reset, handleRemoveFile]);\n\n useImperativeHandle(\n ref,\n () => ({\n focus,\n blur,\n reset: handleReset,\n removeFile: handleRemoveFile,\n getRootNode: () => rootNodeRef.current,\n }),\n [ref, blur, focus, handleReset, handleRemoveFile],\n );\n\n const [focusedByTab, setFocusedByTab] = useState(false);\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n handleChange(event.target.files);\n setHovered(false);\n };\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n if (!disabled) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n globalObject.requestAnimationFrame?.(() => {\n if (keyListener.isTabPressed) {\n setFocusedByTab(true);\n }\n });\n onFocus?.(e);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocusedByTab(false);\n if (!disabled) {\n onBlur?.(e);\n }\n };\n\n const hasFiles = files.length > 0;\n const hasOneFile = files.length === 1;\n const hasOneFileForSingle = isSingleMode && hasOneFile && !hideFiles;\n\n const hasError = !!error || files[0]?.status === FileUploaderFileStatus.Error;\n const hasWarning = !!warning || files[0]?.status === FileUploaderFileStatus.Warning;\n\n const uploadButtonClassNames = cx(\n jsStyles.uploadButton(theme),\n jsViewStyles.uploadButton(),\n sizeClassName,\n hasOneFileForSingle && jsViewStyles.uploadButtonWithFile(theme),\n focusedByTab && jsStyles.uploadButtonFocus(theme),\n disabled && {\n [jsStyles.disabled(theme)]: true,\n [jsStyles.disabledBackground(theme)]: !hasFiles,\n },\n (focusedByTab || !hasOneFileForSingle) && {\n [jsStyles.warningButton(theme)]: hasWarning,\n [jsStyles.errorButton(theme)]: hasError,\n },\n hasOneFileForSingle && {\n [uploadButtonTileWithFileClassName]: isTileView,\n [jsTileStyles.verticalAlign()]: isTileView,\n [jsStyles.warningFile(theme)]: (!isTileView || hovered) && hasWarning,\n [jsStyles.errorFile(theme)]: (!isTileView || hovered) && hasError,\n },\n !disabled &&\n hovered && {\n [jsStyles.hovered(theme)]: true,\n },\n isDraggable && !disabled && jsStyles.dragOver(theme),\n );\n\n const canDrop = isWindowDraggable && !disabled;\n const uploadButtonWrapperClassNames = cx(\n isTileView && {\n [sizeWrapperClass]: true,\n [sizeWrapperEmptyFileClass]: !hasOneFileForSingle,\n },\n jsViewStyles.uploadButtonWrapper(),\n canDrop && jsStyles.windowDragOver(theme),\n );\n\n const uploadButtonIconClassNames = cx(\n jsStyles.icon(theme),\n sizeIconClass,\n disabled && jsStyles.iconDisabled(theme),\n uploadButtonIconGapClass,\n );\n\n const rootClassNames = cx(jsStyles.root(theme), !isTileView && jsRowStyles.root());\n\n const contentClassNames = cx(jsViewStyles.content(), {\n [jsViewStyles.contentWithFiles()]: hasOneFileForSingle,\n [contentInnerClass]: !isTileView && (!files.length || !isSingleMode),\n });\n\n const afterLinkTextClassNames = cx(\n globalClasses.afterLinkText,\n hasOneFileForSingle ? jsStyles.afterLinkText_HasFiles() : jsStyles.afterLinkText(),\n );\n\n const linkClassNames = cx(\n jsStyles.link(theme),\n !disabled && hovered && jsStyles.linkHovered(theme),\n disabled && jsStyles.linkDisabled(theme),\n );\n\n useEffect(() => {\n if (!files || !files.length || !inputRef.current) {\n return;\n }\n\n const dataTransfer = new DataTransfer();\n files.forEach((file) => dataTransfer.items.add(file.originalFile));\n inputRef.current.files = dataTransfer.files;\n }, []);\n\n const rootNodeRef = useRef(null);\n\n const icon = uploaderIcon ?? <UploadIcon size={size} view={view} />;\n const chooseFileText = uploaderText ?? locale.chooseFile;\n const chooseFileLocale = `${chooseFileText}${String.fromCharCode(0xa0)}`; /* */\n const hideUploaderText = isTileView && uploaderText === '';\n const renderChooseFileText = () =>\n !hideUploaderText && (\n <span data-tid={FileUploaderDataTids.link} className={linkClassNames}>\n {!hasOneFileForSingle && chooseFileLocale}\n </span>\n );\n\n const renderFileList = () => {\n return (\n !hideFiles &&\n !isSingleMode &&\n !!files.length && (\n <FileUploaderFileList\n renderFile={renderFile}\n size={size}\n view={view}\n onRemove={handleRemoveFile}\n validationTooltipPosition={validationTooltipPosition}\n withValidationTooltip={withValidationTooltip}\n validationSummary={validationSummary}\n validationSummaryStart={validationSummaryStart}\n withWarningIcon={withWarningIcon}\n disabled={disabled}\n />\n )\n );\n };\n\n const fileProps: FileUploaderFileProps = {\n file: files[0],\n size,\n view,\n onRemove: handleRemoveFile,\n error,\n warning,\n withValidationTooltip,\n validationTooltipPosition,\n withWarningIcon,\n hovered,\n disabled,\n };\n\n const fileElement = renderFile(fileProps);\n\n return (\n <CommonWrapper {...props}>\n <div\n data-tid={FileUploaderDataTids.root}\n className={rootClassNames}\n style={useMemoObject({ width: isTileView && !multiple ? theme.fileUploaderTileWidth : width })}\n ref={rootNodeRef}\n >\n {uploadButtonPosition === 'end' && renderFileList()}\n <div className={uploadButtonWrapperClassNames}>\n <label\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n ref={labelRef}\n className={uploadButtonClassNames}\n >\n {!hasOneFileForSingle && <div className={uploadButtonIconClassNames}>{icon}</div>}\n <div data-tid={FileUploaderDataTids.content} className={contentClassNames}>\n {renderChooseFileText()}\n <div className={afterLinkTextClassNames}>\n {hasOneFileForSingle && (\n <div ref={fileDivRef} className={jsStyles.singleFile()}>\n {fileElement}\n </div>\n )}\n </div>\n </div>\n <FocusControlWrapper onBlurWhenDisabled={() => setFocusedByTab(false)}>\n <input\n {...inputProps}\n data-tid={FileUploaderDataTids.input}\n ref={inputRef}\n tabIndex={disabled ? -1 : 0}\n type=\"file\"\n disabled={disabled}\n multiple={multiple}\n className={jsStyles.visuallyHidden()}\n onClick={stopPropagation}\n onChange={handleInputChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n />\n </FocusControlWrapper>\n </label>\n </div>\n {uploadButtonPosition === 'start' && renderFileList()}\n </div>\n </CommonWrapper>\n );\n});\n\nexport interface FileUploaderProps extends _FileUploaderProps, FileUploaderControlProviderProps {}\n\n/**\n * Контрол для выбора пользователем файла на компьютере и отображения статуса его отправки на сервер.\n */\nexport const FileUploader = withFileUploaderControlProvider<FileUploaderProps, FileUploaderRef>(\n React.memo(_FileUploader),\n);\n\nFileUploader.displayName = 'FileUploader';\n"]}
|
|
1
|
+
{"version":3,"file":"FileUploader.js","sourceRoot":"","sources":["FileUploader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzG,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACl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useImperativeHandle, useRef, useState } from 'react';\n\nimport { useDrop } from '../../hooks/useDrop.js';\nimport { useMemoObject } from '../../hooks/useMemoObject.js';\nimport type { CommonProps } from '../../internal/CommonWrapper/index.js';\nimport { CommonWrapper } from '../../internal/CommonWrapper/index.js';\nimport { FocusControlWrapper } from '../../internal/FocusControlWrapper/index.js';\nimport type { PopupPositionsType, ShortPopupPositionsType } from '../../internal/Popup/index.js';\nimport { useKeyListener } from '../../lib/events/keyListener.js';\nimport { forwardRefAndName } from '../../lib/forwardRefAndName.js';\nimport { useEmotion, useGlobal, useStyles } from '../../lib/renderEnvironment/index.js';\nimport type { InstanceWithRootNode } from '../../lib/rootNode/index.js';\nimport { useSizeControl } from '../../lib/size/useSizeControl.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport type { SizeProp } from '../../lib/types/props.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport { getJsRowStyles, getJsStyles, getJsTileStyles, globalClasses } from './FileUploader.styles.js';\nimport { FileUploaderControlContext } from './FileUploaderControlContext.js';\nimport type { FileUploaderControlProviderProps } from './FileUploaderControlProvider.js';\nimport { FileUploaderCustomViewContext } from './FileUploaderCustomView.js';\nimport { FileUploaderDropzone } from './FileUploaderDropzone.js';\nimport { FileUploaderFile } from './FileUploaderFile.js';\nimport type { FileUploaderFileProps } from './FileUploaderFile.js';\nimport { FileUploaderFileList } from './FileUploaderFileList/FileUploaderFileList.js';\nimport { FileUploaderFiles } from './FileUploaderFiles.js';\nimport { FileUploaderFileValidationResult } from './FileUploaderFileValidationResult.js';\nimport { FileUploaderSummary } from './FileUploaderSummary.js';\nimport { FileUploaderUploader } from './FileUploaderUploader.js';\nimport type {\n FileUploaderAttachedFile,\n FileUploaderUploadButtonPosition,\n FileUploaderValidationSummary,\n FileUploaderView,\n} from './fileUtils.js';\nimport { FileUploaderFileStatus, getAttachedFile } from './fileUtils.js';\nimport { useControlLocale } from './hooks/useControlLocale.js';\nimport { useFileUploaderSize } from './hooks/useFileUploaderSize.js';\nimport { useUpload } from './hooks/useUpload.js';\nimport { UploadIcon } from './icons/UploadIcon.js';\nimport { withFileUploaderControlProvider } from './withFileUploaderControlProvider.js';\n\nconst stopPropagation: React.ReactEventHandler = (e) => e.stopPropagation();\n\ntype FileUploaderOverriddenProps = 'size';\n\ninterface _FileUploaderProps\n extends CommonProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, FileUploaderOverriddenProps> {\n /** Переводит контрол в состояние ошибки. */\n /** Состояние ошибки всего контрола */\n error?: boolean;\n\n /** Переводит контрол в состояние предупреждения. */\n /** Состояние предупреждения всего контрола. */\n warning?: boolean;\n\n /** Расположение тултипа с текстом валидации файла.\n * @default 'top left' */\n validationTooltipPosition?: ShortPopupPositionsType | PopupPositionsType;\n\n /** Включает отображение текста валидации файла во всплывающей подсказке вместо строки рядом с именем.\n * @default false */\n withValidationTooltip?: boolean;\n\n /** Включает отображение иконки предупреждения (восклицательный знак) при статусе предупреждения у файла.\n * @default false */\n withWarningIcon?: boolean;\n\n /** Ширина контрола. */\n width?: React.CSSProperties['width'];\n\n /** Размер контрола и вложенных элементов.\n * @default small */\n size?: SizeProp;\n\n /** Скрывает встроенный список файлов.\n * @default false */\n hideFiles?: boolean;\n\n /** Текст ссылки выбора файла.\n * @default \"Выберите файл\"\n */\n uploaderText?: string;\n\n /** Иконка в кнопке загрузки.\n */\n uploaderIcon?: React.ReactNode;\n\n /** Режим отображения списка файлов: строка (`row`) или плитка (`tile`).\n * @default row\n */\n view?: FileUploaderView;\n\n /** Режим блока-саммари по ошибкам и предупреждениям:\n * - `auto` — от порога `validationSummaryStart`,\n * - `enabled` / `disabled` — всегда или никогда.\n * @default auto\n */\n validationSummary?: FileUploaderValidationSummary;\n\n /** Порог числа файлов для показа саммари при `validationSummary=\"auto\"`.\n * @default 5 */\n validationSummaryStart?: number;\n\n /** Расположение кнопки загрузки относительно списка: в начале или в конце.\n * @default start */\n uploadButtonPosition?: FileUploaderUploadButtonPosition;\n\n /** Включает асинхронный режим загрузки файлов.\n * Отклонённый промис помечает файл(ы) ошибкой загрузки.\n */\n request?: (file: FileUploaderAttachedFile) => Promise<void>;\n\n /** Колбэк после успешного завершения `request` для файла. */\n onRequestSuccess?: (fileId: string) => void;\n\n /** Колбэк после ошибки `request` для файла. */\n onRequestError?: (fileId: string) => void;\n\n /** Проверка файла после выбора и до `request`: строка или `{ message, status }` — ошибка/предупреждение. Пустой результат — файл проходит.\n */\n validateBeforeUpload?: (\n file: FileUploaderAttachedFile,\n ) => Promise<Nullable<string | { message: string; status: FileUploaderFileStatus }>>;\n\n /**\n * Задаёт метод отрисовки файлов.\n * @default (props: FileUploaderFileProps) => <FileUploaderFile {...props} />\n */\n renderFile?: (props: FileUploaderFileProps) => React.ReactNode;\n\n /** Произвольная компоновка через FileUploader.Uploader, Files, Summary и Dropzone.\n * В этом режиме встроенная кнопка и список не выводятся: uploaderText, uploaderIcon,\n * uploadButtonPosition и validationSummary к слотам не применяются. */\n children?: React.ReactNode;\n}\n\nexport interface FileUploaderRef extends InstanceWithRootNode {\n /** Устанавливает фокус на скрытом `input` выбора файла. */\n focus: () => void;\n /** Снимает фокус с `input` выбора файла. */\n blur: () => void;\n /** Очищает список файлов и значения `input`. */\n reset: () => void;\n /** Удаляет файл по id с вызовом `onRemove` и `onValueChange`. */\n removeFile: (fileId: string) => void;\n}\n\nexport type FileUploader = FileUploaderRef;\n\nexport const FileUploaderDataTids = {\n root: 'FileUploader__root',\n content: 'FileUploader__content',\n link: 'FileUploader__link',\n input: 'FileUploader__input',\n} as const;\n\nconst defaultRenderFile = (props: FileUploaderFileProps) => <FileUploaderFile {...props} />;\n\nconst _FileUploader = forwardRefAndName<FileUploaderRef, _FileUploaderProps>('FileUploader', (props, ref) => {\n const theme = useContext(ThemeContext);\n const globalObject = useGlobal();\n const { cx } = useEmotion();\n const jsStyles = useStyles(getJsStyles);\n const jsRowStyles = useStyles(getJsRowStyles);\n const jsTileStyles = useStyles(getJsTileStyles);\n const keyListener = useKeyListener();\n\n const {\n disabled,\n error,\n warning,\n withValidationTooltip = false,\n validationTooltipPosition,\n withWarningIcon = false,\n multiple = false,\n uploaderText,\n uploaderIcon,\n view = 'row',\n uploadButtonPosition = 'start',\n validationSummary = 'auto',\n validationSummaryStart = 5,\n width = theme.fileUploaderWidth,\n hideFiles = false,\n onBlur,\n onFocus,\n onChange,\n request,\n validateBeforeUpload,\n onRequestSuccess,\n onRequestError,\n size: sizeProp,\n renderFile = defaultRenderFile,\n children,\n ...inputProps\n } = props;\n const size = useSizeControl(sizeProp);\n\n const { files, setFiles, removeFile, reset, setFileValidationResult } = useContext(FileUploaderControlContext);\n\n const locale = useControlLocale();\n\n const inputRef = useRef<HTMLInputElement>(null);\n const fileDivRef = useRef<HTMLDivElement>(null);\n\n const isAsync = !!request;\n const isSingleMode = !multiple;\n\n const [hovered, setHovered] = useState(false);\n const upload = useUpload(request, onRequestSuccess, onRequestError);\n\n const tryValidateAndUpload = useCallback(\n (files: FileUploaderAttachedFile[]) => {\n files.forEach(async (file) => {\n const validationMessage = validateBeforeUpload && (await validateBeforeUpload(file));\n\n if (!validationMessage) {\n isAsync && upload(file);\n } else if (typeof validationMessage === 'object') {\n setFileValidationResult(\n file.id,\n FileUploaderFileValidationResult.error(validationMessage.message),\n validationMessage.status,\n );\n } else {\n setFileValidationResult(\n file.id,\n FileUploaderFileValidationResult.error(validationMessage),\n FileUploaderFileStatus.Error,\n );\n }\n });\n },\n [validateBeforeUpload, isAsync, upload, setFileValidationResult],\n );\n\n const isTileView = view === 'tile';\n const jsViewStyles = isTileView ? jsTileStyles : jsRowStyles;\n\n const sizeClassName = useFileUploaderSize(size, {\n small: jsViewStyles.sizeSmall(theme),\n medium: jsViewStyles.sizeMedium(theme),\n large: jsViewStyles.sizeLarge(theme),\n });\n\n const uploadButtonTileWithFileClassName = useFileUploaderSize(size, {\n small: jsTileStyles.uploadButtonTileWithFileSmall(theme),\n medium: jsTileStyles.uploadButtonTileWithFileMedium(theme),\n large: jsTileStyles.uploadButtonTileWithFileLarge(theme),\n });\n\n const uploadButtonIconGapClass = useFileUploaderSize(size, {\n small: jsViewStyles.uploadButtonIconGapSmall(theme),\n medium: jsViewStyles.uploadButtonIconGapMedium(theme),\n large: jsViewStyles.uploadButtonIconGapLarge(theme),\n });\n\n const sizeIconClass = useFileUploaderSize(size, {\n small: jsStyles.iconSmall(theme),\n medium: jsStyles.iconMedium(theme),\n large: jsStyles.iconLarge(theme),\n });\n\n const sizeWrapperClass = useFileUploaderSize(size, {\n small: jsTileStyles.uploadButtonWrapperSmall(theme),\n medium: jsTileStyles.uploadButtonWrapperMedium(theme),\n large: jsTileStyles.uploadButtonWrapperLarge(theme),\n });\n\n const sizeWrapperEmptyFileClass = useFileUploaderSize(size, {\n small: jsTileStyles.uploadButtonWrapperEmptyFileSmall(theme),\n medium: jsTileStyles.uploadButtonWrapperEmptyFileMedium(theme),\n large: jsTileStyles.uploadButtonWrapperEmptyFileLarge(theme),\n });\n\n const contentInnerClass = useFileUploaderSize(size, {\n small: jsStyles.contentInnerSmall(theme),\n medium: jsStyles.contentInnerMedium(theme),\n large: jsStyles.contentInnerLarge(theme),\n });\n\n /** common part **/\n const handleChange = useCallback(\n (newFiles: FileList | null) => {\n if (!newFiles || !newFiles.length) {\n return;\n }\n\n let filesArray = Array.from(newFiles);\n\n if (isSingleMode) {\n filesArray = [filesArray[0]];\n }\n\n const attachedFiles = filesArray.map(getAttachedFile);\n\n if (isSingleMode && attachedFiles.length && files.length) {\n removeFile(files[0].id);\n }\n\n if (attachedFiles.length) {\n setFiles(attachedFiles);\n tryValidateAndUpload(attachedFiles);\n }\n },\n [tryValidateAndUpload, setFiles, isSingleMode, files, removeFile],\n );\n\n const handleDrop = useCallback(\n (event: DragEvent) => {\n if (disabled) {\n return;\n }\n\n const { dataTransfer } = event;\n if (dataTransfer) {\n if (isSingleMode && dataTransfer.files.length > 1) {\n dataTransfer.dropEffect = 'none';\n return;\n }\n if (dataTransfer.files?.length > 0) {\n inputRef.current && (inputRef.current.files = dataTransfer.files);\n handleChange(dataTransfer.files);\n }\n }\n },\n [handleChange, disabled],\n );\n\n const { isDraggable, ref: labelRef } = useDrop<HTMLLabelElement>({ onDrop: handleDrop });\n const getInputDocument = useCallback(() => inputRef.current?.ownerDocument, []);\n const { isDraggable: isWindowDraggable } = useDrop<Document>({ parent: getInputDocument });\n\n const focus = useCallback(() => {\n keyListener.isTabPressed = true;\n inputRef.current?.focus();\n }, []);\n\n const blur = useCallback(() => {\n inputRef.current?.blur();\n }, []);\n\n const openFileDialog = useCallback(() => {\n inputRef.current?.click();\n }, []);\n\n const removeFileFromNativeInput = useCallback(\n (fileId: string) => {\n const input = inputRef.current;\n const DataTransferConstructor = input?.ownerDocument.defaultView?.DataTransfer ?? globalObject.DataTransfer;\n if (!input || !DataTransferConstructor) {\n return;\n }\n const dataTransfer = new DataTransferConstructor();\n files\n .filter((f) => f.id !== fileId)\n .forEach((file) => {\n dataTransfer.items.add(file.originalFile);\n });\n input.files = dataTransfer.files;\n },\n [files],\n );\n\n const handleRemoveFile = useCallback(\n (fileId: string) => {\n removeFile(fileId);\n removeFileFromNativeInput(fileId);\n },\n [removeFileFromNativeInput, removeFile],\n );\n\n const handleReset = useCallback(() => {\n reset();\n const input = inputRef.current;\n const DataTransferConstructor = input?.ownerDocument.defaultView?.DataTransfer ?? globalObject.DataTransfer;\n if (input) {\n if (DataTransferConstructor) {\n input.files = new DataTransferConstructor().files;\n } else {\n input.value = '';\n }\n }\n }, [reset]);\n\n useImperativeHandle(\n ref,\n () => ({\n focus,\n blur,\n reset: handleReset,\n removeFile: handleRemoveFile,\n getRootNode: () => rootNodeRef.current,\n }),\n [ref, blur, focus, handleReset, handleRemoveFile],\n );\n\n const [focusedByTab, setFocusedByTab] = useState(false);\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n handleChange(event.target.files);\n setHovered(false);\n };\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n if (!disabled) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n globalObject.requestAnimationFrame?.(() => {\n if (keyListener.isTabPressed) {\n setFocusedByTab(true);\n }\n });\n onFocus?.(e);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocusedByTab(false);\n if (!disabled) {\n onBlur?.(e);\n }\n };\n\n const hasFiles = files.length > 0;\n const hasOneFile = files.length === 1;\n const hasOneFileForSingle = isSingleMode && hasOneFile && !hideFiles;\n\n const hasError = !!error || files[0]?.status === FileUploaderFileStatus.Error;\n const hasWarning = !!warning || files[0]?.status === FileUploaderFileStatus.Warning;\n\n const uploadButtonClassNames = cx(\n jsStyles.uploadButton(theme),\n jsViewStyles.uploadButton(),\n sizeClassName,\n hasOneFileForSingle && jsViewStyles.uploadButtonWithFile(theme),\n focusedByTab && jsStyles.uploadButtonFocus(theme),\n disabled && {\n [jsStyles.disabled(theme)]: true,\n [jsStyles.disabledBackground(theme)]: !hasFiles,\n },\n (focusedByTab || !hasOneFileForSingle) && {\n [jsStyles.warningButton(theme)]: hasWarning,\n [jsStyles.errorButton(theme)]: hasError,\n },\n hasOneFileForSingle && {\n [uploadButtonTileWithFileClassName]: isTileView,\n [jsTileStyles.verticalAlign()]: isTileView,\n [jsStyles.warningFile(theme)]: (!isTileView || hovered) && hasWarning,\n [jsStyles.errorFile(theme)]: (!isTileView || hovered) && hasError,\n },\n !disabled &&\n hovered && {\n [jsStyles.hovered(theme)]: true,\n },\n isDraggable && !disabled && jsStyles.dragOver(theme),\n );\n\n const canDrop = isWindowDraggable && !disabled;\n const uploadButtonWrapperClassNames = cx(\n isTileView && {\n [sizeWrapperClass]: true,\n [sizeWrapperEmptyFileClass]: !hasOneFileForSingle,\n },\n jsViewStyles.uploadButtonWrapper(),\n canDrop && jsStyles.windowDragOver(theme),\n );\n\n const uploadButtonIconClassNames = cx(\n jsStyles.icon(theme),\n sizeIconClass,\n disabled && jsStyles.iconDisabled(theme),\n uploadButtonIconGapClass,\n );\n\n const rootClassNames = cx(jsStyles.root(theme), !isTileView && jsRowStyles.root());\n\n const contentClassNames = cx(jsViewStyles.content(), {\n [jsViewStyles.contentWithFiles()]: hasOneFileForSingle,\n [contentInnerClass]: !isTileView && (!files.length || !isSingleMode),\n });\n\n const afterLinkTextClassNames = cx(\n globalClasses.afterLinkText,\n hasOneFileForSingle ? jsStyles.afterLinkText_HasFiles() : jsStyles.afterLinkText(),\n );\n\n const linkClassNames = cx(\n jsStyles.link(theme),\n !disabled && hovered && jsStyles.linkHovered(theme),\n disabled && jsStyles.linkDisabled(theme),\n );\n\n useEffect(() => {\n const input = inputRef.current;\n const DataTransferConstructor = input?.ownerDocument.defaultView?.DataTransfer ?? globalObject.DataTransfer;\n if (!files.length || !input || !DataTransferConstructor) {\n return;\n }\n\n const dataTransfer = new DataTransferConstructor();\n files.forEach((file) => dataTransfer.items.add(file.originalFile));\n input.files = dataTransfer.files;\n }, []);\n\n const rootNodeRef = useRef(null);\n\n const icon = uploaderIcon ?? <UploadIcon size={size} view={view} />;\n const chooseFileText = uploaderText ?? locale.chooseFile;\n const chooseFileLocale = `${chooseFileText}${String.fromCharCode(0xa0)}`; /* */\n const hideUploaderText = isTileView && uploaderText === '';\n const renderChooseFileText = () =>\n !hideUploaderText && (\n <span data-tid={FileUploaderDataTids.link} className={linkClassNames}>\n {!hasOneFileForSingle && chooseFileLocale}\n </span>\n );\n\n const renderFileList = () => {\n return (\n !hideFiles &&\n !isSingleMode &&\n !!files.length && (\n <FileUploaderFileList\n renderFile={renderFile}\n size={size}\n view={view}\n onRemove={handleRemoveFile}\n validationTooltipPosition={validationTooltipPosition}\n withValidationTooltip={withValidationTooltip}\n validationSummary={validationSummary}\n validationSummaryStart={validationSummaryStart}\n withWarningIcon={withWarningIcon}\n disabled={disabled}\n />\n )\n );\n };\n\n const fileProps = useMemoObject({\n file: files[0],\n size,\n view,\n onRemove: handleRemoveFile,\n error,\n warning,\n withValidationTooltip,\n validationTooltipPosition,\n withWarningIcon,\n hovered,\n disabled,\n } satisfies FileUploaderFileProps);\n\n const fileElement = children ? null : renderFile(fileProps);\n\n const input = (\n <FocusControlWrapper onBlurWhenDisabled={() => setFocusedByTab(false)}>\n <input\n {...inputProps}\n data-tid={FileUploaderDataTids.input}\n ref={inputRef}\n tabIndex={disabled ? -1 : 0}\n type=\"file\"\n disabled={disabled}\n multiple={multiple}\n className={jsStyles.visuallyHidden()}\n onClick={stopPropagation}\n onChange={handleInputChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n />\n </FocusControlWrapper>\n );\n\n const customView = useMemoObject({\n files,\n disabled: !!disabled,\n multiple,\n input,\n openFileDialog,\n onDrop: handleDrop,\n onRemove: handleRemoveFile,\n renderFile,\n fileProps,\n });\n const rootStyle = useMemoObject({\n width: isTileView && !multiple && props.width === undefined ? theme.fileUploaderTileWidth : width,\n });\n const uploadButtonWrapperStyle = useMemoObject({\n width: isTileView && !multiple && props.width !== undefined ? width : undefined,\n });\n\n if (children) {\n return (\n <CommonWrapper {...props}>\n <div\n data-tid={FileUploaderDataTids.root}\n style={props.width === undefined ? undefined : rootStyle}\n ref={rootNodeRef}\n >\n <FileUploaderCustomViewContext.Provider value={customView}>{children}</FileUploaderCustomViewContext.Provider>\n </div>\n </CommonWrapper>\n );\n }\n\n return (\n <CommonWrapper {...props}>\n <div data-tid={FileUploaderDataTids.root} className={rootClassNames} style={rootStyle} ref={rootNodeRef}>\n {uploadButtonPosition === 'end' && renderFileList()}\n <div className={uploadButtonWrapperClassNames} style={uploadButtonWrapperStyle}>\n <label\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n ref={labelRef}\n className={uploadButtonClassNames}\n >\n {!hasOneFileForSingle && <div className={uploadButtonIconClassNames}>{icon}</div>}\n <div data-tid={FileUploaderDataTids.content} className={contentClassNames}>\n {renderChooseFileText()}\n <div className={afterLinkTextClassNames}>\n {hasOneFileForSingle && (\n <div ref={fileDivRef} className={jsStyles.singleFile()}>\n {fileElement}\n </div>\n )}\n </div>\n </div>\n {input}\n </label>\n </div>\n {uploadButtonPosition === 'start' && renderFileList()}\n </div>\n </CommonWrapper>\n );\n});\n\nexport interface FileUploaderProps extends _FileUploaderProps, FileUploaderControlProviderProps {}\n\n/**\n * Контрол для выбора пользователем файла на компьютере и отображения статуса его отправки на сервер.\n */\nconst FileUploaderBase = withFileUploaderControlProvider<FileUploaderProps, FileUploaderRef>(React.memo(_FileUploader));\n\n/** Слоты для произвольной компоновки FileUploader. */\nexport const FileUploader = FileUploaderBase as typeof FileUploaderBase & {\n Uploader: typeof FileUploaderUploader;\n Files: typeof FileUploaderFiles;\n Summary: typeof FileUploaderSummary;\n Dropzone: typeof FileUploaderDropzone;\n};\n\nFileUploader.Uploader = FileUploaderUploader;\nFileUploader.Files = FileUploaderFiles;\nFileUploader.Summary = FileUploaderSummary;\nFileUploader.Dropzone = FileUploaderDropzone;\nFileUploader.displayName = 'FileUploader';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FileUploaderFileProps } from './FileUploaderFile.js';
|
|
3
|
+
import type { FileUploaderAttachedFile } from './fileUtils.js';
|
|
4
|
+
interface CustomViewContextValue {
|
|
5
|
+
files: FileUploaderAttachedFile[];
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
multiple: boolean;
|
|
8
|
+
input: React.ReactNode;
|
|
9
|
+
openFileDialog: () => void;
|
|
10
|
+
onDrop: (event: DragEvent) => void;
|
|
11
|
+
onRemove: (id: string) => void;
|
|
12
|
+
renderFile: (props: FileUploaderFileProps) => React.ReactNode;
|
|
13
|
+
fileProps: Omit<FileUploaderFileProps, 'file'>;
|
|
14
|
+
}
|
|
15
|
+
export declare const FileUploaderCustomViewContext: React.Context<CustomViewContextValue | null>;
|
|
16
|
+
export declare const useCustomView: () => CustomViewContextValue;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
export var FileUploaderCustomViewContext = createContext(null);
|
|
3
|
+
export var useCustomView = function () {
|
|
4
|
+
var value = useContext(FileUploaderCustomViewContext);
|
|
5
|
+
if (!value) {
|
|
6
|
+
throw new Error('FileUploader slots must be used inside FileUploader');
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=FileUploaderCustomView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploaderCustomView.js","sourceRoot":"","sources":["FileUploaderCustomView.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAiBzD,MAAM,CAAC,IAAM,6BAA6B,GAAG,aAAa,CAAgC,IAAI,CAAC,CAAC;AAEhG,MAAM,CAAC,IAAM,aAAa,GAAG;IAC3B,IAAM,KAAK,GAAG,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACxD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import React, { createContext, useContext } from 'react';\n\nimport type { FileUploaderFileProps } from './FileUploaderFile.js';\nimport type { FileUploaderAttachedFile } from './fileUtils.js';\n\ninterface CustomViewContextValue {\n files: FileUploaderAttachedFile[];\n disabled: boolean;\n multiple: boolean;\n input: React.ReactNode;\n openFileDialog: () => void;\n onDrop: (event: DragEvent) => void;\n onRemove: (id: string) => void;\n renderFile: (props: FileUploaderFileProps) => React.ReactNode;\n fileProps: Omit<FileUploaderFileProps, 'file'>;\n}\n\nexport const FileUploaderCustomViewContext = createContext<CustomViewContextValue | null>(null);\n\nexport const useCustomView = () => {\n const value = useContext(FileUploaderCustomViewContext);\n if (!value) {\n throw new Error('FileUploader slots must be used inside FileUploader');\n }\n return value;\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FileUploaderDropzoneProps {
|
|
3
|
+
/** Элемент или ref на контейнер. Для динамически заменяемого контейнера передайте элемент. */
|
|
4
|
+
parent: HTMLElement | React.RefObject<HTMLElement | null> | null;
|
|
5
|
+
children?: React.ReactNode | ((isDragging: boolean) => React.ReactNode);
|
|
6
|
+
}
|
|
7
|
+
/** Подключает обработчики перетаскивания к внешнему контейнеру. */
|
|
8
|
+
export declare const FileUploaderDropzone: import("../../lib/forwardRefAndName.js").ReactUIComponentWithRef<never, FileUploaderDropzoneProps> & Record<never, never>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDrop } from '../../hooks/useDrop.js';
|
|
3
|
+
import { forwardRefAndName } from '../../lib/forwardRefAndName.js';
|
|
4
|
+
import { useCustomView } from './FileUploaderCustomView.js';
|
|
5
|
+
/** Подключает обработчики перетаскивания к внешнему контейнеру. */
|
|
6
|
+
export var FileUploaderDropzone = forwardRefAndName('FileUploaderDropzone', function (_a, _ref) {
|
|
7
|
+
var parent = _a.parent, children = _a.children;
|
|
8
|
+
var _b = useCustomView(), onDrop = _b.onDrop, disabled = _b.disabled;
|
|
9
|
+
var isDraggable = useDrop({ parent: parent, onDrop: onDrop }).isDraggable;
|
|
10
|
+
return React.createElement(React.Fragment, null, typeof children === 'function' ? children(isDraggable && !disabled) : children);
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=FileUploaderDropzone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploaderDropzone.js","sourceRoot":"","sources":["FileUploaderDropzone.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAQ5D,mEAAmE;AACnE,MAAM,CAAC,IAAM,oBAAoB,GAAG,iBAAiB,CACnD,sBAAsB,EACtB,UAAC,EAAoB,EAAE,IAAI;QAAxB,MAAM,YAAA,EAAE,QAAQ,cAAA;IACX,IAAA,KAAuB,aAAa,EAAE,EAApC,MAAM,YAAA,EAAE,QAAQ,cAAoB,CAAC;IACrC,IAAA,WAAW,GAAK,OAAO,CAAc,EAAE,MAAM,QAAA,EAAE,MAAM,QAAA,EAAE,CAAC,YAA7C,CAA8C;IACjE,OAAO,0CAAG,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAI,CAAC;AAC/F,CAAC,CACF,CAAC","sourcesContent":["import React from 'react';\n\nimport { useDrop } from '../../hooks/useDrop.js';\nimport { forwardRefAndName } from '../../lib/forwardRefAndName.js';\nimport { useCustomView } from './FileUploaderCustomView.js';\n\nexport interface FileUploaderDropzoneProps {\n /** Элемент или ref на контейнер. Для динамически заменяемого контейнера передайте элемент. */\n parent: HTMLElement | React.RefObject<HTMLElement | null> | null;\n children?: React.ReactNode | ((isDragging: boolean) => React.ReactNode);\n}\n\n/** Подключает обработчики перетаскивания к внешнему контейнеру. */\nexport const FileUploaderDropzone = forwardRefAndName<never, FileUploaderDropzoneProps>(\n 'FileUploaderDropzone',\n ({ parent, children }, _ref): React.ReactElement => {\n const { onDrop, disabled } = useCustomView();\n const { isDraggable } = useDrop<HTMLElement>({ parent, onDrop });\n return <>{typeof children === 'function' ? children(isDraggable && !disabled) : children}</>;\n },\n);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FileUploaderFileProps } from './FileUploaderFile.js';
|
|
3
|
+
import type { FileUploaderView } from './fileUtils.js';
|
|
4
|
+
export interface FileUploaderFilesProps {
|
|
5
|
+
view?: FileUploaderView;
|
|
6
|
+
renderItem?: (props: FileUploaderFileProps) => React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/** Список файлов без встроенной обёртки для кастомной вёрстки. */
|
|
9
|
+
export declare const FileUploaderFiles: import("../../lib/forwardRefAndName.js").ReactUIComponentWithRef<never, FileUploaderFilesProps> & Record<never, never>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { forwardRefAndName } from '../../lib/forwardRefAndName.js';
|
|
14
|
+
import { useCustomView } from './FileUploaderCustomView.js';
|
|
15
|
+
import { FileUploaderFileList } from './FileUploaderFileList/FileUploaderFileList.js';
|
|
16
|
+
/** Список файлов без встроенной обёртки для кастомной вёрстки. */
|
|
17
|
+
export var FileUploaderFiles = forwardRefAndName('FileUploaderFiles', function (_a, _ref) {
|
|
18
|
+
var view = _a.view, renderItem = _a.renderItem;
|
|
19
|
+
var _b = useCustomView(), files = _b.files, multiple = _b.multiple, renderFile = _b.renderFile, fileProps = _b.fileProps, onRemove = _b.onRemove, disabled = _b.disabled;
|
|
20
|
+
if (!renderItem && multiple) {
|
|
21
|
+
return (React.createElement(FileUploaderFileList, { renderFile: renderFile, size: fileProps.size, view: view !== null && view !== void 0 ? view : fileProps.view, onRemove: onRemove, disabled: disabled, validationSummary: "disabled", withValidationTooltip: fileProps.withValidationTooltip, validationTooltipPosition: fileProps.validationTooltipPosition, withWarningIcon: fileProps.withWarningIcon }));
|
|
22
|
+
}
|
|
23
|
+
return (React.createElement("div", null, files.map(function (file) { return (React.createElement(React.Fragment, { key: file.id }, (renderItem !== null && renderItem !== void 0 ? renderItem : renderFile)(__assign(__assign({}, fileProps), { file: file, view: view !== null && view !== void 0 ? view : fileProps.view, multiple: multiple })))); })));
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=FileUploaderFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploaderFiles.js","sourceRoot":"","sources":["FileUploaderFiles.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAQtF,kEAAkE;AAClE,MAAM,CAAC,IAAM,iBAAiB,GAAG,iBAAiB,CAChD,mBAAmB,EACnB,UAAC,EAAoB,EAAE,IAAI;QAAxB,IAAI,UAAA,EAAE,UAAU,gBAAA;IACX,IAAA,KAAiE,aAAa,EAAE,EAA9E,KAAK,WAAA,EAAE,QAAQ,cAAA,EAAE,UAAU,gBAAA,EAAE,SAAS,eAAA,EAAE,QAAQ,cAAA,EAAE,QAAQ,cAAoB,CAAC;IACvF,IAAI,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;QAC5B,OAAO,CACL,oBAAC,oBAAoB,IACnB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,SAAS,CAAC,IAAI,EACpB,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,SAAS,CAAC,IAAI,EAC5B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAC,UAAU,EAC5B,qBAAqB,EAAE,SAAS,CAAC,qBAAqB,EACtD,yBAAyB,EAAE,SAAS,CAAC,yBAAyB,EAC9D,eAAe,EAAE,SAAS,CAAC,eAAe,GAC1C,CACH,CAAC;IACJ,CAAC;IACD,OAAO,CACL,iCACG,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,CACnB,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,IAAI,CAAC,EAAE,IACzB,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,UAAU,CAAC,uBAAM,SAAS,KAAE,IAAI,MAAA,EAAE,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,SAAS,CAAC,IAAI,EAAE,QAAQ,UAAA,IAAG,CAC5E,CAClB,EAJoB,CAIpB,CAAC,CACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import React from 'react';\n\nimport { forwardRefAndName } from '../../lib/forwardRefAndName.js';\nimport { useCustomView } from './FileUploaderCustomView.js';\nimport type { FileUploaderFileProps } from './FileUploaderFile.js';\nimport { FileUploaderFileList } from './FileUploaderFileList/FileUploaderFileList.js';\nimport type { FileUploaderView } from './fileUtils.js';\n\nexport interface FileUploaderFilesProps {\n view?: FileUploaderView;\n renderItem?: (props: FileUploaderFileProps) => React.ReactNode;\n}\n\n/** Список файлов без встроенной обёртки для кастомной вёрстки. */\nexport const FileUploaderFiles = forwardRefAndName<never, FileUploaderFilesProps>(\n 'FileUploaderFiles',\n ({ view, renderItem }, _ref): React.ReactElement => {\n const { files, multiple, renderFile, fileProps, onRemove, disabled } = useCustomView();\n if (!renderItem && multiple) {\n return (\n <FileUploaderFileList\n renderFile={renderFile}\n size={fileProps.size}\n view={view ?? fileProps.view}\n onRemove={onRemove}\n disabled={disabled}\n validationSummary=\"disabled\"\n withValidationTooltip={fileProps.withValidationTooltip}\n validationTooltipPosition={fileProps.validationTooltipPosition}\n withWarningIcon={fileProps.withWarningIcon}\n />\n );\n }\n return (\n <div>\n {files.map((file) => (\n <React.Fragment key={file.id}>\n {(renderItem ?? renderFile)({ ...fileProps, file, view: view ?? fileProps.view, multiple })}\n </React.Fragment>\n ))}\n </div>\n );\n },\n);\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FileUploaderSummaryCounts {
|
|
3
|
+
error: number;
|
|
4
|
+
warning: number;
|
|
5
|
+
uploaded: number;
|
|
6
|
+
}
|
|
7
|
+
export interface FileUploaderSummaryProps {
|
|
8
|
+
children: (error: number, warning: number, uploaded: number) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/** Счётчики статусов файлов для произвольной разметки. */
|
|
11
|
+
export declare const FileUploaderSummary: import("../../lib/forwardRefAndName.js").ReactUIComponentWithRef<never, FileUploaderSummaryProps> & Record<never, never>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { forwardRefAndName } from '../../lib/forwardRefAndName.js';
|
|
3
|
+
import { useCustomView } from './FileUploaderCustomView.js';
|
|
4
|
+
import { FileUploaderFileStatus } from './fileUtils.js';
|
|
5
|
+
/** Счётчики статусов файлов для произвольной разметки. */
|
|
6
|
+
export var FileUploaderSummary = forwardRefAndName('FileUploaderSummary', function (_a, _ref) {
|
|
7
|
+
var children = _a.children;
|
|
8
|
+
var files = useCustomView().files;
|
|
9
|
+
var counts = {
|
|
10
|
+
error: files.filter(function (file) { return file.status === FileUploaderFileStatus.Error; }).length,
|
|
11
|
+
warning: files.filter(function (file) { return file.status === FileUploaderFileStatus.Warning; }).length,
|
|
12
|
+
uploaded: files.filter(function (file) { return file.status === FileUploaderFileStatus.Uploaded; }).length,
|
|
13
|
+
};
|
|
14
|
+
return React.createElement(React.Fragment, null, children(counts.error, counts.warning, counts.uploaded));
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=FileUploaderSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploaderSummary.js","sourceRoot":"","sources":["FileUploaderSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAYxD,0DAA0D;AAC1D,MAAM,CAAC,IAAM,mBAAmB,GAAG,iBAAiB,CAClD,qBAAqB,EACrB,UAAC,EAAY,EAAE,IAAI;QAAhB,QAAQ,cAAA;IACD,IAAA,KAAK,GAAK,aAAa,EAAE,MAApB,CAAqB;IAClC,IAAM,MAAM,GAA8B;QACxC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,MAAM,KAAK,sBAAsB,CAAC,KAAK,EAA5C,CAA4C,CAAC,CAAC,MAAM;QAClF,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,MAAM,KAAK,sBAAsB,CAAC,OAAO,EAA9C,CAA8C,CAAC,CAAC,MAAM;QACtF,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,MAAM,KAAK,sBAAsB,CAAC,QAAQ,EAA/C,CAA+C,CAAC,CAAC,MAAM;KACzF,CAAC;IACF,OAAO,0CAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAI,CAAC;AACxE,CAAC,CACF,CAAC","sourcesContent":["import React from 'react';\n\nimport { forwardRefAndName } from '../../lib/forwardRefAndName.js';\nimport { useCustomView } from './FileUploaderCustomView.js';\nimport { FileUploaderFileStatus } from './fileUtils.js';\n\nexport interface FileUploaderSummaryCounts {\n error: number;\n warning: number;\n uploaded: number;\n}\n\nexport interface FileUploaderSummaryProps {\n children: (error: number, warning: number, uploaded: number) => React.ReactNode;\n}\n\n/** Счётчики статусов файлов для произвольной разметки. */\nexport const FileUploaderSummary = forwardRefAndName<never, FileUploaderSummaryProps>(\n 'FileUploaderSummary',\n ({ children }, _ref): React.ReactElement => {\n const { files } = useCustomView();\n const counts: FileUploaderSummaryCounts = {\n error: files.filter((file) => file.status === FileUploaderFileStatus.Error).length,\n warning: files.filter((file) => file.status === FileUploaderFileStatus.Warning).length,\n uploaded: files.filter((file) => file.status === FileUploaderFileStatus.Uploaded).length,\n };\n return <>{children(counts.error, counts.warning, counts.uploaded)}</>;\n },\n);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FileUploaderUploaderProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'htmlFor'> {
|
|
3
|
+
/** Содержимое области выбора. По умолчанию — локализованный текст выбора файла. */
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
/** HTML-атрибут `data-tid`. */
|
|
6
|
+
'data-tid'?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Кастомная область выбора файла; содержимое label активирует скрытый input. */
|
|
9
|
+
export declare const FileUploaderUploader: import("../../lib/forwardRefAndName.js").ReactUIComponentWithRef<HTMLLabelElement, FileUploaderUploaderProps> & Record<never, never>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import { forwardRefAndName } from '../../lib/forwardRefAndName.js';
|
|
25
|
+
import { useCustomView } from './FileUploaderCustomView.js';
|
|
26
|
+
import { useControlLocale } from './hooks/useControlLocale.js';
|
|
27
|
+
/** Кастомная область выбора файла; содержимое label активирует скрытый input. */
|
|
28
|
+
export var FileUploaderUploader = forwardRefAndName('FileUploaderUploader', function (_a, ref) {
|
|
29
|
+
var children = _a.children, onClick = _a.onClick, rest = __rest(_a, ["children", "onClick"]);
|
|
30
|
+
var _b = useCustomView(), disabled = _b.disabled, input = _b.input, openFileDialog = _b.openFileDialog;
|
|
31
|
+
var locale = useControlLocale();
|
|
32
|
+
// Нативная активация label не работает для кликов по интерактивным потомкам (Button, Link и т.п.),
|
|
33
|
+
// поэтому открываем диалог вручную, отменив поведение label, чтобы не открыть его дважды.
|
|
34
|
+
var handleClick = function (event) {
|
|
35
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
36
|
+
if (event.defaultPrevented) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
if (!disabled) {
|
|
41
|
+
openFileDialog();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return (React.createElement("label", __assign({}, rest, { ref: ref, "aria-disabled": disabled, onClick: handleClick }), children !== null && children !== void 0 ? children : locale.chooseFile,
|
|
45
|
+
input));
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=FileUploaderUploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploaderUploader.js","sourceRoot":"","sources":["FileUploaderUploader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAU/D,iFAAiF;AACjF,MAAM,CAAC,IAAM,oBAAoB,GAAG,iBAAiB,CACnD,sBAAsB,EACtB,UAAC,EAA8B,EAAE,GAAG;IAAjC,IAAA,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAK,IAAI,cAA5B,uBAA8B,CAAF;IACrB,IAAA,KAAsC,aAAa,EAAE,EAAnD,QAAQ,cAAA,EAAE,KAAK,WAAA,EAAE,cAAc,oBAAoB,CAAC;IAC5D,IAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAElC,mGAAmG;IACnG,0FAA0F;IAC1F,IAAM,WAAW,GAAG,UAAC,KAAyC;QAC5D,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,KAAK,CAAC,CAAC;QACjB,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC;YAC3B,OAAO;QACT,CAAC;QACD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,cAAc,EAAE,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,0CAAW,IAAI,IAAE,GAAG,EAAE,GAAG,mBAAiB,QAAQ,EAAE,OAAO,EAAE,WAAW,KACrE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,MAAM,CAAC,UAAU;QAC7B,KAAK,CACA,CACT,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import React from 'react';\n\nimport { forwardRefAndName } from '../../lib/forwardRefAndName.js';\nimport { useCustomView } from './FileUploaderCustomView.js';\nimport { useControlLocale } from './hooks/useControlLocale.js';\n\nexport interface FileUploaderUploaderProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'htmlFor'> {\n /** Содержимое области выбора. По умолчанию — локализованный текст выбора файла. */\n children?: React.ReactNode;\n\n /** HTML-атрибут `data-tid`. */\n 'data-tid'?: string;\n}\n\n/** Кастомная область выбора файла; содержимое label активирует скрытый input. */\nexport const FileUploaderUploader = forwardRefAndName<HTMLLabelElement, FileUploaderUploaderProps>(\n 'FileUploaderUploader',\n ({ children, onClick, ...rest }, ref): React.ReactElement => {\n const { disabled, input, openFileDialog } = useCustomView();\n const locale = useControlLocale();\n\n // Нативная активация label не работает для кликов по интерактивным потомкам (Button, Link и т.п.),\n // поэтому открываем диалог вручную, отменив поведение label, чтобы не открыть его дважды.\n const handleClick = (event: React.MouseEvent<HTMLLabelElement>) => {\n onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n if (!disabled) {\n openFileDialog();\n }\n };\n\n return (\n <label {...rest} ref={ref} aria-disabled={disabled} onClick={handleClick}>\n {children ?? locale.chooseFile}\n {input}\n </label>\n );\n },\n);\n"]}
|
|
@@ -3,4 +3,8 @@ export { FileUploaderFileStatus } from './fileUtils.js';
|
|
|
3
3
|
export type FileUploaderAttachedFile = Type;
|
|
4
4
|
export { FileUploaderFileValidationResult } from './FileUploaderFileValidationResult.js';
|
|
5
5
|
export * from './FileUploader.js';
|
|
6
|
+
export type { FileUploaderUploaderProps } from './FileUploaderUploader.js';
|
|
7
|
+
export type { FileUploaderFilesProps } from './FileUploaderFiles.js';
|
|
8
|
+
export type { FileUploaderSummaryProps, FileUploaderSummaryCounts } from './FileUploaderSummary.js';
|
|
9
|
+
export type { FileUploaderDropzoneProps } from './FileUploaderDropzone.js';
|
|
6
10
|
export * from './FileUploaderFile.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,cAAc,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,cAAc,mBAAmB,CAAC;AAKlC,cAAc,uBAAuB,CAAC","sourcesContent":["import type { FileUploaderAttachedFile as Type } from './fileUtils.js';\nexport { FileUploaderFileStatus } from './fileUtils.js';\nexport type FileUploaderAttachedFile = Type;\nexport { FileUploaderFileValidationResult } from './FileUploaderFileValidationResult.js';\nexport * from './FileUploader.js';\nexport type { FileUploaderUploaderProps } from './FileUploaderUploader.js';\nexport type { FileUploaderFilesProps } from './FileUploaderFiles.js';\nexport type { FileUploaderSummaryProps, FileUploaderSummaryCounts } from './FileUploaderSummary.js';\nexport type { FileUploaderDropzoneProps } from './FileUploaderDropzone.js';\nexport * from './FileUploaderFile.js';\n"]}
|
|
@@ -72,7 +72,7 @@ var ToastView = /** @class */ (function (_super) {
|
|
|
72
72
|
: { side: 40, size: parseInt(_this.theme.toastCloseSize) };
|
|
73
73
|
var close = action || showCloseIcon ? (React.createElement("span", { className: _this.cx(_this.styles.closeWrapper(_this.theme), isTheme6_1 && _this.styles.closeWrapper6_1()) },
|
|
74
74
|
React.createElement(CloseButtonIcon, __assign({ "aria-label": _this.locale.closeButtonAriaLabel, "data-tid": ToastDataTids.close, onClick: onClose }, themeDependantProps, { color: toastCloseColors.default, colorHover: toastCloseColors.hover, tabbable: false })))) : null;
|
|
75
|
-
var rootClassName = _this.cx(_this.styles.root(_this.theme), isTheme6_1 && _this.styles.root6_1(), isTheme6_1 && _this.isMobileLayout && _this.styles.rootMobile(_this.theme), _this.styles[use !== null && use !== void 0 ? use : 'default'](_this.theme));
|
|
75
|
+
var rootClassName = _this.cx(_this.styles.root(_this.theme), isTheme6_1 && _this.styles.root6_1(_this.theme), isTheme6_1 && _this.isMobileLayout && _this.styles.rootMobile(_this.theme), _this.styles[use !== null && use !== void 0 ? use : 'default'](_this.theme));
|
|
76
76
|
var wrapperClassName = _this.cx(_this.styles.wrapper(_this.theme), isTheme6_1 && _this.styles.wrapper6_1(_this.theme));
|
|
77
77
|
return (React.createElement(CommonWrapper, __assign({}, _this.props),
|
|
78
78
|
React.createElement(ZIndex, { priority: "Toast", className: wrapperClassName },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastView.js","sourceRoot":"","sources":["ToastView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAuBlD;IAA+B,6BAA+B;IAA9D;;QAuBU,gBAAU,GAAG;YACb,IAAA,KAAsE,KAAI,CAAC,KAAK,EAA9E,MAAM,YAAA,EAAE,aAAa,mBAAA,EAAE,OAAO,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A,IAAI;wBACJ,KAAK,CACF,CACC,CACK,CACjB,CAAC;QACJ,CAAC,CAAC;;IACJ,CAAC;IA5GQ,0BAAM,GAAb;QAAA,iBAWC;QAVC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtC,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,QACnB,UAAC,KAAK;YACL,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,OAAO,KAAI,CAAC,UAAU,EAAE,CAAC;QAC3B,CAAC,CACqB,CACzB,CAAC;IACJ,CAAC;IArBU,SAAS;QAJrB,gBAAgB;QAChB,qBAAqB;QACrB,QAAQ;QACR,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC;OACtB,SAAS,CAsHrB;IAAD,gBAAC;CAAA,AAtHD,CAA+B,KAAK,CAAC,SAAS,GAsH7C;SAtHY,SAAS","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\nimport type { AriaAttributes } from 'react';\nimport React from 'react';\n\nimport { CloseButtonIcon } from '../../internal/CloseButtonIcon/CloseButtonIcon.js';\nimport type { CommonProps } from '../../internal/CommonWrapper/index.js';\nimport { CommonWrapper } from '../../internal/CommonWrapper/index.js';\nimport { ZIndex } from '../../internal/ZIndex/index.js';\nimport { locale } from '../../lib/locale/decorators.js';\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';\nimport type { TGetRootNode, TSetRootNode } from '../../lib/rootNode/index.js';\nimport { rootNode } from '../../lib/rootNode/index.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport { isThemeGTE } from '../../lib/theming/ThemeHelpers.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport { responsiveLayout } from '../ResponsiveLayout/decorator.js';\nimport type { ToastLocale } from './locale/index.js';\nimport { ToastLocaleHelper } from './locale/index.js';\nimport type { Action, ToastUse } from './Toast.js';\nimport { ToastDataTids } from './Toast.js';\nimport { getStyles } from './ToastView.styles.js';\n\nexport interface ToastViewProps extends Pick<AriaAttributes, 'aria-label'>, CommonProps {\n /** Отображает контент уведомления. */\n children?: React.ReactNode;\n /** Добавляет кнопку действия в тост. */\n action?: Nullable<Action>;\n /** Показывает кнопку закрытия рядом с текстом. */\n showCloseIcon?: boolean;\n /** Вызывается при закрытии тоста из разметки. */\n onClose?: () => void;\n /** Вызывается при наведении курсора на тост. */\n onMouseEnter?: () => void;\n /** Вызывается при уходе курсора с тоста. */\n onMouseLeave?: () => void;\n /** Выбирает стиль оформления: обычный или ошибка (`error`). */\n use?: ToastUse;\n}\n\n@responsiveLayout\n@withRenderEnvironment\n@rootNode\n@locale('Toast', ToastLocaleHelper)\nexport class ToastView extends React.Component<ToastViewProps> {\n private styles!: ReturnType<typeof getStyles>;\n private emotion!: Emotion;\n private cx!: Emotion['cx'];\n private theme!: Theme;\n public getRootNode!: TGetRootNode;\n private setRootNode!: TSetRootNode;\n private readonly locale!: ToastLocale;\n private isMobileLayout!: boolean;\n\n public render(): React.JSX.Element {\n this.styles = getStyles(this.emotion);\n\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain = () => {\n const { action, showCloseIcon, onClose, onMouseEnter, onMouseLeave, use } = this.props;\n\n const isTheme6_1 = isThemeGTE(this.theme, '6.1');\n\n const toastCloseColors =\n use === 'error'\n ? {\n hover: this.theme.toastCloseHoverColorError,\n default: this.theme.toastCloseColorError,\n }\n : {\n hover: this.theme.toastCloseHoverColor,\n default: this.theme.toastCloseColor,\n };\n\n const toastActionColorsClassName =\n use === 'error' ? this.styles.toastActionErrorColor(this.theme) : this.styles.toastActionDefaultColor(this.theme);\n const toastActionClassNames = this.cx(\n this.styles.link(this.theme),\n isTheme6_1 && this.styles.link6_1(this.theme),\n\n toastActionColorsClassName,\n );\n\n const link = action ? (\n <button\n aria-label={action['aria-label']}\n data-tid={ToastDataTids.action}\n className={toastActionClassNames}\n onClick={action.handler}\n >\n {action.label}\n </button>\n ) : null;\n\n const themeDependantProps = isTheme6_1\n ? {\n style: {\n height: '100%',\n },\n side: parseInt(this.theme.toastCloseBtnSide),\n }\n : { side: 40, size: parseInt(this.theme.toastCloseSize) };\n\n const close =\n action || showCloseIcon ? (\n <span className={this.cx(this.styles.closeWrapper(this.theme), isTheme6_1 && this.styles.closeWrapper6_1())}>\n <CloseButtonIcon\n aria-label={this.locale.closeButtonAriaLabel}\n data-tid={ToastDataTids.close}\n onClick={onClose}\n {...themeDependantProps}\n color={toastCloseColors.default}\n colorHover={toastCloseColors.hover}\n tabbable={false}\n />\n </span>\n ) : null;\n\n const rootClassName = this.cx(\n this.styles.root(this.theme),\n isTheme6_1 && this.styles.root6_1(this.theme),\n isTheme6_1 && this.isMobileLayout && this.styles.rootMobile(this.theme),\n this.styles[use ?? 'default'](this.theme),\n );\n\n const wrapperClassName = this.cx(this.styles.wrapper(this.theme), isTheme6_1 && this.styles.wrapper6_1(this.theme));\n\n return (\n <CommonWrapper {...this.props}>\n <ZIndex priority=\"Toast\" className={wrapperClassName}>\n <div\n data-tid={ToastDataTids.toastView}\n className={rootClassName}\n ref={this.setRootNode}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n {isTheme6_1 ? (\n <span className={this.styles.content(this.theme)}>\n <span className={this.cx(this.isMobileLayout && this.styles.ellipsisContent())}>\n {this.props.children}\n </span>\n </span>\n ) : (\n <span>{this.props.children}</span>\n )}\n {link}\n {close}\n </div>\n </ZIndex>\n </CommonWrapper>\n );\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Theme } from '../../lib/theming/Theme.js';
|
|
2
2
|
export declare const getStyles: import("../../lib/theming/Emotion.js").StylesGetter<{
|
|
3
3
|
root(t: Theme): string;
|
|
4
|
-
root6_1(): string;
|
|
4
|
+
root6_1(t: Theme): string;
|
|
5
5
|
rootMobile(t: Theme): string;
|
|
6
6
|
default(t: Theme): string;
|
|
7
7
|
error(t: Theme): string;
|
|
@@ -15,8 +15,10 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
15
15
|
var _a = getVerticalPaddings(t), paddingTop = _a[0], paddingBottom = _a[1];
|
|
16
16
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: ", ";\n border: ", ";\n display: inline-flex;\n font-size: ", ";\n line-height: ", ";\n opacity: 1;\n padding: ", " ", " ", ";\n position: relative;\n top: ", ";\n "], ["\n border-radius: ", ";\n border: ", ";\n display: inline-flex;\n font-size: ", ";\n line-height: ", ";\n opacity: 1;\n padding: ", " ", " ", ";\n position: relative;\n top: ", ";\n "])), t.toastBorderRadius, t.toastBorder, t.toastFontSize, t.toastLineHeight, paddingTop, t.toastPaddingX, paddingBottom, t.toastTop);
|
|
17
17
|
},
|
|
18
|
-
root6_1: function () {
|
|
19
|
-
|
|
18
|
+
root6_1: function (t) {
|
|
19
|
+
var _a = getVerticalPaddings(t), paddingTop = _a[0], paddingBottom = _a[1];
|
|
20
|
+
var minHeight = parseInt(paddingTop) + parseInt(paddingBottom) + parseInt(t.toastLineHeight);
|
|
21
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n /*\n * \u0412 \u0432\u0435\u0440\u0441\u0438\u0438 6.1 \u0432\u0435\u0440\u0442\u0438\u043A\u0430\u043B\u044C\u043D\u044B\u0435 \u043F\u0430\u0434\u0434\u0438\u043D\u0433\u0438 \u043F\u0435\u0440\u0435\u0435\u0445\u0430\u043B\u0438 \u043D\u0430 \u043A\u043E\u043D\u0442\u0435\u043D\u0442, \u043F\u043E\u044D\u0442\u043E\u043C\u0443 \u0432\u044B\u0441\u043E\u0442\u0430 \u0442\u043E\u0441\u0442\u0430 \u0441\u0442\u0430\u043B\u0430\n * \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044C \u043E\u0442 \u043D\u0430\u043B\u0438\u0447\u0438\u044F \u0441\u0442\u0440\u043E\u043A\u0438 \u0432 \u043D\u0451\u043C. \u041A\u043E\u043D\u0442\u0435\u043D\u0442 \u0431\u0435\u0437 \u0441\u0442\u0440\u043E\u043A\u0438 (\u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, \u043F\u0440\u043E\u0431\u0435\u043B) \u0441\u0445\u043B\u043E\u043F\u044B\u0432\u0430\u043B \u0442\u043E\u0441\u0442.\n */\n min-height: ", "px;\n padding: 0;\n "], ["\n /*\n * \u0412 \u0432\u0435\u0440\u0441\u0438\u0438 6.1 \u0432\u0435\u0440\u0442\u0438\u043A\u0430\u043B\u044C\u043D\u044B\u0435 \u043F\u0430\u0434\u0434\u0438\u043D\u0433\u0438 \u043F\u0435\u0440\u0435\u0435\u0445\u0430\u043B\u0438 \u043D\u0430 \u043A\u043E\u043D\u0442\u0435\u043D\u0442, \u043F\u043E\u044D\u0442\u043E\u043C\u0443 \u0432\u044B\u0441\u043E\u0442\u0430 \u0442\u043E\u0441\u0442\u0430 \u0441\u0442\u0430\u043B\u0430\n * \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044C \u043E\u0442 \u043D\u0430\u043B\u0438\u0447\u0438\u044F \u0441\u0442\u0440\u043E\u043A\u0438 \u0432 \u043D\u0451\u043C. \u041A\u043E\u043D\u0442\u0435\u043D\u0442 \u0431\u0435\u0437 \u0441\u0442\u0440\u043E\u043A\u0438 (\u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, \u043F\u0440\u043E\u0431\u0435\u043B) \u0441\u0445\u043B\u043E\u043F\u044B\u0432\u0430\u043B \u0442\u043E\u0441\u0442.\n */\n min-height: ", "px;\n padding: 0;\n "])), minHeight);
|
|
20
22
|
},
|
|
21
23
|
rootMobile: function (t) {
|
|
22
24
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n top: ", ";\n font-size: ", ";\n "], ["\n top: ", ";\n font-size: ", ";\n "])), t.mobileToastTop, t.mobileToastFontSize);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastView.styles.js","sourceRoot":"","sources":["ToastView.styles.ts"],"names":[],"mappings":";;;;AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,IAAM,mBAAmB,GAAG,UAAC,KAAY;IAC/B,IAAA,aAAa,GAAK,KAAK,cAAV,CAAW;IAChC,IAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEzC,OAAO,CAAC,UAAG,QAAQ,OAAI,EAAE,UAAG,QAAQ,OAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,SAAS,GAAG,gBAAgB,CAAC,UAAC,EAAgB;QAAd,GAAG,SAAA;IAAgB,OAAA,CAAC;QAC/D,IAAI,YAAC,CAAQ;YACL,IAAA,KAA8B,mBAAmB,CAAC,CAAC,CAAC,EAAnD,UAAU,QAAA,EAAE,aAAa,QAA0B,CAAC;YAC3D,OAAO,GAAG,2SAAA,yBACS,EAAmB,mBAC1B,EAAa,mDAEV,EAAe,wBACb,EAAiB,uCAErB,EAAU,GAAI,EAAe,GAAI,EAAa,2CAElD,EAAU,SAClB,KATkB,CAAC,CAAC,iBAAiB,EAC1B,CAAC,CAAC,WAAW,EAEV,CAAC,CAAC,aAAa,EACb,CAAC,CAAC,eAAe,EAErB,UAAU,EAAI,CAAC,CAAC,aAAa,EAAI,aAAa,EAElD,CAAC,CAAC,QAAQ,EACjB;QACJ,CAAC;QAED,OAAO;
|
|
1
|
+
{"version":3,"file":"ToastView.styles.js","sourceRoot":"","sources":["ToastView.styles.ts"],"names":[],"mappings":";;;;AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,IAAM,mBAAmB,GAAG,UAAC,KAAY;IAC/B,IAAA,aAAa,GAAK,KAAK,cAAV,CAAW;IAChC,IAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEzC,OAAO,CAAC,UAAG,QAAQ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EAAa,GAAI,EAAe,sBAEjD,EAAO,kCACO,EAAoB,GAAI,EAA0B,0CAE3D,EAAkB,8BACb,EAA8B,6BAExC,EAAO,kCACO,EAAoB,GAAI,EAA0B,SAC5E,KAhBU,CAAC,CAAC,cAAc,EAMd,UAAU,EAAO,aAAa,EAAI,CAAC,CAAC,aAAa,EAEjD,OAAO,EACO,CAAC,CAAC,kBAAkB,EAAI,CAAC,CAAC,wBAAwB,EAE3D,CAAC,CAAC,gBAAgB,EACb,CAAC,CAAC,4BAA4B,EAExC,OAAO,EACO,CAAC,CAAC,kBAAkB,EAAI,CAAC,CAAC,wBAAwB,EAC3E;QACJ,CAAC;QAED,OAAO,YAAC,CAAQ;YACd,OAAO,GAAG,uHAAA,uCAEK,EAAkB,SAChC,KADc,CAAC,CAAC,gBAAgB,EAC/B;QACJ,CAAC;QAED,qBAAqB,YAAC,CAAQ;YAC5B,OAAO,GAAG,sQAAA,iBACC,EAAqB,4CAGd,EAAuB,8BAClB,EAA8B,sDAInC,EAAwB,oBAC7B,EAA2B,kBAEvC,KAXU,CAAC,CAAC,mBAAmB,EAGd,CAAC,CAAC,qBAAqB,EAClB,CAAC,CAAC,4BAA4B,EAInC,CAAC,CAAC,sBAAsB,EAC7B,CAAC,CAAC,yBAAyB,EAEtC;QACJ,CAAC;QAED,uBAAuB,YAAC,CAAQ;YAC9B,OAAO,GAAG,gPAAA,iBACC,EAAgB,4CAGT,EAAkB,8BACb,EAA8B,sDAInC,EAAmB,kBAEpC,KAVU,CAAC,CAAC,cAAc,EAGT,CAAC,CAAC,gBAAgB,EACb,CAAC,CAAC,4BAA4B,EAInC,CAAC,CAAC,iBAAiB,EAEnC;QACJ,CAAC;KACF,CAAC;AApK8D,CAoK9D,CAAC,CAAC","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\n\nimport { memoizeGetStyles } from '../../lib/theming/Emotion.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\n\nconst getVerticalPaddings = (theme: Theme) => {\n const { toastPaddingY } = theme;\n const paddingY = parseInt(toastPaddingY);\n\n return [`${paddingY}px`, `${paddingY}px`];\n};\n\nexport const getStyles = memoizeGetStyles(({ css }: Emotion) => ({\n root(t: Theme) {\n const [paddingTop, paddingBottom] = getVerticalPaddings(t);\n return css`\n border-radius: ${t.toastBorderRadius};\n border: ${t.toastBorder};\n display: inline-flex;\n font-size: ${t.toastFontSize};\n line-height: ${t.toastLineHeight};\n opacity: 1;\n padding: ${paddingTop} ${t.toastPaddingX} ${paddingBottom};\n position: relative;\n top: ${t.toastTop};\n `;\n },\n\n root6_1(t: Theme) {\n const [paddingTop, paddingBottom] = getVerticalPaddings(t);\n const minHeight = parseInt(paddingTop) + parseInt(paddingBottom) + parseInt(t.toastLineHeight);\n\n return css`\n /*\n * В версии 6.1 вертикальные паддинги переехали на контент, поэтому высота тоста стала\n * зависеть от наличия строки в нём. Контент без строки (например, пробел) схлопывал тост.\n */\n min-height: ${minHeight}px;\n padding: 0;\n `;\n },\n\n rootMobile(t: Theme) {\n return css`\n top: ${t.mobileToastTop};\n font-size: ${t.mobileToastFontSize};\n `;\n },\n\n default(t: Theme) {\n return css`\n background: ${t.toastBg};\n color: ${t.toastColor};\n `;\n },\n\n error(t: Theme) {\n return css`\n background: ${t.toastErrorBg};\n color: ${t.toastColorError};\n `;\n },\n\n wrapper(t: Theme) {\n return css`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: 0;\n text-align: center;\n border-radius: ${t.toastBorderRadius};\n `;\n },\n\n wrapper6_1(t: Theme) {\n return css`\n padding: 0 ${t.toastPaddingX};\n `;\n },\n\n content(t: Theme) {\n const [paddingTop, paddingBottom] = getVerticalPaddings(t);\n return css`\n padding: ${paddingTop} ${t.toastPaddingX} ${paddingBottom};\n `;\n },\n\n ellipsisContent() {\n return css`\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: start;\n `;\n },\n\n closeWrapper(t: Theme) {\n const [paddingTop, paddingBottom] = getVerticalPaddings(t);\n return css`\n display: flex;\n margin: -${paddingTop} -${t.toastPaddingX} -${paddingBottom} 0;\n `;\n },\n\n closeWrapper6_1() {\n return css`\n margin: 0;\n `;\n },\n\n link(t: Theme) {\n const [paddingTop, paddingBottom] = getVerticalPaddings(t);\n const padding = `${paddingTop} ${t.toastLinkPadding}`;\n\n return css`\n border: none;\n font: inherit;\n color: ${t.toastLinkColor};\n cursor: pointer;\n display: inline-block;\n font-weight: 600;\n background-color: transparent;\n\n margin: -${paddingTop} 0 -${paddingBottom} ${t.toastPaddingX};\n\n padding: ${padding};\n transition: background ${t.transitionDuration} ${t.transitionTimingFunction};\n &:hover {\n background: ${t.toastLinkBgHover};\n text-decoration: ${t.toastLinkTextDecorationHover};\n }\n padding: ${padding};\n transition: background ${t.transitionDuration} ${t.transitionTimingFunction};\n `;\n },\n\n link6_1(t: Theme) {\n return css`\n margin: 0;\n padding: 0 ${t.toastLinkPadding};\n `;\n },\n\n toastActionErrorColor(t: Theme) {\n return css`\n color: ${t.toastLinkColorError};\n\n &:hover {\n background: ${t.toastLinkBgHoverError};\n text-decoration: ${t.toastLinkTextDecorationHover};\n }\n\n &:active {\n background: ${t.toastLinkBgActiveError};\n color: ${t.toastLinkColorActiveError};\n }\n `;\n },\n\n toastActionDefaultColor(t: Theme) {\n return css`\n color: ${t.toastLinkColor};\n\n &:hover {\n background: ${t.toastLinkBgHover};\n text-decoration: ${t.toastLinkTextDecorationHover};\n }\n\n &:active {\n background: ${t.toastLinkBgActive};\n }\n `;\n },\n}));\n"]}
|
package/hooks/useDrop.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { MutableRefObject } from 'react';
|
|
2
|
-
interface IUseDropProps {
|
|
1
|
+
import type { MutableRefObject, RefObject } from 'react';
|
|
2
|
+
interface IUseDropProps<TElement> {
|
|
3
3
|
onDrop?: (event: DragEvent) => void;
|
|
4
|
+
parent?: TElement | RefObject<TElement | null> | (() => TElement | null | undefined) | null;
|
|
4
5
|
}
|
|
5
6
|
type IElementWithListener = Pick<HTMLElement, 'addEventListener' | 'removeEventListener'>;
|
|
6
7
|
interface IUseDropResult<TElement extends IElementWithListener> {
|
|
7
8
|
isDraggable: boolean;
|
|
8
9
|
ref: MutableRefObject<TElement | null>;
|
|
9
10
|
}
|
|
10
|
-
export declare const useDrop: <TElement extends IElementWithListener>(props?: IUseDropProps) => IUseDropResult<TElement>;
|
|
11
|
+
export declare const useDrop: <TElement extends IElementWithListener>(props?: IUseDropProps<TElement>) => IUseDropResult<TElement>;
|
|
11
12
|
export {};
|
package/hooks/useDrop.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
export var useDrop = function (props) {
|
|
3
3
|
if (props === void 0) { props = {}; }
|
|
4
|
-
var onDrop = props.onDrop;
|
|
4
|
+
var onDrop = props.onDrop, parent = props.parent;
|
|
5
5
|
var droppableRef = useRef(null);
|
|
6
|
-
var overRef = useRef(false);
|
|
7
6
|
var timerId = useRef(undefined);
|
|
8
7
|
var _a = useState(false), isDraggable = _a[0], setIsDraggable = _a[1];
|
|
9
8
|
var clearTimer = useCallback(function () {
|
|
10
|
-
|
|
9
|
+
if (timerId.current) {
|
|
10
|
+
clearTimeout(timerId.current);
|
|
11
|
+
timerId.current = undefined;
|
|
12
|
+
}
|
|
11
13
|
}, []);
|
|
12
14
|
var handleDragOver = useCallback(function (event) {
|
|
13
15
|
event.preventDefault();
|
|
14
16
|
setIsDraggable(true);
|
|
15
17
|
clearTimer();
|
|
16
18
|
timerId.current = setTimeout(function () {
|
|
17
|
-
overRef.current = false;
|
|
18
19
|
setIsDraggable(false);
|
|
19
20
|
}, 200);
|
|
20
21
|
}, [clearTimer]);
|
|
@@ -24,12 +25,23 @@ export var useDrop = function (props) {
|
|
|
24
25
|
}, []);
|
|
25
26
|
var handleDrop = useCallback(function (event) {
|
|
26
27
|
preventDefault(event);
|
|
28
|
+
clearTimer();
|
|
27
29
|
setIsDraggable(false);
|
|
28
|
-
overRef.current = false;
|
|
29
30
|
onDrop === null || onDrop === void 0 ? void 0 : onDrop(event);
|
|
30
|
-
}, [preventDefault, onDrop]);
|
|
31
|
+
}, [clearTimer, preventDefault, onDrop]);
|
|
31
32
|
useEffect(function () {
|
|
32
|
-
|
|
33
|
+
// Resolve refs and lazy parents after DOM refs attach (also works for iframe documents).
|
|
34
|
+
var resolveParent = function () {
|
|
35
|
+
if (typeof parent === 'function') {
|
|
36
|
+
return parent();
|
|
37
|
+
}
|
|
38
|
+
if (parent && 'current' in parent) {
|
|
39
|
+
return parent.current;
|
|
40
|
+
}
|
|
41
|
+
return parent;
|
|
42
|
+
};
|
|
43
|
+
var parentElement = resolveParent();
|
|
44
|
+
var ref = parent === undefined ? droppableRef.current : parentElement;
|
|
33
45
|
if (!ref) {
|
|
34
46
|
return;
|
|
35
47
|
}
|
|
@@ -38,12 +50,13 @@ export var useDrop = function (props) {
|
|
|
38
50
|
ref.addEventListener('dragover', handleDragOver);
|
|
39
51
|
ref.addEventListener('drop', handleDrop);
|
|
40
52
|
return function () {
|
|
53
|
+
clearTimer();
|
|
41
54
|
ref.removeEventListener('dragenter', preventDefault);
|
|
42
55
|
ref.removeEventListener('dragleave', preventDefault);
|
|
43
56
|
ref.removeEventListener('dragover', handleDragOver);
|
|
44
57
|
ref.removeEventListener('drop', handleDrop);
|
|
45
58
|
};
|
|
46
|
-
}, [handleDrop, handleDragOver, preventDefault]);
|
|
59
|
+
}, [clearTimer, handleDrop, handleDragOver, preventDefault, parent]);
|
|
47
60
|
return { isDraggable: isDraggable, ref: droppableRef };
|
|
48
61
|
};
|
|
49
62
|
//# sourceMappingURL=useDrop.js.map
|
package/hooks/useDrop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrop.js","sourceRoot":"","sources":["useDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE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AC,UAAU,EAAE,cAAc,CAAC,CAAC;YACpD,GAAG,CAAC,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC9C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;IAErE,OAAO,EAAE,WAAW,aAAA,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC;AAC5C,CAAC,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { MutableRefObject, RefObject } from 'react';\n\nimport type { SafeTimer } from '../lib/globalObject.js';\n\ninterface IUseDropProps<TElement> {\n onDrop?: (event: DragEvent) => void;\n parent?: TElement | RefObject<TElement | null> | (() => TElement | null | undefined) | null;\n}\n\ntype IElementWithListener = Pick<HTMLElement, 'addEventListener' | 'removeEventListener'>;\n\ninterface IUseDropResult<TElement extends IElementWithListener> {\n isDraggable: boolean;\n ref: MutableRefObject<TElement | null>;\n}\n\nexport const useDrop = <TElement extends IElementWithListener>(\n props: IUseDropProps<TElement> = {},\n): IUseDropResult<TElement> => {\n const { onDrop, parent } = props;\n\n const droppableRef = useRef<TElement>(null);\n const timerId = useRef<SafeTimer>(undefined);\n const [isDraggable, setIsDraggable] = useState<boolean>(false);\n\n const clearTimer = useCallback(() => {\n if (timerId.current) {\n clearTimeout(timerId.current);\n timerId.current = undefined;\n }\n }, []);\n\n const handleDragOver = useCallback(\n (event: DragEvent) => {\n event.preventDefault();\n setIsDraggable(true);\n\n clearTimer();\n timerId.current = setTimeout(() => {\n setIsDraggable(false);\n }, 200);\n },\n [clearTimer],\n );\n\n const preventDefault = useCallback((event: DragEvent) => {\n event.preventDefault();\n event.stopPropagation();\n }, []);\n\n const handleDrop = useCallback(\n (event: DragEvent) => {\n preventDefault(event);\n clearTimer();\n setIsDraggable(false);\n\n onDrop?.(event);\n },\n [clearTimer, preventDefault, onDrop],\n );\n\n useEffect(() => {\n // Resolve refs and lazy parents after DOM refs attach (also works for iframe documents).\n const resolveParent = () => {\n if (typeof parent === 'function') {\n return parent();\n }\n if (parent && 'current' in parent) {\n return parent.current;\n }\n return parent;\n };\n const parentElement = resolveParent();\n const ref = parent === undefined ? droppableRef.current : parentElement;\n\n if (!ref) {\n return;\n }\n\n ref.addEventListener('dragenter', preventDefault);\n ref.addEventListener('dragleave', preventDefault);\n ref.addEventListener('dragover', handleDragOver);\n ref.addEventListener('drop', handleDrop);\n\n return () => {\n clearTimer();\n ref.removeEventListener('dragenter', preventDefault);\n ref.removeEventListener('dragleave', preventDefault);\n ref.removeEventListener('dragover', handleDragOver);\n ref.removeEventListener('drop', handleDrop);\n };\n }, [clearTimer, handleDrop, handleDragOver, preventDefault, parent]);\n\n return { isDraggable, ref: droppableRef };\n};\n"]}
|
|
@@ -2,6 +2,22 @@ import { isFocusable, tabbable } from 'tabbable';
|
|
|
2
2
|
import { getOwnerGlobalObject } from '../../lib/globalObject.js';
|
|
3
3
|
import { isInstanceOf } from '../../lib/isInstanceOf.js';
|
|
4
4
|
import { isElement } from '../../lib/utils.js';
|
|
5
|
+
// `tabbable` >= 6.4.0 throws in old browsers (Chrome < 88, Firefox < 84) on the `:not([inert] *)` selector.
|
|
6
|
+
// Fallback list is `candidateSelectors` from tabbable 6.0.1 (no `:not([inert])` parts yet):
|
|
7
|
+
// https://github.com/focus-trap/tabbable/blob/v6.0.1/src/index.js
|
|
8
|
+
var FALLBACK_CANDIDATE_SELECTOR = [
|
|
9
|
+
'input',
|
|
10
|
+
'select',
|
|
11
|
+
'textarea',
|
|
12
|
+
'a[href]',
|
|
13
|
+
'button',
|
|
14
|
+
'[tabindex]:not(slot)',
|
|
15
|
+
'audio[controls]',
|
|
16
|
+
'video[controls]',
|
|
17
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
18
|
+
'details>summary:first-of-type',
|
|
19
|
+
'details',
|
|
20
|
+
].join(',');
|
|
5
21
|
/**
|
|
6
22
|
* Поиск всех элементов, у которых tabindex > -1, в переданном родителе
|
|
7
23
|
* или на всей странице
|
|
@@ -16,7 +32,13 @@ export var getTabbableElements = function (parent) {
|
|
|
16
32
|
if (!parent || !parent.children.length || !isInstanceOf(parent, getOwnerGlobalObject(parent).Element)) {
|
|
17
33
|
return [];
|
|
18
34
|
}
|
|
19
|
-
|
|
35
|
+
try {
|
|
36
|
+
return tabbable(parent);
|
|
37
|
+
}
|
|
38
|
+
catch (_a) {
|
|
39
|
+
// `tabIndex >= 0` matches the value `disableChildrenFocus` saves and restores.
|
|
40
|
+
return Array.from(parent.querySelectorAll(FALLBACK_CANDIDATE_SELECTOR)).filter(function (element) { return element.tabIndex >= 0; });
|
|
41
|
+
}
|
|
20
42
|
};
|
|
21
43
|
/**
|
|
22
44
|
* Поиск ближайшего фокусируемого элемента среди переданного и его родителей
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabbableHelpers.js","sourceRoot":"","sources":["tabbableHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;;;;;GAMG;AAEH,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAC,MAAoC;IACtE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QACtG,OAAO,EAAE,CAAC;IACZ,CAAC;
|
|
1
|
+
{"version":3,"file":"tabbableHelpers.js","sourceRoot":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B,GAAG,UAAC,OAA2B;IACpE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAC5F,CAAC,CAAC","sourcesContent":["import { isFocusable, tabbable } from 'tabbable';\nimport type { FocusableElement } from 'tabbable';\n\nimport { getOwnerGlobalObject } from '../../lib/globalObject.js';\nimport { isInstanceOf } from '../../lib/isInstanceOf.js';\nimport { isElement } from '../../lib/utils.js';\nimport type { Nullable } from '../../typings/utility-types.js';\n\n// `tabbable` >= 6.4.0 throws in old browsers (Chrome < 88, Firefox < 84) on the `:not([inert] *)` selector.\n// Fallback list is `candidateSelectors` from tabbable 6.0.1 (no `:not([inert])` parts yet):\n// https://github.com/focus-trap/tabbable/blob/v6.0.1/src/index.js\nconst FALLBACK_CANDIDATE_SELECTOR = [\n 'input',\n 'select',\n 'textarea',\n 'a[href]',\n 'button',\n '[tabindex]:not(slot)',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n 'details>summary:first-of-type',\n 'details',\n].join(',');\n\n/**\n * Поиск всех элементов, у которых tabindex > -1, в переданном родителе\n * или на всей странице\n * @param {Element|Document|null} [parent=document] - Родительский элемент,\n * внутри которого осуществляется поиск.\n * @return {FocusableElement[]} - Массив найденных элементов\n */\n\nexport const getTabbableElements = (parent: Nullable<Element | Document>): FocusableElement[] => {\n if (!isElement(parent)) {\n return [];\n }\n\n if (!parent || !parent.children.length || !isInstanceOf(parent, getOwnerGlobalObject(parent).Element)) {\n return [];\n }\n\n try {\n return tabbable(parent);\n } catch {\n // `tabIndex >= 0` matches the value `disableChildrenFocus` saves and restores.\n return Array.from(parent.querySelectorAll(FALLBACK_CANDIDATE_SELECTOR)).filter(\n (element): element is FocusableElement => (element as HTMLElement).tabIndex >= 0,\n );\n }\n};\n\n/**\n * Поиск ближайшего фокусируемого элемента среди переданного и его родителей\n * @param {HTMLElement} current - Текущий элемент\n * @return {HTMLElement|null} - Найденный элемент или null\n *\n */\n\nexport const getClosestFocusableElement = (current: HTMLElement | null): HTMLElement | null => {\n if (!current) {\n return null;\n }\n\n return isFocusable(current) ? current : getClosestFocusableElement(current.parentElement);\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/react-ui",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.4-f56fc.0",
|
|
4
4
|
"description": "UI Components",
|
|
5
5
|
"homepage": "https://tech.skbkontur.ru/kontur-ui",
|
|
6
6
|
"bugs": {
|
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
"release:unstable": "yarn release --tag=unstable",
|
|
252
252
|
"storybook": "storybook dev -p 6060",
|
|
253
253
|
"storybook:build": "cross-env STORYBOOK_REACT_UI_TEST=true storybook build -o .storybook/build --quiet",
|
|
254
|
-
"storybook:docs-build": "cross-env STORYBOOK_REACT_UI_DOCS=true NODE_OPTIONS=--max-old-space-size=
|
|
254
|
+
"storybook:docs-build": "cross-env STORYBOOK_REACT_UI_DOCS=true NODE_OPTIONS=--max-old-space-size=2048 storybook build --docs -c .storybook-docs -o .storybook/build --quiet && yarn docs:generate-ai",
|
|
255
255
|
"docs:generate-ai": "node scripts/generate-ai-docs.mts --strict",
|
|
256
256
|
"storybook:test": "cross-env STORYBOOK_REACT_UI_TEST=true storybook dev --ci -p 6060",
|
|
257
257
|
"storybook:docs": "cross-env STORYBOOK_REACT_UI_DOCS=true storybook dev --docs -p 6061 -c .storybook-docs",
|