@cloud-ru/ds-attachment 1.0.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 +8 -0
- package/LICENSE +201 -0
- package/README.md +312 -0
- package/dist/cjs/components/Attachment/Attachment.d.ts +2 -0
- package/dist/cjs/components/Attachment/Attachment.js +29 -0
- package/dist/cjs/components/Attachment/components/Emblem/Emblem.d.ts +5 -0
- package/dist/cjs/components/Attachment/components/Emblem/Emblem.js +30 -0
- package/dist/cjs/components/Attachment/components/Emblem/index.d.ts +1 -0
- package/dist/cjs/components/Attachment/components/Emblem/index.js +17 -0
- package/dist/cjs/components/Attachment/components/Emblem/styles.module.css +32 -0
- package/dist/cjs/components/Attachment/index.d.ts +1 -0
- package/dist/cjs/components/Attachment/index.js +17 -0
- package/dist/cjs/components/Attachment/styles.module.css +23 -0
- package/dist/cjs/components/AttachmentSquare/AttachmentSquare.d.ts +2 -0
- package/dist/cjs/components/AttachmentSquare/AttachmentSquare.js +53 -0
- package/dist/cjs/components/AttachmentSquare/components/HoverContent/HoverContent.d.ts +7 -0
- package/dist/cjs/components/AttachmentSquare/components/HoverContent/HoverContent.js +19 -0
- package/dist/cjs/components/AttachmentSquare/components/HoverContent/index.d.ts +1 -0
- package/dist/cjs/components/AttachmentSquare/components/HoverContent/index.js +17 -0
- package/dist/cjs/components/AttachmentSquare/components/HoverContent/styles.module.css +20 -0
- package/dist/cjs/components/AttachmentSquare/components/LoadingContent/LoadingContent.d.ts +1 -0
- package/dist/cjs/components/AttachmentSquare/components/LoadingContent/LoadingContent.js +14 -0
- package/dist/cjs/components/AttachmentSquare/components/LoadingContent/index.d.ts +1 -0
- package/dist/cjs/components/AttachmentSquare/components/LoadingContent/index.js +17 -0
- package/dist/cjs/components/AttachmentSquare/components/LoadingContent/styles.module.css +9 -0
- package/dist/cjs/components/AttachmentSquare/components/MainContent/MainContent.d.ts +7 -0
- package/dist/cjs/components/AttachmentSquare/components/MainContent/MainContent.js +22 -0
- package/dist/cjs/components/AttachmentSquare/components/MainContent/index.d.ts +1 -0
- package/dist/cjs/components/AttachmentSquare/components/MainContent/index.js +17 -0
- package/dist/cjs/components/AttachmentSquare/components/MainContent/styles.module.css +38 -0
- package/dist/cjs/components/AttachmentSquare/index.d.ts +1 -0
- package/dist/cjs/components/AttachmentSquare/index.js +17 -0
- package/dist/cjs/components/AttachmentSquare/styles.module.css +68 -0
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +18 -0
- package/dist/cjs/constants.d.ts +18 -0
- package/dist/cjs/constants.js +22 -0
- package/dist/cjs/context.d.ts +10 -0
- package/dist/cjs/context.js +17 -0
- package/dist/cjs/helperComponents/Actions/Actions.d.ts +7 -0
- package/dist/cjs/helperComponents/Actions/Actions.js +38 -0
- package/dist/cjs/helperComponents/Actions/index.d.ts +1 -0
- package/dist/cjs/helperComponents/Actions/index.js +17 -0
- package/dist/cjs/helperComponents/Actions/styles.module.css +4 -0
- package/dist/cjs/helperComponents/Text/Text.d.ts +9 -0
- package/dist/cjs/helperComponents/Text/Text.js +15 -0
- package/dist/cjs/helperComponents/Text/index.d.ts +1 -0
- package/dist/cjs/helperComponents/Text/index.js +17 -0
- package/dist/cjs/helperComponents/TextBlock/TextBlock.d.ts +5 -0
- package/dist/cjs/helperComponents/TextBlock/TextBlock.js +17 -0
- package/dist/cjs/helperComponents/TextBlock/index.d.ts +1 -0
- package/dist/cjs/helperComponents/TextBlock/index.js +17 -0
- package/dist/cjs/helperComponents/TextBlock/styles.module.css +56 -0
- package/dist/cjs/helperComponents/index.d.ts +3 -0
- package/dist/cjs/helperComponents/index.js +19 -0
- package/dist/cjs/hooks.d.ts +4 -0
- package/dist/cjs/hooks.js +37 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/style.css +250 -0
- package/dist/cjs/types.d.ts +70 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils.d.ts +6 -0
- package/dist/cjs/utils.js +28 -0
- package/dist/esm/components/Attachment/Attachment.d.ts +2 -0
- package/dist/esm/components/Attachment/Attachment.js +23 -0
- package/dist/esm/components/Attachment/components/Emblem/Emblem.d.ts +5 -0
- package/dist/esm/components/Attachment/components/Emblem/Emblem.js +24 -0
- package/dist/esm/components/Attachment/components/Emblem/index.d.ts +1 -0
- package/dist/esm/components/Attachment/components/Emblem/index.js +1 -0
- package/dist/esm/components/Attachment/components/Emblem/styles.module.css +32 -0
- package/dist/esm/components/Attachment/index.d.ts +1 -0
- package/dist/esm/components/Attachment/index.js +1 -0
- package/dist/esm/components/Attachment/styles.module.css +23 -0
- package/dist/esm/components/AttachmentSquare/AttachmentSquare.d.ts +2 -0
- package/dist/esm/components/AttachmentSquare/AttachmentSquare.js +47 -0
- package/dist/esm/components/AttachmentSquare/components/HoverContent/HoverContent.d.ts +7 -0
- package/dist/esm/components/AttachmentSquare/components/HoverContent/HoverContent.js +13 -0
- package/dist/esm/components/AttachmentSquare/components/HoverContent/index.d.ts +1 -0
- package/dist/esm/components/AttachmentSquare/components/HoverContent/index.js +1 -0
- package/dist/esm/components/AttachmentSquare/components/HoverContent/styles.module.css +20 -0
- package/dist/esm/components/AttachmentSquare/components/LoadingContent/LoadingContent.d.ts +1 -0
- package/dist/esm/components/AttachmentSquare/components/LoadingContent/LoadingContent.js +8 -0
- package/dist/esm/components/AttachmentSquare/components/LoadingContent/index.d.ts +1 -0
- package/dist/esm/components/AttachmentSquare/components/LoadingContent/index.js +1 -0
- package/dist/esm/components/AttachmentSquare/components/LoadingContent/styles.module.css +9 -0
- package/dist/esm/components/AttachmentSquare/components/MainContent/MainContent.d.ts +7 -0
- package/dist/esm/components/AttachmentSquare/components/MainContent/MainContent.js +16 -0
- package/dist/esm/components/AttachmentSquare/components/MainContent/index.d.ts +1 -0
- package/dist/esm/components/AttachmentSquare/components/MainContent/index.js +1 -0
- package/dist/esm/components/AttachmentSquare/components/MainContent/styles.module.css +38 -0
- package/dist/esm/components/AttachmentSquare/index.d.ts +1 -0
- package/dist/esm/components/AttachmentSquare/index.js +1 -0
- package/dist/esm/components/AttachmentSquare/styles.module.css +68 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/constants.d.ts +18 -0
- package/dist/esm/constants.js +19 -0
- package/dist/esm/context.d.ts +10 -0
- package/dist/esm/context.js +12 -0
- package/dist/esm/helperComponents/Actions/Actions.d.ts +7 -0
- package/dist/esm/helperComponents/Actions/Actions.js +32 -0
- package/dist/esm/helperComponents/Actions/index.d.ts +1 -0
- package/dist/esm/helperComponents/Actions/index.js +1 -0
- package/dist/esm/helperComponents/Actions/styles.module.css +4 -0
- package/dist/esm/helperComponents/Text/Text.d.ts +9 -0
- package/dist/esm/helperComponents/Text/Text.js +12 -0
- package/dist/esm/helperComponents/Text/index.d.ts +1 -0
- package/dist/esm/helperComponents/Text/index.js +1 -0
- package/dist/esm/helperComponents/TextBlock/TextBlock.d.ts +5 -0
- package/dist/esm/helperComponents/TextBlock/TextBlock.js +11 -0
- package/dist/esm/helperComponents/TextBlock/index.d.ts +1 -0
- package/dist/esm/helperComponents/TextBlock/index.js +1 -0
- package/dist/esm/helperComponents/TextBlock/styles.module.css +56 -0
- package/dist/esm/helperComponents/index.d.ts +3 -0
- package/dist/esm/helperComponents/index.js +3 -0
- package/dist/esm/hooks.d.ts +4 -0
- package/dist/esm/hooks.js +34 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/style.css +250 -0
- package/dist/esm/types.d.ts +70 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils.d.ts +6 -0
- package/dist/esm/utils.js +22 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +50 -0
- package/src/components/Attachment/Attachment.tsx +79 -0
- package/src/components/Attachment/components/Emblem/Emblem.tsx +56 -0
- package/src/components/Attachment/components/Emblem/index.ts +1 -0
- package/src/components/Attachment/components/Emblem/styles.module.scss +34 -0
- package/src/components/Attachment/index.ts +1 -0
- package/src/components/Attachment/styles.module.scss +28 -0
- package/src/components/AttachmentSquare/AttachmentSquare.tsx +127 -0
- package/src/components/AttachmentSquare/components/HoverContent/HoverContent.tsx +34 -0
- package/src/components/AttachmentSquare/components/HoverContent/index.ts +1 -0
- package/src/components/AttachmentSquare/components/HoverContent/styles.module.scss +34 -0
- package/src/components/AttachmentSquare/components/LoadingContent/LoadingContent.tsx +14 -0
- package/src/components/AttachmentSquare/components/LoadingContent/index.ts +1 -0
- package/src/components/AttachmentSquare/components/LoadingContent/styles.module.scss +13 -0
- package/src/components/AttachmentSquare/components/MainContent/MainContent.tsx +43 -0
- package/src/components/AttachmentSquare/components/MainContent/index.ts +1 -0
- package/src/components/AttachmentSquare/components/MainContent/styles.module.scss +44 -0
- package/src/components/AttachmentSquare/index.ts +1 -0
- package/src/components/AttachmentSquare/styles.module.scss +95 -0
- package/src/components/index.ts +2 -0
- package/src/constants.ts +21 -0
- package/src/context.tsx +28 -0
- package/src/helperComponents/Actions/Actions.tsx +90 -0
- package/src/helperComponents/Actions/index.ts +1 -0
- package/src/helperComponents/Actions/styles.module.scss +4 -0
- package/src/helperComponents/Text/Text.tsx +29 -0
- package/src/helperComponents/Text/index.ts +1 -0
- package/src/helperComponents/TextBlock/TextBlock.tsx +38 -0
- package/src/helperComponents/TextBlock/index.ts +1 -0
- package/src/helperComponents/TextBlock/styles.module.scss +53 -0
- package/src/helperComponents/index.ts +3 -0
- package/src/hooks.ts +40 -0
- package/src/index.ts +3 -0
- package/src/types.ts +74 -0
- package/src/utils.ts +30 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { isFileImage } from './utils.js';
|
|
3
|
+
export function useImage(file) {
|
|
4
|
+
const [imageData, setImageData] = useState(undefined);
|
|
5
|
+
const [loading, setIsLoading] = useState(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!file || !isFileImage(file)) {
|
|
8
|
+
setImageData(undefined);
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const reader = new FileReader();
|
|
12
|
+
let aborted = false;
|
|
13
|
+
reader.onloadstart = () => {
|
|
14
|
+
if (!aborted)
|
|
15
|
+
setIsLoading(true);
|
|
16
|
+
};
|
|
17
|
+
reader.onloadend = () => {
|
|
18
|
+
if (aborted)
|
|
19
|
+
return;
|
|
20
|
+
setIsLoading(false);
|
|
21
|
+
const { result } = reader;
|
|
22
|
+
if (result)
|
|
23
|
+
setImageData(result.toString());
|
|
24
|
+
};
|
|
25
|
+
reader.readAsDataURL(file);
|
|
26
|
+
return () => {
|
|
27
|
+
aborted = true;
|
|
28
|
+
if (reader.readyState === FileReader.LOADING) {
|
|
29
|
+
reader.abort();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}, [file]);
|
|
33
|
+
return { imageData, loading };
|
|
34
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
.loader{
|
|
2
|
+
display:inline-flex;
|
|
3
|
+
flex-shrink:0;
|
|
4
|
+
align-items:center;
|
|
5
|
+
justify-content:center;
|
|
6
|
+
color:var(--sn-theme-color-neutral-text, var(--sn-brand-color-neutral-45, var(--sn-primitive-color-gray-45, #81869c)));
|
|
7
|
+
}
|
|
8
|
+
.loader[data-size=s]{
|
|
9
|
+
width:var(--sn-attachment-anatomy-size-s-container-content-image-width, var(--sn-density-size-m, var(--sn-primitive-dimension-56, 56px)));
|
|
10
|
+
height:var(--sn-attachment-anatomy-size-s-container-content-image-height, var(--sn-density-size-m, var(--sn-primitive-dimension-56, 56px)));
|
|
11
|
+
}
|
|
12
|
+
.loader[data-size=m]{
|
|
13
|
+
width:var(--sn-attachment-anatomy-size-m-container-content-image-width, var(--sn-density-size-l, var(--sn-primitive-dimension-64, 64px)));
|
|
14
|
+
height:var(--sn-attachment-anatomy-size-m-container-content-image-height, var(--sn-density-size-l, var(--sn-primitive-dimension-64, 64px)));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.image{
|
|
18
|
+
display:block;
|
|
19
|
+
flex-shrink:0;
|
|
20
|
+
-o-object-fit:cover;
|
|
21
|
+
object-fit:cover;
|
|
22
|
+
}
|
|
23
|
+
.image[data-size=s]{
|
|
24
|
+
width:var(--sn-attachment-anatomy-size-s-container-content-image-width, var(--sn-density-size-m, var(--sn-primitive-dimension-56, 56px)));
|
|
25
|
+
height:var(--sn-attachment-anatomy-size-s-container-content-image-height, var(--sn-density-size-m, var(--sn-primitive-dimension-56, 56px)));
|
|
26
|
+
border-radius:var(--sn-attachment-anatomy-size-s-container-content-image-borderRadius, var(--sn-density-radius-xs, var(--sn-primitive-dimension-10, 10px)));
|
|
27
|
+
}
|
|
28
|
+
.image[data-size=m]{
|
|
29
|
+
width:var(--sn-attachment-anatomy-size-m-container-content-image-width, var(--sn-density-size-l, var(--sn-primitive-dimension-64, 64px)));
|
|
30
|
+
height:var(--sn-attachment-anatomy-size-m-container-content-image-height, var(--sn-density-size-l, var(--sn-primitive-dimension-64, 64px)));
|
|
31
|
+
border-radius:var(--sn-attachment-anatomy-size-m-container-content-image-borderRadius, var(--sn-density-radius-s, var(--sn-primitive-dimension-16, 16px)));
|
|
32
|
+
}
|
|
33
|
+
.root{
|
|
34
|
+
isolation:isolate;
|
|
35
|
+
display:inline-block;
|
|
36
|
+
width:-moz-fit-content;
|
|
37
|
+
width:fit-content;
|
|
38
|
+
max-width:100%;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.composition{
|
|
42
|
+
display:flex;
|
|
43
|
+
align-items:flex-start;
|
|
44
|
+
box-sizing:border-box;
|
|
45
|
+
width:100%;
|
|
46
|
+
min-width:0;
|
|
47
|
+
}
|
|
48
|
+
.composition[data-size=s]{
|
|
49
|
+
gap:var(--sn-attachment-anatomy-size-s-container-gap, var(--sn-primitive-dimension-8, 8px));
|
|
50
|
+
padding:var(--sn-attachment-anatomy-size-s-container-content-padding, var(--sn-primitive-dimension-8, 8px));
|
|
51
|
+
}
|
|
52
|
+
.composition[data-size=m]{
|
|
53
|
+
gap:var(--sn-attachment-anatomy-size-m-container-gap, var(--sn-primitive-dimension-8, 8px));
|
|
54
|
+
padding:var(--sn-attachment-anatomy-size-m-container-content-padding, var(--sn-primitive-dimension-16, 16px));
|
|
55
|
+
}
|
|
56
|
+
.overlay{
|
|
57
|
+
display:flex;
|
|
58
|
+
flex-direction:column;
|
|
59
|
+
gap:0;
|
|
60
|
+
align-items:center;
|
|
61
|
+
justify-content:center;
|
|
62
|
+
width:100%;
|
|
63
|
+
height:100%;
|
|
64
|
+
color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
|
|
65
|
+
background-color:transparent;
|
|
66
|
+
}
|
|
67
|
+
.overlay[data-mode=icon]:not([data-error]){
|
|
68
|
+
justify-content:flex-end;
|
|
69
|
+
}
|
|
70
|
+
.overlay[data-size=s]{
|
|
71
|
+
padding:var(--sn-attachment-anatomy-size-s-container-content-padding, var(--sn-primitive-dimension-8, 8px));
|
|
72
|
+
}
|
|
73
|
+
.overlay[data-size=m]{
|
|
74
|
+
padding:var(--sn-attachment-anatomy-size-m-container-content-padding, var(--sn-primitive-dimension-16, 16px));
|
|
75
|
+
}
|
|
76
|
+
.composition{
|
|
77
|
+
position:absolute;
|
|
78
|
+
inset:0;
|
|
79
|
+
display:flex;
|
|
80
|
+
flex-direction:column;
|
|
81
|
+
align-items:center;
|
|
82
|
+
justify-content:center;
|
|
83
|
+
color:var(--sn-theme-color-neutral-text, var(--sn-brand-color-neutral-45, var(--sn-primitive-color-gray-45, #81869c)));
|
|
84
|
+
}
|
|
85
|
+
.composition{
|
|
86
|
+
display:flex;
|
|
87
|
+
align-items:center;
|
|
88
|
+
justify-content:center;
|
|
89
|
+
width:100%;
|
|
90
|
+
height:100%;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.iconMode{
|
|
94
|
+
flex-direction:column;
|
|
95
|
+
gap:0;
|
|
96
|
+
align-items:center;
|
|
97
|
+
justify-content:center;
|
|
98
|
+
}
|
|
99
|
+
.iconMode[data-size=s]{
|
|
100
|
+
padding:var(--sn-attachment-anatomy-size-s-container-content-padding, var(--sn-primitive-dimension-8, 8px));
|
|
101
|
+
}
|
|
102
|
+
.iconMode[data-size=m]{
|
|
103
|
+
padding:var(--sn-attachment-anatomy-size-m-container-content-padding, var(--sn-primitive-dimension-16, 16px));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.iconSlot{
|
|
107
|
+
display:flex;
|
|
108
|
+
align-items:center;
|
|
109
|
+
justify-content:center;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.image{
|
|
113
|
+
padding:0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.img{
|
|
117
|
+
display:block;
|
|
118
|
+
width:100%;
|
|
119
|
+
height:100%;
|
|
120
|
+
-o-object-fit:cover;
|
|
121
|
+
object-fit:cover;
|
|
122
|
+
}
|
|
123
|
+
@charset "UTF-8";
|
|
124
|
+
.root{
|
|
125
|
+
isolation:isolate;
|
|
126
|
+
display:inline-flex;
|
|
127
|
+
flex-direction:column;
|
|
128
|
+
}
|
|
129
|
+
.root:has(> div > [data-size=s]){
|
|
130
|
+
width:var(--sn-attachment-anatomy-size-s-container-width, var(--sn-density-size-5xl, var(--sn-primitive-dimension-104, 104px)));
|
|
131
|
+
height:var(--sn-attachment-anatomy-size-s-container-height, var(--sn-density-size-5xl, var(--sn-primitive-dimension-104, 104px)));
|
|
132
|
+
}
|
|
133
|
+
.root:has(> div > [data-size=m]){
|
|
134
|
+
width:var(--sn-attachment-anatomy-size-m-container-width, var(--sn-density-size-8xl, var(--sn-primitive-dimension-128, 128px)));
|
|
135
|
+
height:var(--sn-attachment-anatomy-size-m-container-height, var(--sn-density-size-8xl, var(--sn-primitive-dimension-128, 128px)));
|
|
136
|
+
}
|
|
137
|
+
.root > div{
|
|
138
|
+
flex:1;
|
|
139
|
+
min-height:0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.composition{
|
|
143
|
+
position:relative;
|
|
144
|
+
width:100%;
|
|
145
|
+
height:100%;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.main{
|
|
149
|
+
position:absolute;
|
|
150
|
+
inset:0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.hover{
|
|
154
|
+
pointer-events:none;
|
|
155
|
+
position:absolute;
|
|
156
|
+
inset:0;
|
|
157
|
+
opacity:0;
|
|
158
|
+
}
|
|
159
|
+
.hasFocusedActions .hover,
|
|
160
|
+
.composition:hover .hover[data-mode=image],
|
|
161
|
+
.composition[data-has-actions]:hover .hover,
|
|
162
|
+
.root:focus-visible .hover[data-mode=image],
|
|
163
|
+
.root:focus-visible .composition[data-has-actions] .hover{
|
|
164
|
+
opacity:1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.composition[data-error] .hover{
|
|
168
|
+
opacity:1;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.hover [data-attachment-actions]{
|
|
172
|
+
pointer-events:auto;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.hover[data-mode=image],
|
|
176
|
+
.hover[data-error]{
|
|
177
|
+
pointer-events:auto;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.root:not([data-disabled]) .composition[data-has-actions]:hover [data-attachment-icon-slot],
|
|
181
|
+
.root:not([data-disabled]) .hasFocusedActions [data-attachment-icon-slot],
|
|
182
|
+
.root:not([data-disabled]):focus-visible .composition[data-has-actions] [data-attachment-icon-slot]{
|
|
183
|
+
opacity:0;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.root:not([data-disabled]) .composition:hover [data-attachment-image],
|
|
187
|
+
.root:not([data-disabled]) .hasFocusedActions [data-attachment-image],
|
|
188
|
+
.root:not([data-disabled]):focus-visible .composition [data-attachment-image]{
|
|
189
|
+
display:none;
|
|
190
|
+
}
|
|
191
|
+
.actions{
|
|
192
|
+
display:inline-flex;
|
|
193
|
+
align-items:center;
|
|
194
|
+
}
|
|
195
|
+
.content{
|
|
196
|
+
display:flex;
|
|
197
|
+
flex:1;
|
|
198
|
+
flex-direction:column;
|
|
199
|
+
width:100%;
|
|
200
|
+
min-width:0;
|
|
201
|
+
}
|
|
202
|
+
.content[data-align=center]{
|
|
203
|
+
align-items:center;
|
|
204
|
+
justify-content:center;
|
|
205
|
+
text-align:center;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.title{
|
|
209
|
+
width:100%;
|
|
210
|
+
min-width:0;
|
|
211
|
+
color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
|
|
212
|
+
}
|
|
213
|
+
.title[data-size=s]{
|
|
214
|
+
font-family:var(--sn-regular-label-m-fontFamily, var(--sn-brand-font-fontFamily-regular-label, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
215
|
+
font-weight:var(--sn-regular-label-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-label-m, var(--sn-brand-font-fontWeight-light-regular-label-m, var(--sn-primitive-font-fontWeightValue-550, 550))));
|
|
216
|
+
line-height:var(--sn-regular-label-m-lineHeight, var(--sn-density-typography-roleLabel-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
|
|
217
|
+
font-size:var(--sn-regular-label-m-fontSize, var(--sn-density-typography-roleLabel-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
|
|
218
|
+
letter-spacing:var(--sn-regular-label-m-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
|
|
219
|
+
paragraph-spacing:var(--sn-regular-label-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
|
|
220
|
+
}
|
|
221
|
+
.title[data-size=m]{
|
|
222
|
+
font-family:var(--sn-regular-label-l-fontFamily, var(--sn-brand-font-fontFamily-regular-label, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
223
|
+
font-weight:var(--sn-regular-label-l-fontWeight, var(--sn-theme-typography-fontWeight-regular-label-l, var(--sn-brand-font-fontWeight-light-regular-label-l, var(--sn-primitive-font-fontWeightValue-550, 550))));
|
|
224
|
+
line-height:var(--sn-regular-label-l-lineHeight, var(--sn-density-typography-roleLabel-lineHeightL, var(--sn-primitive-font-lineHeight-by20, 28px)));
|
|
225
|
+
font-size:var(--sn-regular-label-l-fontSize, var(--sn-density-typography-roleLabel-fontSizeL, var(--sn-primitive-font-fontSize-20, 20px)));
|
|
226
|
+
letter-spacing:var(--sn-regular-label-l-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
|
|
227
|
+
paragraph-spacing:var(--sn-regular-label-l-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.description{
|
|
231
|
+
width:100%;
|
|
232
|
+
min-width:0;
|
|
233
|
+
color:var(--sn-theme-color-available-version-textSecondary, var(--sn-brand-color-text-version-secondary, rgba(65, 66, 78, 0.8)));
|
|
234
|
+
}
|
|
235
|
+
.description[data-size=s]{
|
|
236
|
+
font-family:var(--sn-regular-body-s-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
237
|
+
font-weight:var(--sn-regular-body-s-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-s, var(--sn-brand-font-fontWeight-light-regular-body-s, var(--sn-primitive-font-fontWeightValue-400, 400))));
|
|
238
|
+
line-height:var(--sn-regular-body-s-lineHeight, var(--sn-density-typography-roleBody-lineHeightS, var(--sn-primitive-font-lineHeight-by14, 20px)));
|
|
239
|
+
font-size:var(--sn-regular-body-s-fontSize, var(--sn-density-typography-roleBody-fontSizeS, var(--sn-primitive-font-fontSize-14, 14px)));
|
|
240
|
+
letter-spacing:var(--sn-regular-body-s-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
|
|
241
|
+
paragraph-spacing:var(--sn-regular-body-s-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
|
|
242
|
+
}
|
|
243
|
+
.description[data-size=m]{
|
|
244
|
+
font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
245
|
+
font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
|
|
246
|
+
line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
|
|
247
|
+
font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
|
|
248
|
+
letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
|
|
249
|
+
paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
|
|
250
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { IconPredefinedProps } from '@cloud-ru/ds-icon-predefined';
|
|
2
|
+
import { TruncateStringProps } from '@cloud-ru/ds-truncate-string';
|
|
3
|
+
import { ValueOf, WithSupportProps } from '@cloud-ru/ds-utils';
|
|
4
|
+
import { MouseEvent } from 'react';
|
|
5
|
+
import { SIZE } from './constants.js';
|
|
6
|
+
export type Size = ValueOf<typeof SIZE>;
|
|
7
|
+
export type AttachmentSquareProps = WithSupportProps<{
|
|
8
|
+
/** Файл */
|
|
9
|
+
file?: File;
|
|
10
|
+
/** Колбек на клик по кнопке скачивания */
|
|
11
|
+
onDownload?(file?: File | undefined): void;
|
|
12
|
+
/** Колбек на клик по кнопке удаления */
|
|
13
|
+
onDelete?(file?: File | undefined): void;
|
|
14
|
+
/** Колбек на клик по кнопке повторения */
|
|
15
|
+
onRetry?(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Заголовок
|
|
18
|
+
* @default fileName
|
|
19
|
+
*/
|
|
20
|
+
title?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Описание
|
|
23
|
+
* @default fileExtension
|
|
24
|
+
*/
|
|
25
|
+
description?: string;
|
|
26
|
+
/** Сообщение об ошибке */
|
|
27
|
+
error?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Вариант обрезания строки:
|
|
30
|
+
* <br> - `end` — с конца;
|
|
31
|
+
* <br> - `middle` — по середине
|
|
32
|
+
*/
|
|
33
|
+
truncateVariant?: TruncateStringProps['variant'];
|
|
34
|
+
/** Управление состоянием загрузки */
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Иконка для файла
|
|
38
|
+
* @defaultIcon FileSVG
|
|
39
|
+
*/
|
|
40
|
+
icon?: IconPredefinedProps['icon'];
|
|
41
|
+
/** Размер */
|
|
42
|
+
size?: Size;
|
|
43
|
+
/** Состояние «выбран» (множественный выбор) */
|
|
44
|
+
checked?: boolean;
|
|
45
|
+
/** Заблокировано */
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/** Клик по карточке */
|
|
48
|
+
onClick?(event: MouseEvent<HTMLDivElement>): void;
|
|
49
|
+
/** CSS-класс корня */
|
|
50
|
+
className?: string;
|
|
51
|
+
}>;
|
|
52
|
+
export type AttachmentProps = AttachmentSquareProps & {
|
|
53
|
+
truncate?: {
|
|
54
|
+
/**
|
|
55
|
+
* Максимальное кол-во строк заголовка
|
|
56
|
+
* @default 1
|
|
57
|
+
*/
|
|
58
|
+
title?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Максимальное кол-во строк описания
|
|
61
|
+
* @default 1
|
|
62
|
+
*/
|
|
63
|
+
description?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Максимальное кол-во строк ошибки
|
|
66
|
+
* @default 1
|
|
67
|
+
*/
|
|
68
|
+
error?: number;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IconPredefinedProps } from '@cloud-ru/ds-icon-predefined';
|
|
2
|
+
import { Size } from './types.js';
|
|
3
|
+
export declare const EMBLEM_ICON_SIZE: Record<Size, IconPredefinedProps['size']>;
|
|
4
|
+
export declare function getBaseFileName(fileName?: string): string | undefined;
|
|
5
|
+
export declare function getFileExtension(fileName?: string): string | undefined;
|
|
6
|
+
export declare function isFileImage(file: File): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SIZE as IP_SIZE } from '@cloud-ru/ds-icon-predefined';
|
|
2
|
+
export const EMBLEM_ICON_SIZE = {
|
|
3
|
+
s: IP_SIZE.M,
|
|
4
|
+
m: IP_SIZE.L,
|
|
5
|
+
};
|
|
6
|
+
export function getBaseFileName(fileName) {
|
|
7
|
+
if (!fileName) {
|
|
8
|
+
return fileName;
|
|
9
|
+
}
|
|
10
|
+
const parts = fileName.split('.');
|
|
11
|
+
parts.pop();
|
|
12
|
+
// Файлы без имени (.bashrc, .gitignore) — возвращаем исходное имя.
|
|
13
|
+
if (parts.length === 1 && parts[0] === '')
|
|
14
|
+
return fileName;
|
|
15
|
+
return parts.join('.');
|
|
16
|
+
}
|
|
17
|
+
export function getFileExtension(fileName) {
|
|
18
|
+
return fileName?.split('.').pop()?.toLocaleUpperCase();
|
|
19
|
+
}
|
|
20
|
+
export function isFileImage(file) {
|
|
21
|
+
return Boolean(file.type.match(/image\/(png|jpg|jpeg|gif|webp|bmp|svg)/i));
|
|
22
|
+
}
|