@alfalab/core-components-attach
Advanced tools
Comparing version 1.3.3 to 1.4.0
@@ -5,8 +5,5 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var cn = _interopDefault(require('classnames')); | ||
var mergeRefs = _interopDefault(require('react-merge-refs')); | ||
var cn = require('classnames'); | ||
var mergeRefs = require('react-merge-refs'); | ||
var coreComponentsButton = require('@alfalab/core-components-button'); | ||
@@ -18,4 +15,10 @@ var coreComponentsProgressBar = require('@alfalab/core-components-progress-bar'); | ||
var utils = require('@alfalab/utils'); | ||
var index = require('./utils/index.js'); | ||
var utils_index = require('./utils/index.js'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn); | ||
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs); | ||
/*! ***************************************************************************** | ||
@@ -68,7 +71,7 @@ Copyright (c) Microsoft Corporation. | ||
var styles = {"component":"attach__component_13st5","label":"attach__label_13st5","control":"attach__control_13st5","xs":"attach__xs_13st5","file":"attach__file_13st5","noFile":"attach__noFile_13st5","s":"attach__s_13st5","m":"attach__m_13st5","l":"attach__l_13st5","clear":"attach__clear_13st5","progressBar":"attach__progressBar_13st5","disabled":"attach__disabled_13st5","icon":"attach__icon_13st5","focused":"attach__focused_13st5"}; | ||
var styles = {"component":"attach__component_2hj10","label":"attach__label_2hj10","control":"attach__control_2hj10","xs":"attach__xs_2hj10","file":"attach__file_2hj10","noFile":"attach__noFile_2hj10","s":"attach__s_2hj10","m":"attach__m_2hj10","l":"attach__l_2hj10","clear":"attach__clear_2hj10","progressBar":"attach__progressBar_2hj10","disabled":"attach__disabled_2hj10","icon":"attach__icon_2hj10","focused":"attach__focused_2hj10"}; | ||
require('./index.css') | ||
var MULTIPLE_TEXTS = ['файл', 'файла', 'файлов']; | ||
var Attach = React__default.forwardRef(function (_a, ref) { | ||
var Attach = React__default['default'].forwardRef(function (_a, ref) { | ||
var _b; | ||
@@ -106,22 +109,22 @@ var _c = _a.size, size = _c === void 0 ? 's' : _c, accept = _a.accept, _d = _a.buttonContent, buttonContent = _d === void 0 ? 'Выберите файл' : _d, _e = _a.buttonProps, buttonProps = _e === void 0 ? {} : _e, className = _a.className, disabled = _a.disabled, dataTestId = _a.dataTestId, id = _a.id, maxFilenameLength = _a.maxFilenameLength, multiple = _a.multiple, _f = _a.noFileText, noFileText = _f === void 0 ? 'Нет файла' : _f, progressBarPercent = _a.progressBarPercent, value = _a.value, onChange = _a.onChange, restProps = __rest(_a, ["size", "accept", "buttonContent", "buttonProps", "className", "disabled", "dataTestId", "id", "maxFilenameLength", "multiple", "noFileText", "progressBarPercent", "value", "onChange"]); | ||
var Icon = size === 'xs' ? AttachmentSBlackIcon.AttachmentSBlackIcon : AttachmentMBlackIcon.AttachmentMBlackIcon; | ||
var statusTextContent = files.length === 1 ? (index.truncateFilename(files[0].name, maxFilenameLength)) : (React__default.createElement("abbr", { title: files.map(function (file) { return file.name; }).join() }, | ||
var statusTextContent = files.length === 1 ? (utils_index.truncateFilename(files[0].name, maxFilenameLength)) : (React__default['default'].createElement("abbr", { title: files.map(function (file) { return file.name; }).join() }, | ||
files.length, | ||
" ", | ||
utils.pluralize.apply(void 0, __spreadArrays([files.length], MULTIPLE_TEXTS)))); | ||
return (React__default.createElement("div", { className: cn(styles.component, styles[size], (_b = {}, | ||
return (React__default['default'].createElement("div", { className: cn__default['default'](styles.component, styles[size], (_b = {}, | ||
_b[styles.disabled] = disabled, | ||
_b), className) }, | ||
React__default.createElement(coreComponentsButton.Button, __assign({}, buttonProps, { size: size, disabled: disabled, view: (buttonProps && buttonProps.view) || 'outlined', leftAddons: (buttonProps && buttonProps.leftAddons) || React__default.createElement(Icon, { className: styles.icon }), onClick: handleButtonClick, ref: buttonRef }), | ||
React__default.createElement("span", null, buttonContent)), | ||
React__default.createElement("label", { className: styles.label, htmlFor: id, ref: labelRef }, | ||
React__default.createElement("input", __assign({}, restProps, { className: styles.control, accept: accept, disabled: disabled, id: id, multiple: multiple, tabIndex: -1, type: 'file', onChange: handleInputChange, ref: mergeRefs([ref, inputRef]), "data-test-id": dataTestId }))), | ||
files && files.length > 0 ? (React__default.createElement("div", { className: styles.file }, | ||
React__default.createElement("span", null, statusTextContent), | ||
React__default.createElement(coreComponentsKeyboardFocusable.KeyboardFocusable, null, function (ref, focused) { | ||
React__default['default'].createElement(coreComponentsButton.Button, __assign({}, buttonProps, { size: size, disabled: disabled, view: (buttonProps && buttonProps.view) || 'outlined', leftAddons: (buttonProps && buttonProps.leftAddons) || React__default['default'].createElement(Icon, { className: styles.icon }), onClick: handleButtonClick, ref: buttonRef }), | ||
React__default['default'].createElement("span", null, buttonContent)), | ||
React__default['default'].createElement("label", { className: styles.label, htmlFor: id, ref: labelRef }, | ||
React__default['default'].createElement("input", __assign({}, restProps, { className: styles.control, accept: accept, disabled: disabled, id: id, multiple: multiple, tabIndex: -1, type: 'file', onChange: handleInputChange, ref: mergeRefs__default['default']([ref, inputRef]), "data-test-id": dataTestId }))), | ||
files && files.length > 0 ? (React__default['default'].createElement("div", { className: styles.file }, | ||
React__default['default'].createElement("span", null, statusTextContent), | ||
React__default['default'].createElement(coreComponentsKeyboardFocusable.KeyboardFocusable, null, function (ref, focused) { | ||
var _a; | ||
return (React__default.createElement("button", { "aria-label": '\u043E\u0447\u0438\u0441\u0442\u0438\u0442\u044C', type: 'button', className: cn(styles.clear, (_a = {}, | ||
return (React__default['default'].createElement("button", { "aria-label": '\u043E\u0447\u0438\u0441\u0442\u0438\u0442\u044C', type: 'button', className: cn__default['default'](styles.clear, (_a = {}, | ||
_a[styles.focused] = focused, | ||
_a)), onClick: handleClearClick, ref: ref })); | ||
}), | ||
progressBarPercent && (React__default.createElement(coreComponentsProgressBar.ProgressBar, { className: styles.progressBar, value: progressBarPercent, view: 'positive' })))) : (React__default.createElement("div", { className: styles.noFile }, noFileText)))); | ||
progressBarPercent && (React__default['default'].createElement(coreComponentsProgressBar.ProgressBar, { className: styles.progressBar, value: progressBarPercent, view: 'positive' })))) : (React__default['default'].createElement("div", { className: styles.noFile }, noFileText)))); | ||
}); | ||
@@ -128,0 +131,0 @@ /** |
@@ -5,8 +5,5 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var cn = _interopDefault(require('classnames')); | ||
var mergeRefs = _interopDefault(require('react-merge-refs')); | ||
var cn = require('classnames'); | ||
var mergeRefs = require('react-merge-refs'); | ||
var coreComponentsButton = require('@alfalab/core-components-button/dist/cssm'); | ||
@@ -18,5 +15,12 @@ var coreComponentsProgressBar = require('@alfalab/core-components-progress-bar/dist/cssm'); | ||
var utils = require('@alfalab/utils'); | ||
var index = require('./utils/index.js'); | ||
var styles = _interopDefault(require('./index.module.css')); | ||
var utils_index = require('./utils/index.js'); | ||
var styles = require('./index.module.css'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn); | ||
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs); | ||
var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles); | ||
/*! ***************************************************************************** | ||
@@ -70,3 +74,3 @@ Copyright (c) Microsoft Corporation. | ||
var MULTIPLE_TEXTS = ['файл', 'файла', 'файлов']; | ||
var Attach = React__default.forwardRef(function (_a, ref) { | ||
var Attach = React__default['default'].forwardRef(function (_a, ref) { | ||
var _b; | ||
@@ -104,22 +108,22 @@ var _c = _a.size, size = _c === void 0 ? 's' : _c, accept = _a.accept, _d = _a.buttonContent, buttonContent = _d === void 0 ? 'Выберите файл' : _d, _e = _a.buttonProps, buttonProps = _e === void 0 ? {} : _e, className = _a.className, disabled = _a.disabled, dataTestId = _a.dataTestId, id = _a.id, maxFilenameLength = _a.maxFilenameLength, multiple = _a.multiple, _f = _a.noFileText, noFileText = _f === void 0 ? 'Нет файла' : _f, progressBarPercent = _a.progressBarPercent, value = _a.value, onChange = _a.onChange, restProps = __rest(_a, ["size", "accept", "buttonContent", "buttonProps", "className", "disabled", "dataTestId", "id", "maxFilenameLength", "multiple", "noFileText", "progressBarPercent", "value", "onChange"]); | ||
var Icon = size === 'xs' ? AttachmentSBlackIcon.AttachmentSBlackIcon : AttachmentMBlackIcon.AttachmentMBlackIcon; | ||
var statusTextContent = files.length === 1 ? (index.truncateFilename(files[0].name, maxFilenameLength)) : (React__default.createElement("abbr", { title: files.map(function (file) { return file.name; }).join() }, | ||
var statusTextContent = files.length === 1 ? (utils_index.truncateFilename(files[0].name, maxFilenameLength)) : (React__default['default'].createElement("abbr", { title: files.map(function (file) { return file.name; }).join() }, | ||
files.length, | ||
" ", | ||
utils.pluralize.apply(void 0, __spreadArrays([files.length], MULTIPLE_TEXTS)))); | ||
return (React__default.createElement("div", { className: cn(styles.component, styles[size], (_b = {}, | ||
_b[styles.disabled] = disabled, | ||
return (React__default['default'].createElement("div", { className: cn__default['default'](styles__default['default'].component, styles__default['default'][size], (_b = {}, | ||
_b[styles__default['default'].disabled] = disabled, | ||
_b), className) }, | ||
React__default.createElement(coreComponentsButton.Button, __assign({}, buttonProps, { size: size, disabled: disabled, view: (buttonProps && buttonProps.view) || 'outlined', leftAddons: (buttonProps && buttonProps.leftAddons) || React__default.createElement(Icon, { className: styles.icon }), onClick: handleButtonClick, ref: buttonRef }), | ||
React__default.createElement("span", null, buttonContent)), | ||
React__default.createElement("label", { className: styles.label, htmlFor: id, ref: labelRef }, | ||
React__default.createElement("input", __assign({}, restProps, { className: styles.control, accept: accept, disabled: disabled, id: id, multiple: multiple, tabIndex: -1, type: 'file', onChange: handleInputChange, ref: mergeRefs([ref, inputRef]), "data-test-id": dataTestId }))), | ||
files && files.length > 0 ? (React__default.createElement("div", { className: styles.file }, | ||
React__default.createElement("span", null, statusTextContent), | ||
React__default.createElement(coreComponentsKeyboardFocusable.KeyboardFocusable, null, function (ref, focused) { | ||
React__default['default'].createElement(coreComponentsButton.Button, __assign({}, buttonProps, { size: size, disabled: disabled, view: (buttonProps && buttonProps.view) || 'outlined', leftAddons: (buttonProps && buttonProps.leftAddons) || React__default['default'].createElement(Icon, { className: styles__default['default'].icon }), onClick: handleButtonClick, ref: buttonRef }), | ||
React__default['default'].createElement("span", null, buttonContent)), | ||
React__default['default'].createElement("label", { className: styles__default['default'].label, htmlFor: id, ref: labelRef }, | ||
React__default['default'].createElement("input", __assign({}, restProps, { className: styles__default['default'].control, accept: accept, disabled: disabled, id: id, multiple: multiple, tabIndex: -1, type: 'file', onChange: handleInputChange, ref: mergeRefs__default['default']([ref, inputRef]), "data-test-id": dataTestId }))), | ||
files && files.length > 0 ? (React__default['default'].createElement("div", { className: styles__default['default'].file }, | ||
React__default['default'].createElement("span", null, statusTextContent), | ||
React__default['default'].createElement(coreComponentsKeyboardFocusable.KeyboardFocusable, null, function (ref, focused) { | ||
var _a; | ||
return (React__default.createElement("button", { "aria-label": '\u043E\u0447\u0438\u0441\u0442\u0438\u0442\u044C', type: 'button', className: cn(styles.clear, (_a = {}, | ||
_a[styles.focused] = focused, | ||
return (React__default['default'].createElement("button", { "aria-label": '\u043E\u0447\u0438\u0441\u0442\u0438\u0442\u044C', type: 'button', className: cn__default['default'](styles__default['default'].clear, (_a = {}, | ||
_a[styles__default['default'].focused] = focused, | ||
_a)), onClick: handleClearClick, ref: ref })); | ||
}), | ||
progressBarPercent && (React__default.createElement(coreComponentsProgressBar.ProgressBar, { className: styles.progressBar, value: progressBarPercent, view: 'positive' })))) : (React__default.createElement("div", { className: styles.noFile }, noFileText)))); | ||
progressBarPercent && (React__default['default'].createElement(coreComponentsProgressBar.ProgressBar, { className: styles__default['default'].progressBar, value: progressBarPercent, view: 'positive' })))) : (React__default['default'].createElement("div", { className: styles__default['default'].noFile }, noFileText)))); | ||
}); | ||
@@ -126,0 +130,0 @@ /** |
@@ -59,3 +59,3 @@ import React, { useState, useRef, useCallback } from 'react'; | ||
var styles = {"component":"attach__component_13st5","label":"attach__label_13st5","control":"attach__control_13st5","xs":"attach__xs_13st5","file":"attach__file_13st5","noFile":"attach__noFile_13st5","s":"attach__s_13st5","m":"attach__m_13st5","l":"attach__l_13st5","clear":"attach__clear_13st5","progressBar":"attach__progressBar_13st5","disabled":"attach__disabled_13st5","icon":"attach__icon_13st5","focused":"attach__focused_13st5"}; | ||
var styles = {"component":"attach__component_2hj10","label":"attach__label_2hj10","control":"attach__control_2hj10","xs":"attach__xs_2hj10","file":"attach__file_2hj10","noFile":"attach__noFile_2hj10","s":"attach__s_2hj10","m":"attach__m_2hj10","l":"attach__l_2hj10","clear":"attach__clear_2hj10","progressBar":"attach__progressBar_2hj10","disabled":"attach__disabled_2hj10","icon":"attach__icon_2hj10","focused":"attach__focused_2hj10"}; | ||
require('./index.css') | ||
@@ -62,0 +62,0 @@ |
@@ -12,3 +12,3 @@ import React, { useState, useRef, useCallback } from 'react'; | ||
var styles = {"component":"attach__component_13st5","label":"attach__label_13st5","control":"attach__control_13st5","xs":"attach__xs_13st5","file":"attach__file_13st5","noFile":"attach__noFile_13st5","s":"attach__s_13st5","m":"attach__m_13st5","l":"attach__l_13st5","clear":"attach__clear_13st5","progressBar":"attach__progressBar_13st5","disabled":"attach__disabled_13st5","icon":"attach__icon_13st5","focused":"attach__focused_13st5"}; | ||
var styles = {"component":"attach__component_2hj10","label":"attach__label_2hj10","control":"attach__control_2hj10","xs":"attach__xs_2hj10","file":"attach__file_2hj10","noFile":"attach__noFile_2hj10","s":"attach__s_2hj10","m":"attach__m_2hj10","l":"attach__l_2hj10","clear":"attach__clear_2hj10","progressBar":"attach__progressBar_2hj10","disabled":"attach__disabled_2hj10","icon":"attach__icon_2hj10","focused":"attach__focused_2hj10"}; | ||
require('./index.css') | ||
@@ -15,0 +15,0 @@ |
{ | ||
"name": "@alfalab/core-components-attach", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"description": "", | ||
@@ -19,3 +19,3 @@ "keywords": [], | ||
"dependencies": { | ||
"@alfalab/core-components-button": "^1.10.0", | ||
"@alfalab/core-components-button": "^1.11.0", | ||
"@alfalab/core-components-keyboard-focusable": "^1.2.4", | ||
@@ -28,3 +28,3 @@ "@alfalab/core-components-progress-bar": "^1.0.6", | ||
}, | ||
"gitHead": "535abe93e4e8a8874b20cb961e3cf9b0001a7371" | ||
"gitHead": "2cd9a78cfd6e939d2efc48e4ef8092aa96e9e99b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73525
1335