@snack-uikit/attachment 0.0.1-preview-bfae2d03.0 → 0.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 +16 -0
- package/dist/components/Attachment/Attachment.d.ts +1 -1
- package/dist/components/Attachment/Attachment.js +2 -2
- package/dist/components/AttachmentSquare/AttachmentSquare.d.ts +1 -1
- package/dist/components/AttachmentSquare/AttachmentSquare.js +2 -2
- package/dist/components/AttachmentSquare/components/styles.module.css +1 -0
- package/dist/components/AttachmentSquare/styles.module.css +4 -0
- package/package.json +3 -3
- package/src/components/Attachment/Attachment.tsx +3 -1
- package/src/components/AttachmentSquare/AttachmentSquare.tsx +3 -2
- package/src/components/AttachmentSquare/components/styles.module.scss +1 -0
- package/src/components/AttachmentSquare/styles.module.scss +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 0.1.0 (2024-05-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PDS-172:** add attachment ([fecc3a2](https://github.com/cloud-ru-tech/snack-uikit/commit/fecc3a2aa922d06827f115a8a020da8615985a16))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
1
17
|
## CHANGELOG
|
|
2
18
|
|
|
3
19
|
### v0.0.0
|
|
@@ -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, ...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, className, ...rest }: AttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,10 +19,10 @@ import { useImage } from '../../hooks';
|
|
|
19
19
|
import { Emblem } from './components';
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
export function Attachment(_a) {
|
|
22
|
-
var { file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size = 's', truncate } = _a, rest = __rest(_a, ["file", "loading", "icon", "title", "description", "error", "disabled", "truncateVariant", "checked", "onDownload", "onDelete", "onClick", "onRetry", "size", "truncate"]);
|
|
22
|
+
var { file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size = 's', truncate, className } = _a, rest = __rest(_a, ["file", "loading", "icon", "title", "description", "error", "disabled", "truncateVariant", "checked", "onDownload", "onDelete", "onClick", "onRetry", "size", "truncate", "className"]);
|
|
23
23
|
const { loading: loadingImage, imageData } = useImage(file);
|
|
24
24
|
const isLoading = loading || loadingImage;
|
|
25
25
|
const title = titleProp || getBaseFileName(file === null || file === void 0 ? void 0 : file.name);
|
|
26
26
|
const description = descriptionProp || getFileExtension(file === null || file === void 0 ? void 0 : file.name);
|
|
27
|
-
return (_jsx(Card, Object.assign({}, extractSupportProps(rest), { outline: true, disabled: disabled, checked: !loading && checked, multipleSelection: true, size: size, onClick: !isLoading && !disabled ? onClick : undefined, header: _jsx(AttachmentContext.Provider, { value: { file, truncateVariant, onDelete, onDownload, onRetry, disabled, size, truncate }, children: _jsxs("div", { className: styles.composition, "data-size": size, children: [_jsx(Emblem, { title: title, loading: isLoading, icon: icon, imageData: imageData }), _jsx(TextBlock, { title: title, description: description, error: error }), _jsx(Actions, { hideDownload: isLoading || Boolean(error), hideRetry: isLoading || !Boolean(error) })] }) }) })));
|
|
27
|
+
return (_jsx(Card, Object.assign({}, extractSupportProps(rest), { outline: true, disabled: !loading && disabled, checked: !loading && checked, multipleSelection: true, className: className, size: size, onClick: !isLoading && !disabled ? onClick : undefined, header: _jsx(AttachmentContext.Provider, { value: { file, truncateVariant, onDelete, onDownload, onRetry, disabled, size, truncate }, children: _jsxs("div", { className: styles.composition, "data-size": size, children: [_jsx(Emblem, { title: title, loading: isLoading, icon: icon, imageData: imageData }), _jsx(TextBlock, { title: title, description: description, error: error }), _jsx(Actions, { hideDownload: isLoading || Boolean(error), hideRetry: isLoading || !Boolean(error) })] }) }) })));
|
|
28
28
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AttachmentSquareProps } from '../../types';
|
|
2
|
-
export declare function AttachmentSquare({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size, ...rest }: AttachmentSquareProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function AttachmentSquare({ file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size, className, ...rest }: AttachmentSquareProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,13 +20,13 @@ import { useImage } from '../../hooks';
|
|
|
20
20
|
import { HoverContent, LoadingContent, MainContent } from './components';
|
|
21
21
|
import styles from './styles.module.css';
|
|
22
22
|
export function AttachmentSquare(_a) {
|
|
23
|
-
var { file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size = 's' } = _a, rest = __rest(_a, ["file", "loading", "icon", "title", "description", "error", "disabled", "truncateVariant", "checked", "onDownload", "onDelete", "onClick", "onRetry", "size"]);
|
|
23
|
+
var { file, loading, icon, title: titleProp, description: descriptionProp, error, disabled, truncateVariant, checked, onDownload, onDelete, onClick, onRetry, size = 's', className } = _a, rest = __rest(_a, ["file", "loading", "icon", "title", "description", "error", "disabled", "truncateVariant", "checked", "onDownload", "onDelete", "onClick", "onRetry", "size", "className"]);
|
|
24
24
|
const { loading: loadingImage, imageData } = useImage(file);
|
|
25
25
|
const isLoading = loading || loadingImage;
|
|
26
26
|
const title = titleProp || getBaseFileName(file === null || file === void 0 ? void 0 : file.name);
|
|
27
27
|
const description = descriptionProp || getFileExtension(file === null || file === void 0 ? void 0 : file.name);
|
|
28
28
|
const [hasFocusedActions, setHasFocusedActions] = useState(false);
|
|
29
|
-
return (_jsx(Card, Object.assign({}, extractSupportProps(rest), { outline: true, disabled: disabled, size: size, className: cn(styles.wrapper, {
|
|
29
|
+
return (_jsx(Card, Object.assign({}, extractSupportProps(rest), { outline: true, disabled: !loading && disabled, size: size, className: cn(className, styles.wrapper, {
|
|
30
30
|
[styles.sizeS]: size === 's',
|
|
31
31
|
[styles.sizeM]: size === 'm',
|
|
32
32
|
[styles.hasFocusedActions]: hasFocusedActions,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
.wrapper{
|
|
2
|
+
flex-shrink:0;
|
|
3
|
+
}
|
|
1
4
|
.wrapper.sizeS{
|
|
2
5
|
width:var(--size-attachment-container-square-s, 80px);
|
|
3
6
|
height:var(--size-attachment-container-square-s, 80px);
|
|
@@ -8,6 +11,7 @@
|
|
|
8
11
|
}
|
|
9
12
|
.wrapper .main{
|
|
10
13
|
display:flex;
|
|
14
|
+
flex-shrink:0;
|
|
11
15
|
}
|
|
12
16
|
.wrapper .hover{
|
|
13
17
|
pointer-events:none;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Attachment",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.1.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@snack-uikit/button": "0.17.1",
|
|
36
|
-
"@snack-uikit/card": "0.12.14
|
|
36
|
+
"@snack-uikit/card": "0.12.14",
|
|
37
37
|
"@snack-uikit/icon-predefined": "0.5.1",
|
|
38
38
|
"@snack-uikit/icons": "0.21.0",
|
|
39
39
|
"@snack-uikit/loaders": "0.5.2",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"@snack-uikit/utils": "3.3.0",
|
|
42
42
|
"classnames": "2.3.2"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "616e36de014b8451e203bcb195f0996ed4af75d6"
|
|
45
45
|
}
|
|
@@ -25,6 +25,7 @@ export function Attachment({
|
|
|
25
25
|
onRetry,
|
|
26
26
|
size = 's',
|
|
27
27
|
truncate,
|
|
28
|
+
className,
|
|
28
29
|
...rest
|
|
29
30
|
}: AttachmentProps) {
|
|
30
31
|
const { loading: loadingImage, imageData } = useImage(file);
|
|
@@ -37,9 +38,10 @@ export function Attachment({
|
|
|
37
38
|
<Card
|
|
38
39
|
{...extractSupportProps(rest)}
|
|
39
40
|
outline
|
|
40
|
-
disabled={disabled}
|
|
41
|
+
disabled={!loading && disabled}
|
|
41
42
|
checked={!loading && checked}
|
|
42
43
|
multipleSelection
|
|
44
|
+
className={className}
|
|
43
45
|
size={size}
|
|
44
46
|
onClick={!isLoading && !disabled ? onClick : undefined}
|
|
45
47
|
header={
|
|
@@ -26,6 +26,7 @@ export function AttachmentSquare({
|
|
|
26
26
|
onClick,
|
|
27
27
|
onRetry,
|
|
28
28
|
size = 's',
|
|
29
|
+
className,
|
|
29
30
|
...rest
|
|
30
31
|
}: AttachmentSquareProps) {
|
|
31
32
|
const { loading: loadingImage, imageData } = useImage(file);
|
|
@@ -40,9 +41,9 @@ export function AttachmentSquare({
|
|
|
40
41
|
<Card
|
|
41
42
|
{...extractSupportProps(rest)}
|
|
42
43
|
outline
|
|
43
|
-
disabled={disabled}
|
|
44
|
+
disabled={!loading && disabled}
|
|
44
45
|
size={size}
|
|
45
|
-
className={cn(styles.wrapper, {
|
|
46
|
+
className={cn(className, styles.wrapper, {
|
|
46
47
|
[styles.sizeS]: size === 's',
|
|
47
48
|
[styles.sizeM]: size === 'm',
|
|
48
49
|
[styles.hasFocusedActions]: hasFocusedActions,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-attachment';
|
|
2
2
|
|
|
3
3
|
.wrapper {
|
|
4
|
+
flex-shrink: 0;
|
|
5
|
+
|
|
4
6
|
&.sizeS {
|
|
5
7
|
@include composite-var($attachment-container-square-s);
|
|
6
8
|
}
|
|
@@ -11,6 +13,7 @@
|
|
|
11
13
|
|
|
12
14
|
.main {
|
|
13
15
|
display: flex;
|
|
16
|
+
flex-shrink: 0;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
.hover {
|