@snack-uikit/attachment 0.4.45-preview-02d918ac.0 → 0.4.45
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 +10 -0
- package/dist/cjs/components/Attachment/Attachment.js +20 -22
- package/dist/cjs/components/Attachment/components/Emblem/Emblem.js +6 -9
- package/dist/cjs/components/AttachmentSquare/AttachmentSquare.js +25 -22
- package/dist/cjs/components/AttachmentSquare/components/HoverContent/HoverContent.js +8 -10
- package/dist/cjs/components/AttachmentSquare/components/LoadingContent/LoadingContent.js +2 -3
- package/dist/cjs/components/AttachmentSquare/components/MainContent/MainContent.js +7 -10
- package/dist/cjs/helperComponents/Actions/Actions.js +12 -15
- package/dist/cjs/helperComponents/Text/Text.js +6 -8
- package/dist/cjs/helperComponents/TextBlock/TextBlock.js +10 -11
- package/dist/cjs/hooks.js +11 -5
- package/dist/cjs/testIds.js +9 -9
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## 0.4.45 (2026-07-03)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/card@0.20.23]($PUBLIC_PROJECT_URL/blob/master/packages/card/CHANGELOG.md)
|
|
10
|
+
* [@snack-uikit/truncate-string@0.7.14]($PUBLIC_PROJECT_URL/blob/master/packages/truncate-string/CHANGELOG.md)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## 0.4.44 (2026-06-24)
|
|
7
17
|
|
|
8
18
|
### Only dependencies have been changed
|
|
@@ -27,29 +27,27 @@ const hooks_1 = require("../../hooks");
|
|
|
27
27
|
const components_1 = require("./components");
|
|
28
28
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
29
29
|
function Attachment(_a) {
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} = _a,
|
|
30
|
+
var file = _a.file,
|
|
31
|
+
loading = _a.loading,
|
|
32
|
+
icon = _a.icon,
|
|
33
|
+
titleProp = _a.title,
|
|
34
|
+
descriptionProp = _a.description,
|
|
35
|
+
error = _a.error,
|
|
36
|
+
disabled = _a.disabled,
|
|
37
|
+
truncateVariant = _a.truncateVariant,
|
|
38
|
+
checked = _a.checked,
|
|
39
|
+
onDownload = _a.onDownload,
|
|
40
|
+
onDelete = _a.onDelete,
|
|
41
|
+
onClick = _a.onClick,
|
|
42
|
+
onRetry = _a.onRetry,
|
|
43
|
+
_a$size = _a.size,
|
|
44
|
+
size = _a$size === void 0 ? 's' : _a$size,
|
|
45
|
+
truncate = _a.truncate,
|
|
46
|
+
className = _a.className,
|
|
48
47
|
rest = __rest(_a, ["file", "loading", "icon", "title", "description", "error", "disabled", "truncateVariant", "checked", "onDownload", "onDelete", "onClick", "onRetry", "size", "truncate", "className"]);
|
|
49
|
-
const
|
|
50
|
-
loading
|
|
51
|
-
imageData
|
|
52
|
-
} = (0, hooks_1.useImage)(file);
|
|
48
|
+
const _ref = (0, hooks_1.useImage)(file),
|
|
49
|
+
loadingImage = _ref.loading,
|
|
50
|
+
imageData = _ref.imageData;
|
|
53
51
|
const isLoading = loading || loadingImage;
|
|
54
52
|
const title = titleProp || (0, helpers_1.getBaseFileName)(file === null || file === void 0 ? void 0 : file.name);
|
|
55
53
|
const description = descriptionProp || (0, helpers_1.getFileExtension)(file === null || file === void 0 ? void 0 : file.name);
|
|
@@ -17,15 +17,12 @@ const contexts_1 = require("../../../../contexts");
|
|
|
17
17
|
const testIds_1 = require("../../../../testIds");
|
|
18
18
|
const styled_module_scss_1 = __importDefault(require('./styled.module.css'));
|
|
19
19
|
function Emblem(_ref) {
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
size
|
|
28
|
-
} = (0, contexts_1.useAttachmentContext)();
|
|
20
|
+
let loading = _ref.loading,
|
|
21
|
+
icon = _ref.icon,
|
|
22
|
+
imageData = _ref.imageData,
|
|
23
|
+
title = _ref.title;
|
|
24
|
+
const _ref2 = (0, contexts_1.useAttachmentContext)(),
|
|
25
|
+
size = _ref2.size;
|
|
29
26
|
if (loading) {
|
|
30
27
|
return (0, jsx_runtime_1.jsx)(icon_predefined_1.IconPredefined, {
|
|
31
28
|
size: size,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -28,32 +30,33 @@ const hooks_1 = require("../../hooks");
|
|
|
28
30
|
const components_1 = require("./components");
|
|
29
31
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
30
32
|
function AttachmentSquare(_a) {
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} = _a,
|
|
33
|
+
var file = _a.file,
|
|
34
|
+
loading = _a.loading,
|
|
35
|
+
icon = _a.icon,
|
|
36
|
+
titleProp = _a.title,
|
|
37
|
+
descriptionProp = _a.description,
|
|
38
|
+
error = _a.error,
|
|
39
|
+
disabled = _a.disabled,
|
|
40
|
+
truncateVariant = _a.truncateVariant,
|
|
41
|
+
checked = _a.checked,
|
|
42
|
+
onDownload = _a.onDownload,
|
|
43
|
+
onDelete = _a.onDelete,
|
|
44
|
+
onClick = _a.onClick,
|
|
45
|
+
onRetry = _a.onRetry,
|
|
46
|
+
_a$size = _a.size,
|
|
47
|
+
size = _a$size === void 0 ? 's' : _a$size,
|
|
48
|
+
className = _a.className,
|
|
48
49
|
rest = __rest(_a, ["file", "loading", "icon", "title", "description", "error", "disabled", "truncateVariant", "checked", "onDownload", "onDelete", "onClick", "onRetry", "size", "className"]);
|
|
49
|
-
const
|
|
50
|
-
loading
|
|
51
|
-
imageData
|
|
52
|
-
} = (0, hooks_1.useImage)(file);
|
|
50
|
+
const _ref = (0, hooks_1.useImage)(file),
|
|
51
|
+
loadingImage = _ref.loading,
|
|
52
|
+
imageData = _ref.imageData;
|
|
53
53
|
const isLoading = loading || loadingImage;
|
|
54
54
|
const title = titleProp || (0, helpers_1.getBaseFileName)(file === null || file === void 0 ? void 0 : file.name);
|
|
55
55
|
const description = descriptionProp || (0, helpers_1.getFileExtension)(file === null || file === void 0 ? void 0 : file.name);
|
|
56
|
-
const
|
|
56
|
+
const _ref2 = (0, react_1.useState)(false),
|
|
57
|
+
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
58
|
+
hasFocusedActions = _ref3[0],
|
|
59
|
+
setHasFocusedActions = _ref3[1];
|
|
57
60
|
return (0, jsx_runtime_1.jsx)(card_1.Card, Object.assign({}, (0, utils_1.extractSupportProps)(rest), {
|
|
58
61
|
outline: true,
|
|
59
62
|
disabled: !loading && disabled,
|
|
@@ -15,16 +15,14 @@ const contexts_1 = require("../../../../contexts");
|
|
|
15
15
|
const helperComponents_1 = require("../../../../helperComponents");
|
|
16
16
|
const styles_module_scss_1 = __importDefault(require('../styles.module.css'));
|
|
17
17
|
function HoverContent(_ref) {
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
className = ''
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
size
|
|
27
|
-
} = (0, contexts_1.useAttachmentContext)();
|
|
18
|
+
let title = _ref.title,
|
|
19
|
+
description = _ref.description,
|
|
20
|
+
error = _ref.error,
|
|
21
|
+
_ref$className = _ref.className,
|
|
22
|
+
className = _ref$className === void 0 ? '' : _ref$className;
|
|
23
|
+
const _ref2 = (0, contexts_1.useAttachmentContext)(),
|
|
24
|
+
disabled = _ref2.disabled,
|
|
25
|
+
size = _ref2.size;
|
|
28
26
|
return (0, jsx_runtime_1.jsxs)("div", {
|
|
29
27
|
className: (0, classnames_1.default)(styles_module_scss_1.default.composition, {
|
|
30
28
|
[className]: !disabled && !error
|
|
@@ -17,9 +17,8 @@ const helperComponents_1 = require("../../../../helperComponents");
|
|
|
17
17
|
const testIds_1 = require("../../../../testIds");
|
|
18
18
|
const styles_module_scss_1 = __importDefault(require('../styles.module.css'));
|
|
19
19
|
function LoadingContent() {
|
|
20
|
-
const
|
|
21
|
-
size
|
|
22
|
-
} = (0, contexts_1.useAttachmentContext)();
|
|
20
|
+
const _ref = (0, contexts_1.useAttachmentContext)(),
|
|
21
|
+
size = _ref.size;
|
|
23
22
|
return (0, jsx_runtime_1.jsxs)("div", {
|
|
24
23
|
className: styles_module_scss_1.default.composition,
|
|
25
24
|
"data-size": size,
|
|
@@ -19,17 +19,14 @@ const helperComponents_1 = require("../../../../helperComponents");
|
|
|
19
19
|
const testIds_1 = require("../../../../testIds");
|
|
20
20
|
const styles_module_scss_1 = __importDefault(require('../styles.module.css'));
|
|
21
21
|
function MainContent(_ref) {
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
className
|
|
27
|
-
} = _ref;
|
|
22
|
+
let title = _ref.title,
|
|
23
|
+
icon = _ref.icon,
|
|
24
|
+
imageData = _ref.imageData,
|
|
25
|
+
className = _ref.className;
|
|
28
26
|
var _a;
|
|
29
|
-
const
|
|
30
|
-
file,
|
|
31
|
-
size
|
|
32
|
-
} = (0, contexts_1.useAttachmentContext)();
|
|
27
|
+
const _ref2 = (0, contexts_1.useAttachmentContext)(),
|
|
28
|
+
file = _ref2.file,
|
|
29
|
+
size = _ref2.size;
|
|
33
30
|
if (imageData) {
|
|
34
31
|
return (0, jsx_runtime_1.jsx)("div", {
|
|
35
32
|
className: (0, classnames_1.default)(styles_module_scss_1.default.composition, className),
|
|
@@ -17,21 +17,18 @@ const testIds_1 = require("../../testIds");
|
|
|
17
17
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
18
18
|
const noop = () => {};
|
|
19
19
|
function Actions(_ref) {
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
setFocused = noop
|
|
34
|
-
} = (0, contexts_1.useAttachmentFocusActionsContext)();
|
|
20
|
+
let hideDelete = _ref.hideDelete,
|
|
21
|
+
hideDownload = _ref.hideDownload,
|
|
22
|
+
hideRetry = _ref.hideRetry;
|
|
23
|
+
const _ref2 = (0, contexts_1.useAttachmentContext)(),
|
|
24
|
+
onDelete = _ref2.onDelete,
|
|
25
|
+
onDownload = _ref2.onDownload,
|
|
26
|
+
file = _ref2.file,
|
|
27
|
+
disabled = _ref2.disabled,
|
|
28
|
+
onRetry = _ref2.onRetry;
|
|
29
|
+
const _ref3 = (0, contexts_1.useAttachmentFocusActionsContext)(),
|
|
30
|
+
_ref3$setFocused = _ref3.setFocused,
|
|
31
|
+
setFocused = _ref3$setFocused === void 0 ? noop : _ref3$setFocused;
|
|
35
32
|
const showDownload = onDownload && !hideDownload;
|
|
36
33
|
const showDelete = onDelete && !hideDelete;
|
|
37
34
|
const showRetry = onRetry && !hideRetry;
|
|
@@ -17,15 +17,13 @@ const truncate_string_1 = require("@snack-uikit/truncate-string");
|
|
|
17
17
|
const utils_1 = require("@snack-uikit/utils");
|
|
18
18
|
const contexts_1 = require("../../contexts");
|
|
19
19
|
function Text(_a) {
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = _a,
|
|
20
|
+
var text = _a.text,
|
|
21
|
+
className = _a.className,
|
|
22
|
+
_a$maxLines = _a.maxLines,
|
|
23
|
+
maxLines = _a$maxLines === void 0 ? 1 : _a$maxLines,
|
|
25
24
|
rest = __rest(_a, ["text", "className", "maxLines"]);
|
|
26
|
-
const
|
|
27
|
-
truncateVariant
|
|
28
|
-
} = (0, contexts_1.useAttachmentContext)();
|
|
25
|
+
const _ref = (0, contexts_1.useAttachmentContext)(),
|
|
26
|
+
truncateVariant = _ref.truncateVariant;
|
|
29
27
|
if (!text) {
|
|
30
28
|
return null;
|
|
31
29
|
}
|
|
@@ -16,17 +16,16 @@ const testIds_1 = require("../../testIds");
|
|
|
16
16
|
const Text_1 = require("../Text");
|
|
17
17
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
18
18
|
function TextBlock(_ref) {
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
align = 'left'
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
truncate = {}
|
|
29
|
-
} = (0, contexts_1.useAttachmentContext)();
|
|
19
|
+
let title = _ref.title,
|
|
20
|
+
description = _ref.description,
|
|
21
|
+
error = _ref.error,
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
_ref$align = _ref.align,
|
|
24
|
+
align = _ref$align === void 0 ? 'left' : _ref$align;
|
|
25
|
+
const _ref2 = (0, contexts_1.useAttachmentContext)(),
|
|
26
|
+
size = _ref2.size,
|
|
27
|
+
_ref2$truncate = _ref2.truncate,
|
|
28
|
+
truncate = _ref2$truncate === void 0 ? {} : _ref2$truncate;
|
|
30
29
|
return (0, jsx_runtime_1.jsxs)("div", {
|
|
31
30
|
className: (0, classnames_1.default)(styles_module_scss_1.default.content, className),
|
|
32
31
|
"data-size": size,
|
package/dist/cjs/hooks.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -7,8 +9,14 @@ exports.useImage = useImage;
|
|
|
7
9
|
const react_1 = require("react");
|
|
8
10
|
const helpers_1 = require("./helpers");
|
|
9
11
|
function useImage(file) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
+
const _ref = (0, react_1.useState)(undefined),
|
|
13
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
14
|
+
imageData = _ref2[0],
|
|
15
|
+
setImageData = _ref2[1];
|
|
16
|
+
const _ref3 = (0, react_1.useState)(false),
|
|
17
|
+
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
18
|
+
loading = _ref4[0],
|
|
19
|
+
setIsLoading = _ref4[1];
|
|
12
20
|
(0, react_1.useEffect)(() => {
|
|
13
21
|
if (file && (0, helpers_1.isFileImage)(file)) {
|
|
14
22
|
const reader = new FileReader();
|
|
@@ -17,9 +25,7 @@ function useImage(file) {
|
|
|
17
25
|
};
|
|
18
26
|
reader.onloadend = () => {
|
|
19
27
|
setIsLoading(false);
|
|
20
|
-
const
|
|
21
|
-
result
|
|
22
|
-
} = reader;
|
|
28
|
+
const result = reader.result;
|
|
23
29
|
if (result) {
|
|
24
30
|
setImageData(result.toString());
|
|
25
31
|
}
|
package/dist/cjs/testIds.js
CHANGED
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.TEST_IDS = void 0;
|
|
7
7
|
const PREFIX = 'attachment';
|
|
8
8
|
exports.TEST_IDS = {
|
|
9
|
-
icon:
|
|
10
|
-
image:
|
|
11
|
-
loading:
|
|
12
|
-
retryAction:
|
|
13
|
-
deleteAction:
|
|
14
|
-
downloadAction:
|
|
15
|
-
title:
|
|
16
|
-
description:
|
|
17
|
-
error:
|
|
9
|
+
icon: "".concat(PREFIX, "__icon"),
|
|
10
|
+
image: "".concat(PREFIX, "__image"),
|
|
11
|
+
loading: "".concat(PREFIX, "__loading"),
|
|
12
|
+
retryAction: "".concat(PREFIX, "__retry-action"),
|
|
13
|
+
deleteAction: "".concat(PREFIX, "__delete-action"),
|
|
14
|
+
downloadAction: "".concat(PREFIX, "__download-action"),
|
|
15
|
+
title: "".concat(PREFIX, "__title"),
|
|
16
|
+
description: "".concat(PREFIX, "__description"),
|
|
17
|
+
error: "".concat(PREFIX, "__error")
|
|
18
18
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Attachment",
|
|
7
|
-
"version": "0.4.45
|
|
7
|
+
"version": "0.4.45",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@snack-uikit/button": "0.19.19",
|
|
40
|
-
"@snack-uikit/card": "0.20.23
|
|
40
|
+
"@snack-uikit/card": "0.20.23",
|
|
41
41
|
"@snack-uikit/icon-predefined": "0.7.12",
|
|
42
42
|
"@snack-uikit/icons": "0.27.7",
|
|
43
43
|
"@snack-uikit/loaders": "0.9.11",
|
|
44
|
-
"@snack-uikit/truncate-string": "0.7.14
|
|
44
|
+
"@snack-uikit/truncate-string": "0.7.14",
|
|
45
45
|
"@snack-uikit/utils": "4.0.2",
|
|
46
46
|
"classnames": "2.5.1"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "864821fceaa6bbb61080166d14f1682fa16e3f85"
|
|
49
49
|
}
|