@cloud-ru/ds-attachment 1.0.5-preview-04507fc5.0 → 1.1.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 +6 -0
- package/README.md +1 -0
- package/dist/cjs/components/Attachment/Attachment.d.ts +1 -1
- package/dist/cjs/components/Attachment/Attachment.js +2 -2
- package/dist/cjs/components/Attachment/styles.module.css +4 -0
- package/dist/cjs/style.css +4 -0
- package/dist/cjs/types.d.ts +5 -0
- package/dist/esm/components/Attachment/Attachment.d.ts +1 -1
- package/dist/esm/components/Attachment/Attachment.js +2 -2
- package/dist/esm/components/Attachment/styles.module.css +4 -0
- package/dist/esm/style.css +4 -0
- package/dist/esm/types.d.ts +5 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/components/Attachment/Attachment.tsx +2 -0
- package/src/components/Attachment/styles.module.scss +5 -0
- package/src/types.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
# 1.1.0 (2026-08-27)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **FF-8948:** add fullWidth prop to Attachment ([d685af7](https://github.com/cloud-ru-tech/snack-v2/commit/d685af7187b363926dd0ff9d15b308b82ee0975b))
|
|
11
|
+
|
|
6
12
|
## 1.0.4 (2026-08-25)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @ds/attachment
|
package/README.md
CHANGED
|
@@ -188,6 +188,7 @@ export function AttachmentSelectable() {
|
|
|
188
188
|
| `disabled` | `boolean` | — | Заблокировано |
|
|
189
189
|
| `error` | `string` | — | Сообщение об ошибке |
|
|
190
190
|
| `file` | `File` | — | Файл |
|
|
191
|
+
| `fullWidth` | `boolean` | `true` | Растянуть карточку на всю ширину контейнера. Выключенная — ужимается по содержимому. |
|
|
191
192
|
| `icon` | `IconPredefinedProps` | — | Иконка для файла <br/> @defaultIcon FileSVG |
|
|
192
193
|
| `loading` | `boolean` | — | Управление состоянием загрузки |
|
|
193
194
|
| `onClick` | `((event: MouseEvent<HTMLDivElement, MouseEvent>) => void)` | — | Клик по карточке |
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AttachmentProps } from '../../types';
|
|
2
|
-
export declare function Attachment({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size, truncate, className, ...rest }: AttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function Attachment({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size, truncate, fullWidth, className, ...rest }: AttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,14 +15,14 @@ const hooks_1 = require("../../hooks");
|
|
|
15
15
|
const utils_2 = require("../../utils");
|
|
16
16
|
const Emblem_1 = require("./components/Emblem");
|
|
17
17
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
18
|
-
function Attachment({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size = 's', truncate, className, ...rest }) {
|
|
18
|
+
function Attachment({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size = 's', truncate, fullWidth = true, className, ...rest }) {
|
|
19
19
|
const { loading: loadingImage, imageData } = (0, hooks_1.useImage)(file);
|
|
20
20
|
const isLoading = loading || loadingImage;
|
|
21
21
|
const title = titleProp || (0, utils_2.getBaseFileName)(file?.name);
|
|
22
22
|
const description = descriptionProp || (0, utils_2.getFileExtension)(file?.name);
|
|
23
23
|
const interactive = Boolean(!isLoading && !disabled && onClick);
|
|
24
24
|
const hasError = Boolean(error);
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(card_1.Card, { ...(0, utils_1.extractSupportProps)(rest), view: 'outline', radius: size === 's' ? 's' : 'm', backgroundPredefined: hasError ? materials_1.BACKGROUND_PREDEFINED_FILL.RedBackground : materials_1.BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level, disabled: !loading && disabled, checked: !loading && checked, multiSelect: true, interactive: interactive, className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-attachment-error": hasError || undefined, "aria-busy": isLoading || undefined, children: (0, jsx_runtime_1.jsx)(context_1.AttachmentContext.Provider, { value: { file, truncateVariant, onDelete, onDownload, onRetry, disabled, size, truncate }, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.composition, "data-size": size, "data-loading": isLoading || undefined, "data-error": hasError || undefined, onClick: interactive ? onClick : undefined, role: interactive ? 'button' : undefined,
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(card_1.Card, { ...(0, utils_1.extractSupportProps)(rest), view: 'outline', radius: size === 's' ? 's' : 'm', backgroundPredefined: hasError ? materials_1.BACKGROUND_PREDEFINED_FILL.RedBackground : materials_1.BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level, disabled: !loading && disabled, checked: !loading && checked, multiSelect: true, interactive: interactive, className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-full-width": fullWidth || undefined, "data-attachment-error": hasError || undefined, "aria-busy": isLoading || undefined, children: (0, jsx_runtime_1.jsx)(context_1.AttachmentContext.Provider, { value: { file, truncateVariant, onDelete, onDownload, onRetry, disabled, size, truncate }, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.composition, "data-size": size, "data-loading": isLoading || undefined, "data-error": hasError || undefined, onClick: interactive ? onClick : undefined, role: interactive ? 'button' : undefined,
|
|
26
26
|
// Card-корень сам фокусируется (tabIndex=0); внутренний кликабельный wrapper
|
|
27
27
|
// забирает себе только обработчик, но в tab-order не участвует.
|
|
28
28
|
tabIndex: -1, children: [(0, jsx_runtime_1.jsx)(Emblem_1.Emblem, { title: title, loading: isLoading, icon: icon, imageData: imageData }), (0, jsx_runtime_1.jsx)(helperComponents_1.TextBlock, { title: title, description: description, error: error }), (0, jsx_runtime_1.jsx)(helperComponents_1.Actions, { hideDownload: isLoading || hasError, hideRetry: isLoading || !hasError })] }) }) }));
|
package/dist/cjs/style.css
CHANGED
package/dist/cjs/types.d.ts
CHANGED
|
@@ -50,6 +50,11 @@ export type AttachmentSquareProps = WithSupportProps<{
|
|
|
50
50
|
className?: string;
|
|
51
51
|
}>;
|
|
52
52
|
export type AttachmentProps = AttachmentSquareProps & {
|
|
53
|
+
/**
|
|
54
|
+
* Растянуть карточку на всю ширину контейнера. Выключенная — ужимается по содержимому.
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
fullWidth?: boolean;
|
|
53
58
|
truncate?: {
|
|
54
59
|
/**
|
|
55
60
|
* Максимальное кол-во строк заголовка
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AttachmentProps } from '../../types.js';
|
|
2
|
-
export declare function Attachment({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size, truncate, className, ...rest }: AttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function Attachment({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size, truncate, fullWidth, className, ...rest }: AttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,14 +9,14 @@ import { useImage } from '../../hooks.js';
|
|
|
9
9
|
import { getBaseFileName, getFileExtension } from '../../utils.js';
|
|
10
10
|
import { Emblem } from './components/Emblem/index.js';
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
|
-
export function Attachment({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size = 's', truncate, className, ...rest }) {
|
|
12
|
+
export function Attachment({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size = 's', truncate, fullWidth = true, className, ...rest }) {
|
|
13
13
|
const { loading: loadingImage, imageData } = useImage(file);
|
|
14
14
|
const isLoading = loading || loadingImage;
|
|
15
15
|
const title = titleProp || getBaseFileName(file?.name);
|
|
16
16
|
const description = descriptionProp || getFileExtension(file?.name);
|
|
17
17
|
const interactive = Boolean(!isLoading && !disabled && onClick);
|
|
18
18
|
const hasError = Boolean(error);
|
|
19
|
-
return (_jsx(Card, { ...extractSupportProps(rest), view: 'outline', radius: size === 's' ? 's' : 'm', backgroundPredefined: hasError ? BACKGROUND_PREDEFINED_FILL.RedBackground : BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level, disabled: !loading && disabled, checked: !loading && checked, multiSelect: true, interactive: interactive, className: cn(styles.root, className), "data-attachment-error": hasError || undefined, "aria-busy": isLoading || undefined, children: _jsx(AttachmentContext.Provider, { value: { file, truncateVariant, onDelete, onDownload, onRetry, disabled, size, truncate }, children: _jsxs("div", { className: styles.composition, "data-size": size, "data-loading": isLoading || undefined, "data-error": hasError || undefined, onClick: interactive ? onClick : undefined, role: interactive ? 'button' : undefined,
|
|
19
|
+
return (_jsx(Card, { ...extractSupportProps(rest), view: 'outline', radius: size === 's' ? 's' : 'm', backgroundPredefined: hasError ? BACKGROUND_PREDEFINED_FILL.RedBackground : BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level, disabled: !loading && disabled, checked: !loading && checked, multiSelect: true, interactive: interactive, className: cn(styles.root, className), "data-full-width": fullWidth || undefined, "data-attachment-error": hasError || undefined, "aria-busy": isLoading || undefined, children: _jsx(AttachmentContext.Provider, { value: { file, truncateVariant, onDelete, onDownload, onRetry, disabled, size, truncate }, children: _jsxs("div", { className: styles.composition, "data-size": size, "data-loading": isLoading || undefined, "data-error": hasError || undefined, onClick: interactive ? onClick : undefined, role: interactive ? 'button' : undefined,
|
|
20
20
|
// Card-корень сам фокусируется (tabIndex=0); внутренний кликабельный wrapper
|
|
21
21
|
// забирает себе только обработчик, но в tab-order не участвует.
|
|
22
22
|
tabIndex: -1, children: [_jsx(Emblem, { title: title, loading: isLoading, icon: icon, imageData: imageData }), _jsx(TextBlock, { title: title, description: description, error: error }), _jsx(Actions, { hideDownload: isLoading || hasError, hideRetry: isLoading || !hasError })] }) }) }));
|
package/dist/esm/style.css
CHANGED
package/dist/esm/types.d.ts
CHANGED
|
@@ -50,6 +50,11 @@ export type AttachmentSquareProps = WithSupportProps<{
|
|
|
50
50
|
className?: string;
|
|
51
51
|
}>;
|
|
52
52
|
export type AttachmentProps = AttachmentSquareProps & {
|
|
53
|
+
/**
|
|
54
|
+
* Растянуть карточку на всю ширину контейнера. Выключенная — ужимается по содержимому.
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
fullWidth?: boolean;
|
|
53
58
|
truncate?: {
|
|
54
59
|
/**
|
|
55
60
|
* Максимальное кол-во строк заголовка
|