@frontify/guideline-blocks-settings 1.0.13-alpha.6 → 1.0.13-alpha.8
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/dist/components/Attachments/AttachmentItem.es.js +53 -52
- package/dist/components/Attachments/AttachmentItem.es.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.es.js +9 -6
- package/dist/components/DownloadButton/DownloadButton.es.js.map +1 -1
- package/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
2
|
-
import { useSortable as
|
|
3
|
-
import { useFileInput as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { IconGrabHandle as G, IconPen as T, IconArrowCircleUp as U, IconImageStack as $, IconTrashBin as L, IconImage as B, IconPlayFrame as H, IconMusicNote as M, IconDocument as O } from "@frontify/fondue/icons";
|
|
2
|
+
import { useSortable as R } from "@dnd-kit/sortable";
|
|
3
|
+
import { useFileInput as C, useAssetUpload as A } from "@frontify/app-bridge";
|
|
4
|
+
import { LoadingCircle as j, Dropdown as i, Button as D } from "@frontify/fondue/components";
|
|
5
|
+
import { IconGrabHandle as G, IconPen as $, IconArrowCircleUp as E, IconImageStack as T, IconTrashBin as U, IconImage as B, IconPlayFrame as H, IconMusicNote as L, IconDocument as M } from "@frontify/fondue/icons";
|
|
7
6
|
import { useFocusRing as V } from "@react-aria/focus";
|
|
8
|
-
import { forwardRef as q, useState as
|
|
7
|
+
import { forwardRef as q, useState as O, useEffect as v } from "react";
|
|
9
8
|
import { joinClassNames as g } from "../../utilities/react/joinClassNames.es.js";
|
|
10
|
-
const
|
|
9
|
+
const J = (o) => o === "IMAGE" ? /* @__PURE__ */ e(B, { size: "24" }) : o === "VIDEO" ? /* @__PURE__ */ e(H, { size: "24" }) : o === "AUDIO" ? /* @__PURE__ */ e(L, { size: "24" }) : /* @__PURE__ */ e(M, { size: "24" }), k = q(
|
|
11
10
|
({
|
|
12
11
|
item: o,
|
|
13
12
|
isEditing: u,
|
|
14
13
|
draggableProps: w,
|
|
15
14
|
transformStyle: p,
|
|
16
|
-
isDragging:
|
|
17
|
-
isOverlay:
|
|
15
|
+
isDragging: a,
|
|
16
|
+
isOverlay: s,
|
|
18
17
|
isLoading: c,
|
|
19
18
|
onDelete: m,
|
|
20
|
-
onReplaceWithBrowse:
|
|
21
|
-
onReplaceWithUpload:
|
|
22
|
-
onDownload:
|
|
19
|
+
onReplaceWithBrowse: b,
|
|
20
|
+
onReplaceWithUpload: z,
|
|
21
|
+
onDownload: h
|
|
23
22
|
}, x) => {
|
|
24
|
-
const [
|
|
25
|
-
|
|
26
|
-
d &&
|
|
27
|
-
}, [d]),
|
|
28
|
-
f &&
|
|
23
|
+
const [n, l] = O(), [N, { selectedFiles: d }] = C({ multiple: !0, accept: "image/*" }), [S, { results: I, doneAll: f }] = A(), { focusProps: P, isFocusVisible: y } = V();
|
|
24
|
+
v(() => {
|
|
25
|
+
d && S(d[0]);
|
|
26
|
+
}, [d]), v(() => {
|
|
27
|
+
f && z(I[0]);
|
|
29
28
|
}, [f, I]);
|
|
30
|
-
const
|
|
29
|
+
const F = c || d && !f;
|
|
31
30
|
return /* @__PURE__ */ r(
|
|
32
31
|
"button",
|
|
33
32
|
{
|
|
33
|
+
type: "button",
|
|
34
34
|
"aria-label": "Download attachment",
|
|
35
35
|
"data-test-id": "attachments-item",
|
|
36
|
-
onClick: () => !
|
|
36
|
+
onClick: () => !n && (h == null ? void 0 : h()),
|
|
37
37
|
ref: x,
|
|
38
38
|
style: {
|
|
39
39
|
...p,
|
|
40
|
-
opacity:
|
|
40
|
+
opacity: a && !s ? 0.3 : 1,
|
|
41
41
|
fontFamily: "var(-f-theme-settings-body-font-family)"
|
|
42
42
|
},
|
|
43
43
|
className: g([
|
|
44
44
|
"tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-box-neutral-hover",
|
|
45
|
-
|
|
45
|
+
a ? "tw-bg-box-neutral-hover" : ""
|
|
46
46
|
]),
|
|
47
47
|
children: [
|
|
48
|
-
/* @__PURE__ */ e("div", { className: "tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover", children:
|
|
48
|
+
/* @__PURE__ */ e("div", { className: "tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover", children: F ? /* @__PURE__ */ e(j, { size: "small" }) : J(o.objectType) }),
|
|
49
49
|
/* @__PURE__ */ r("div", { className: "tw-text-s tw-flex-1 tw-min-w-0", children: [
|
|
50
50
|
/* @__PURE__ */ e("div", { className: "tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover", children: o.title }),
|
|
51
51
|
/* @__PURE__ */ e("div", { className: "tw-text-text-weak", children: `${o.fileSizeHumanReadable} - ${o.extension}` })
|
|
@@ -56,32 +56,33 @@ const _ = (o) => o === "IMAGE" ? /* @__PURE__ */ e(B, { size: "24" }) : o === "V
|
|
|
56
56
|
"data-test-id": "attachments-actionbar",
|
|
57
57
|
className: g([
|
|
58
58
|
"tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",
|
|
59
|
-
|
|
59
|
+
s || (n == null ? void 0 : n.id) === o.id ? "tw-opacity-100" : "tw-opacity-0"
|
|
60
60
|
]),
|
|
61
61
|
children: [
|
|
62
62
|
/* @__PURE__ */ e(
|
|
63
63
|
"button",
|
|
64
64
|
{
|
|
65
|
-
|
|
65
|
+
type: "button",
|
|
66
|
+
...P,
|
|
66
67
|
...w,
|
|
67
68
|
"aria-label": "Drag attachment",
|
|
68
69
|
className: g([
|
|
69
70
|
" tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded tw-h-9 tw-w-9 ",
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
a || s ? "tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed" : "tw-cursor-grab hover:tw-bg-button-background-hover",
|
|
72
|
+
y && "tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none",
|
|
73
|
+
y && "tw-z-[2]"
|
|
73
74
|
]),
|
|
74
75
|
children: /* @__PURE__ */ e(G, {})
|
|
75
76
|
}
|
|
76
77
|
),
|
|
77
78
|
/* @__PURE__ */ e("div", { "data-test-id": "attachments-actionbar-flyout", children: /* @__PURE__ */ r(
|
|
78
|
-
|
|
79
|
+
i.Root,
|
|
79
80
|
{
|
|
80
|
-
open: (
|
|
81
|
+
open: (n == null ? void 0 : n.id) === o.id,
|
|
81
82
|
onOpenChange: (t) => l(t ? o : void 0),
|
|
82
83
|
children: [
|
|
83
|
-
/* @__PURE__ */ e(
|
|
84
|
-
|
|
84
|
+
/* @__PURE__ */ e(i.Trigger, { children: /* @__PURE__ */ e(
|
|
85
|
+
D,
|
|
85
86
|
{
|
|
86
87
|
aspect: "square",
|
|
87
88
|
ref: x,
|
|
@@ -89,46 +90,46 @@ const _ = (o) => o === "IMAGE" ? /* @__PURE__ */ e(B, { size: "24" }) : o === "V
|
|
|
89
90
|
t == null || t.stopPropagation(), t == null || t.preventDefault();
|
|
90
91
|
},
|
|
91
92
|
emphasis: "default",
|
|
92
|
-
children: /* @__PURE__ */ e(
|
|
93
|
+
children: /* @__PURE__ */ e($, { size: "20" })
|
|
93
94
|
}
|
|
94
95
|
) }),
|
|
95
|
-
/* @__PURE__ */ r(
|
|
96
|
-
/* @__PURE__ */ r(
|
|
96
|
+
/* @__PURE__ */ r(i.Content, { side: "right", children: [
|
|
97
|
+
/* @__PURE__ */ r(i.Group, { children: [
|
|
97
98
|
/* @__PURE__ */ r(
|
|
98
|
-
|
|
99
|
+
i.Item,
|
|
99
100
|
{
|
|
100
101
|
"data-test-id": "menu-item",
|
|
101
102
|
onSelect: (t) => {
|
|
102
103
|
t == null || t.stopPropagation(), N(), l(void 0);
|
|
103
104
|
},
|
|
104
105
|
children: [
|
|
105
|
-
/* @__PURE__ */ e(
|
|
106
|
+
/* @__PURE__ */ e(E, { size: "20" }),
|
|
106
107
|
"Replace with upload"
|
|
107
108
|
]
|
|
108
109
|
}
|
|
109
110
|
),
|
|
110
111
|
/* @__PURE__ */ r(
|
|
111
|
-
|
|
112
|
+
i.Item,
|
|
112
113
|
{
|
|
113
114
|
onSelect: (t) => {
|
|
114
|
-
t == null || t.stopPropagation(),
|
|
115
|
+
t == null || t.stopPropagation(), b(), l(void 0);
|
|
115
116
|
},
|
|
116
117
|
children: [
|
|
117
|
-
/* @__PURE__ */ e(
|
|
118
|
+
/* @__PURE__ */ e(T, { size: "20" }),
|
|
118
119
|
"Replace with asset"
|
|
119
120
|
]
|
|
120
121
|
}
|
|
121
122
|
)
|
|
122
123
|
] }),
|
|
123
|
-
/* @__PURE__ */ e(
|
|
124
|
-
|
|
124
|
+
/* @__PURE__ */ e(i.Group, { children: /* @__PURE__ */ r(
|
|
125
|
+
i.Item,
|
|
125
126
|
{
|
|
126
127
|
emphasis: "danger",
|
|
127
128
|
onSelect: (t) => {
|
|
128
129
|
t == null || t.stopPropagation(), m(), l(void 0);
|
|
129
130
|
},
|
|
130
131
|
children: [
|
|
131
|
-
/* @__PURE__ */ e(
|
|
132
|
+
/* @__PURE__ */ e(U, { size: "20" }),
|
|
132
133
|
"Delete"
|
|
133
134
|
]
|
|
134
135
|
}
|
|
@@ -145,28 +146,28 @@ const _ = (o) => o === "IMAGE" ? /* @__PURE__ */ e(B, { size: "24" }) : o === "V
|
|
|
145
146
|
);
|
|
146
147
|
}
|
|
147
148
|
);
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
const { attributes: u, listeners: w, setNodeRef: p, transform:
|
|
149
|
+
k.displayName = "AttachmentItem";
|
|
150
|
+
const et = (o) => {
|
|
151
|
+
const { attributes: u, listeners: w, setNodeRef: p, transform: a, transition: s, isDragging: c } = R({
|
|
151
152
|
id: o.item.id
|
|
152
153
|
}), m = {
|
|
153
|
-
transform:
|
|
154
|
-
transition:
|
|
154
|
+
transform: a ? `translate(${a.x}px, ${a.y}px)` : "",
|
|
155
|
+
transition: s,
|
|
155
156
|
zIndex: c ? 2 : 1
|
|
156
|
-
},
|
|
157
|
+
}, b = { ...u, ...w };
|
|
157
158
|
return /* @__PURE__ */ e(
|
|
158
|
-
|
|
159
|
+
k,
|
|
159
160
|
{
|
|
160
161
|
ref: p,
|
|
161
162
|
isDragging: c,
|
|
162
163
|
transformStyle: m,
|
|
163
|
-
draggableProps:
|
|
164
|
+
draggableProps: b,
|
|
164
165
|
...o
|
|
165
166
|
}
|
|
166
167
|
);
|
|
167
168
|
};
|
|
168
169
|
export {
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
k as AttachmentItem,
|
|
171
|
+
et as SortableAttachmentItem
|
|
171
172
|
};
|
|
172
173
|
//# sourceMappingURL=AttachmentItem.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentItem.es.js","sources":["../../../src/components/Attachments/AttachmentItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useSortable } from '@dnd-kit/sortable';\nimport { type Asset, useAssetUpload, useFileInput } from '@frontify/app-bridge';\nimport { FOCUS_STYLE } from '@frontify/fondue';\nimport { LoadingCircle, Dropdown, Button } from '@frontify/fondue/components';\nimport {\n IconArrowCircleUp,\n IconImageStack,\n IconPen,\n IconTrashBin,\n IconDocument,\n IconImage,\n IconPlayFrame,\n IconMusicNote,\n IconGrabHandle,\n} from '@frontify/fondue/icons';\nimport { useFocusRing } from '@react-aria/focus';\nimport { type MutableRefObject, forwardRef, useEffect, useState } from 'react';\n\nimport { joinClassNames } from '../../utilities';\n\nimport { type AttachmentItemProps, type SortableAttachmentItemProps } from './types';\n\nconst getDecorator = (type: string) => {\n if (type === 'IMAGE') {\n return <IconImage size=\"24\" />;\n } else if (type === 'VIDEO') {\n return <IconPlayFrame size=\"24\" />;\n } else if (type === 'AUDIO') {\n return <IconMusicNote size=\"24\" />;\n } else {\n return <IconDocument size=\"24\" />;\n }\n};\n\nexport const AttachmentItem = forwardRef<HTMLButtonElement, AttachmentItemProps>(\n (\n {\n item,\n isEditing,\n draggableProps,\n transformStyle,\n isDragging,\n isOverlay,\n isLoading,\n onDelete,\n onReplaceWithBrowse,\n onReplaceWithUpload,\n onDownload,\n },\n ref,\n ) => {\n const [selectedAsset, setSelectedAsset] = useState<Asset | undefined>();\n const [openFileDialog, { selectedFiles }] = useFileInput({ multiple: true, accept: 'image/*' });\n const [uploadFile, { results: uploadResults, doneAll }] = useAssetUpload();\n\n const { focusProps, isFocusVisible } = useFocusRing();\n\n useEffect(() => {\n if (selectedFiles) {\n uploadFile(selectedFiles[0]);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedFiles]);\n\n useEffect(() => {\n if (doneAll) {\n onReplaceWithUpload(uploadResults[0]);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [doneAll, uploadResults]);\n\n const showLoadingCircle = isLoading || (selectedFiles && !doneAll);\n\n return (\n <button\n aria-label=\"Download attachment\"\n data-test-id=\"attachments-item\"\n onClick={() => !selectedAsset && onDownload?.()}\n ref={ref}\n style={{\n ...transformStyle,\n opacity: isDragging && !isOverlay ? 0.3 : 1,\n fontFamily: 'var(-f-theme-settings-body-font-family)',\n }}\n className={joinClassNames([\n 'tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-box-neutral-hover',\n isDragging ? 'tw-bg-box-neutral-hover' : '',\n ])}\n >\n <div className=\"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover\">\n {showLoadingCircle ? <LoadingCircle size=\"small\" /> : getDecorator(item.objectType)}\n </div>\n <div className=\"tw-text-s tw-flex-1 tw-min-w-0\">\n <div className=\"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover\">\n {item.title}\n </div>\n <div className=\"tw-text-text-weak\">{`${item.fileSizeHumanReadable} - ${item.extension}`}</div>\n </div>\n {isEditing && (\n <div\n data-test-id=\"attachments-actionbar\"\n className={joinClassNames([\n 'tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100',\n isOverlay || selectedAsset?.id === item.id ? 'tw-opacity-100' : 'tw-opacity-0',\n ])}\n >\n <button\n {...focusProps}\n {...draggableProps}\n aria-label=\"Drag attachment\"\n className={joinClassNames([\n ' tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded tw-h-9 tw-w-9 ',\n isDragging || isOverlay\n ? 'tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed'\n : 'tw-cursor-grab hover:tw-bg-button-background-hover',\n isFocusVisible && FOCUS_STYLE,\n isFocusVisible && 'tw-z-[2]',\n ])}\n >\n <IconGrabHandle />\n </button>\n <div data-test-id=\"attachments-actionbar-flyout\">\n <Dropdown.Root\n open={selectedAsset?.id === item.id}\n onOpenChange={(isOpen) => setSelectedAsset(isOpen ? item : undefined)}\n >\n <Dropdown.Trigger>\n <Button\n aspect=\"square\"\n ref={ref as MutableRefObject<HTMLButtonElement>}\n onPress={(e) => {\n e?.stopPropagation();\n e?.preventDefault();\n }}\n emphasis=\"default\"\n >\n <IconPen size=\"20\" />\n </Button>\n </Dropdown.Trigger>\n <Dropdown.Content side=\"right\">\n <Dropdown.Group>\n <Dropdown.Item\n data-test-id=\"menu-item\"\n onSelect={(event) => {\n event?.stopPropagation();\n openFileDialog();\n setSelectedAsset(undefined);\n }}\n >\n <IconArrowCircleUp size=\"20\" />\n Replace with upload\n </Dropdown.Item>\n <Dropdown.Item\n onSelect={(event) => {\n event?.stopPropagation();\n onReplaceWithBrowse();\n setSelectedAsset(undefined);\n }}\n >\n <IconImageStack size=\"20\" />\n Replace with asset\n </Dropdown.Item>\n </Dropdown.Group>\n <Dropdown.Group>\n <Dropdown.Item\n emphasis=\"danger\"\n onSelect={(event) => {\n event?.stopPropagation();\n onDelete();\n setSelectedAsset(undefined);\n }}\n >\n <IconTrashBin size=\"20\" />\n Delete\n </Dropdown.Item>\n </Dropdown.Group>\n </Dropdown.Content>\n </Dropdown.Root>\n </div>\n </div>\n )}\n </button>\n );\n },\n);\n\nAttachmentItem.displayName = 'AttachmentItem';\n\nexport const SortableAttachmentItem = (props: SortableAttachmentItemProps) => {\n const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({\n id: props.item.id,\n });\n\n const transformStyle = {\n transform: transform ? `translate(${transform.x}px, ${transform.y}px)` : '',\n transition,\n zIndex: isDragging ? 2 : 1,\n };\n\n const draggableProps = { ...attributes, ...listeners };\n\n return (\n <AttachmentItem\n ref={setNodeRef}\n isDragging={isDragging}\n transformStyle={transformStyle}\n draggableProps={draggableProps}\n {...props}\n />\n );\n};\n"],"names":["getDecorator","type","jsx","IconImage","IconPlayFrame","IconMusicNote","IconDocument","AttachmentItem","forwardRef","item","isEditing","draggableProps","transformStyle","isDragging","isOverlay","isLoading","onDelete","onReplaceWithBrowse","onReplaceWithUpload","onDownload","ref","selectedAsset","setSelectedAsset","useState","openFileDialog","selectedFiles","useFileInput","uploadFile","uploadResults","doneAll","useAssetUpload","focusProps","isFocusVisible","useFocusRing","useEffect","showLoadingCircle","jsxs","joinClassNames","LoadingCircle","FOCUS_STYLE","IconGrabHandle","Dropdown","isOpen","Button","e","IconPen","event","IconArrowCircleUp","IconImageStack","IconTrashBin","SortableAttachmentItem","props","attributes","listeners","setNodeRef","transform","transition","useSortable"],"mappings":";;;;;;;;;AAwBA,MAAMA,IAAe,CAACC,MACdA,MAAS,UACF,gBAAAC,EAACC,GAAA,EAAU,MAAK,KAAA,CAAK,IACrBF,MAAS,UACT,gBAAAC,EAACE,GAAA,EAAc,MAAK,KAAA,CAAK,IACzBH,MAAS,UACT,gBAAAC,EAACG,GAAA,EAAc,MAAK,KAAA,CAAK,IAEzB,gBAAAH,EAACI,GAAA,EAAa,MAAK,KAAA,CAAK,GAI1BC,IAAiBC;AAAA,EAC1B,CACI;AAAA,IACI,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,YAAAC;AAAA,EAAA,GAEJC,MACC;AACD,UAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAA,GACpC,CAACC,GAAgB,EAAE,eAAAC,EAAA,CAAe,IAAIC,EAAa,EAAE,UAAU,IAAM,QAAQ,WAAW,GACxF,CAACC,GAAY,EAAE,SAASC,GAAe,SAAAC,EAAA,CAAS,IAAIC,EAAA,GAEpD,EAAE,YAAAC,GAAY,gBAAAC,EAAA,IAAmBC,EAAA;AAEvC,IAAAC,EAAU,MAAM;AACZ,MAAIT,KACAE,EAAWF,EAAc,CAAC,CAAC;AAAA,IAGnC,GAAG,CAACA,CAAa,CAAC,GAElBS,EAAU,MAAM;AACZ,MAAIL,KACAX,EAAoBU,EAAc,CAAC,CAAC;AAAA,IAG5C,GAAG,CAACC,GAASD,CAAa,CAAC;AAE3B,UAAMO,IAAoBpB,KAAcU,KAAiB,CAACI;AAE1D,WACI,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,cAAW;AAAA,QACX,gBAAa;AAAA,QACb,SAAS,M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.es.js","sources":["../../../src/components/Attachments/AttachmentItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useSortable } from '@dnd-kit/sortable';\nimport { type Asset, useAssetUpload, useFileInput } from '@frontify/app-bridge';\nimport { LoadingCircle, Dropdown, Button } from '@frontify/fondue/components';\nimport {\n IconArrowCircleUp,\n IconImageStack,\n IconPen,\n IconTrashBin,\n IconDocument,\n IconImage,\n IconPlayFrame,\n IconMusicNote,\n IconGrabHandle,\n} from '@frontify/fondue/icons';\nimport { useFocusRing } from '@react-aria/focus';\nimport { type MutableRefObject, forwardRef, useEffect, useState } from 'react';\n\nimport { joinClassNames } from '../../utilities';\n\nimport { type AttachmentItemProps, type SortableAttachmentItemProps } from './types';\n\nconst getDecorator = (type: string) => {\n if (type === 'IMAGE') {\n return <IconImage size=\"24\" />;\n } else if (type === 'VIDEO') {\n return <IconPlayFrame size=\"24\" />;\n } else if (type === 'AUDIO') {\n return <IconMusicNote size=\"24\" />;\n } else {\n return <IconDocument size=\"24\" />;\n }\n};\n\nexport const AttachmentItem = forwardRef<HTMLButtonElement, AttachmentItemProps>(\n (\n {\n item,\n isEditing,\n draggableProps,\n transformStyle,\n isDragging,\n isOverlay,\n isLoading,\n onDelete,\n onReplaceWithBrowse,\n onReplaceWithUpload,\n onDownload,\n },\n ref,\n ) => {\n const [selectedAsset, setSelectedAsset] = useState<Asset | undefined>();\n const [openFileDialog, { selectedFiles }] = useFileInput({ multiple: true, accept: 'image/*' });\n const [uploadFile, { results: uploadResults, doneAll }] = useAssetUpload();\n\n const { focusProps, isFocusVisible } = useFocusRing();\n\n useEffect(() => {\n if (selectedFiles) {\n uploadFile(selectedFiles[0]);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedFiles]);\n\n useEffect(() => {\n if (doneAll) {\n onReplaceWithUpload(uploadResults[0]);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [doneAll, uploadResults]);\n\n const showLoadingCircle = isLoading || (selectedFiles && !doneAll);\n\n return (\n <button\n type=\"button\"\n aria-label=\"Download attachment\"\n data-test-id=\"attachments-item\"\n onClick={() => !selectedAsset && onDownload?.()}\n ref={ref}\n style={{\n ...transformStyle,\n opacity: isDragging && !isOverlay ? 0.3 : 1,\n fontFamily: 'var(-f-theme-settings-body-font-family)',\n }}\n className={joinClassNames([\n 'tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-box-neutral-hover',\n isDragging ? 'tw-bg-box-neutral-hover' : '',\n ])}\n >\n <div className=\"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover\">\n {showLoadingCircle ? <LoadingCircle size=\"small\" /> : getDecorator(item.objectType)}\n </div>\n <div className=\"tw-text-s tw-flex-1 tw-min-w-0\">\n <div className=\"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover\">\n {item.title}\n </div>\n <div className=\"tw-text-text-weak\">{`${item.fileSizeHumanReadable} - ${item.extension}`}</div>\n </div>\n {isEditing && (\n <div\n data-test-id=\"attachments-actionbar\"\n className={joinClassNames([\n 'tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100',\n isOverlay || selectedAsset?.id === item.id ? 'tw-opacity-100' : 'tw-opacity-0',\n ])}\n >\n <button\n type=\"button\"\n {...focusProps}\n {...draggableProps}\n aria-label=\"Drag attachment\"\n className={joinClassNames([\n ' tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded tw-h-9 tw-w-9 ',\n isDragging || isOverlay\n ? 'tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed'\n : 'tw-cursor-grab hover:tw-bg-button-background-hover',\n isFocusVisible &&\n 'tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none',\n isFocusVisible && 'tw-z-[2]',\n ])}\n >\n <IconGrabHandle />\n </button>\n <div data-test-id=\"attachments-actionbar-flyout\">\n <Dropdown.Root\n open={selectedAsset?.id === item.id}\n onOpenChange={(isOpen) => setSelectedAsset(isOpen ? item : undefined)}\n >\n <Dropdown.Trigger>\n <Button\n aspect=\"square\"\n ref={ref as MutableRefObject<HTMLButtonElement>}\n onPress={(e) => {\n e?.stopPropagation();\n e?.preventDefault();\n }}\n emphasis=\"default\"\n >\n <IconPen size=\"20\" />\n </Button>\n </Dropdown.Trigger>\n <Dropdown.Content side=\"right\">\n <Dropdown.Group>\n <Dropdown.Item\n data-test-id=\"menu-item\"\n onSelect={(event) => {\n event?.stopPropagation();\n openFileDialog();\n setSelectedAsset(undefined);\n }}\n >\n <IconArrowCircleUp size=\"20\" />\n Replace with upload\n </Dropdown.Item>\n <Dropdown.Item\n onSelect={(event) => {\n event?.stopPropagation();\n onReplaceWithBrowse();\n setSelectedAsset(undefined);\n }}\n >\n <IconImageStack size=\"20\" />\n Replace with asset\n </Dropdown.Item>\n </Dropdown.Group>\n <Dropdown.Group>\n <Dropdown.Item\n emphasis=\"danger\"\n onSelect={(event) => {\n event?.stopPropagation();\n onDelete();\n setSelectedAsset(undefined);\n }}\n >\n <IconTrashBin size=\"20\" />\n Delete\n </Dropdown.Item>\n </Dropdown.Group>\n </Dropdown.Content>\n </Dropdown.Root>\n </div>\n </div>\n )}\n </button>\n );\n },\n);\n\nAttachmentItem.displayName = 'AttachmentItem';\n\nexport const SortableAttachmentItem = (props: SortableAttachmentItemProps) => {\n const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({\n id: props.item.id,\n });\n\n const transformStyle = {\n transform: transform ? `translate(${transform.x}px, ${transform.y}px)` : '',\n transition,\n zIndex: isDragging ? 2 : 1,\n };\n\n const draggableProps = { ...attributes, ...listeners };\n\n return (\n <AttachmentItem\n ref={setNodeRef}\n isDragging={isDragging}\n transformStyle={transformStyle}\n draggableProps={draggableProps}\n {...props}\n />\n );\n};\n"],"names":["getDecorator","type","jsx","IconImage","IconPlayFrame","IconMusicNote","IconDocument","AttachmentItem","forwardRef","item","isEditing","draggableProps","transformStyle","isDragging","isOverlay","isLoading","onDelete","onReplaceWithBrowse","onReplaceWithUpload","onDownload","ref","selectedAsset","setSelectedAsset","useState","openFileDialog","selectedFiles","useFileInput","uploadFile","uploadResults","doneAll","useAssetUpload","focusProps","isFocusVisible","useFocusRing","useEffect","showLoadingCircle","jsxs","joinClassNames","LoadingCircle","IconGrabHandle","Dropdown","isOpen","Button","e","IconPen","event","IconArrowCircleUp","IconImageStack","IconTrashBin","SortableAttachmentItem","props","attributes","listeners","setNodeRef","transform","transition","useSortable"],"mappings":";;;;;;;;AAuBA,MAAMA,IAAe,CAACC,MACdA,MAAS,UACF,gBAAAC,EAACC,GAAA,EAAU,MAAK,KAAA,CAAK,IACrBF,MAAS,UACT,gBAAAC,EAACE,GAAA,EAAc,MAAK,KAAA,CAAK,IACzBH,MAAS,UACT,gBAAAC,EAACG,GAAA,EAAc,MAAK,KAAA,CAAK,IAEzB,gBAAAH,EAACI,GAAA,EAAa,MAAK,KAAA,CAAK,GAI1BC,IAAiBC;AAAA,EAC1B,CACI;AAAA,IACI,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,YAAAC;AAAA,EAAA,GAEJC,MACC;AACD,UAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAA,GACpC,CAACC,GAAgB,EAAE,eAAAC,EAAA,CAAe,IAAIC,EAAa,EAAE,UAAU,IAAM,QAAQ,WAAW,GACxF,CAACC,GAAY,EAAE,SAASC,GAAe,SAAAC,EAAA,CAAS,I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AAA,IACzF,IAAIN,EAAM,KAAK;AAAA,EAAA,CAClB,GAEKtC,IAAiB;AAAA,IACnB,WAAW0C,IAAY,aAAaA,EAAU,CAAC,OAAOA,EAAU,CAAC,QAAQ;AAAA,IACzE,YAAAC;AAAA,IACA,QAAQ1C,IAAa,IAAI;AAAA,EAAA,GAGvBF,IAAiB,EAAE,GAAGwC,GAAY,GAAGC,EAAA;AAE3C,SACI,gBAAAlD;AAAA,IAACK;AAAA,IAAA;AAAA,MACG,KAAK8C;AAAA,MACL,YAAAxC;AAAA,MACA,gBAAAD;AAAA,MACA,gBAAAD;AAAA,MACC,GAAGuC;AAAA,IAAA;AAAA,EAAA;AAGhB;"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { FOCUS_STYLE as a } from "@frontify/fondue";
|
|
3
2
|
import { Tooltip as o } from "@frontify/fondue/components";
|
|
4
3
|
import { IconArrowCircleDown as w } from "@frontify/fondue/icons";
|
|
5
|
-
import { useFocusRing as
|
|
4
|
+
import { useFocusRing as a } from "@react-aria/focus";
|
|
6
5
|
import { joinClassNames as u } from "../../utilities/react/joinClassNames.es.js";
|
|
7
|
-
const
|
|
8
|
-
const { isFocused: r, focusProps: i } =
|
|
6
|
+
const p = ({ onDownload: e, ariaLabel: n }) => {
|
|
7
|
+
const { isFocused: r, focusProps: i } = a();
|
|
9
8
|
return /* @__PURE__ */ l(o.Root, { enterDelay: 500, children: [
|
|
10
9
|
/* @__PURE__ */ t(o.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
|
|
11
10
|
"button",
|
|
12
11
|
{
|
|
12
|
+
type: "button",
|
|
13
13
|
tabIndex: 0,
|
|
14
14
|
"aria-label": n ?? "Download",
|
|
15
15
|
...i,
|
|
16
|
-
className: u([
|
|
16
|
+
className: u([
|
|
17
|
+
"tw-outline-none tw-rounded",
|
|
18
|
+
r && "tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none"
|
|
19
|
+
]),
|
|
17
20
|
onClick: e,
|
|
18
21
|
onPointerDown: (s) => s.preventDefault(),
|
|
19
22
|
"data-test-id": "download-button",
|
|
@@ -24,6 +27,6 @@ const g = ({ onDownload: e, ariaLabel: n }) => {
|
|
|
24
27
|
] });
|
|
25
28
|
};
|
|
26
29
|
export {
|
|
27
|
-
|
|
30
|
+
p as DownloadButton
|
|
28
31
|
};
|
|
29
32
|
//# sourceMappingURL=DownloadButton.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadButton.es.js","sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {
|
|
1
|
+
{"version":3,"file":"DownloadButton.es.js","sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Tooltip } from '@frontify/fondue/components';\nimport { IconArrowCircleDown } from '@frontify/fondue/icons';\nimport { useFocusRing } from '@react-aria/focus';\n\nimport { joinClassNames } from '../../utilities';\n\nimport { type DownloadButtonProps } from './types';\n\nexport const DownloadButton = ({ onDownload, ariaLabel }: DownloadButtonProps) => {\n const { isFocused, focusProps } = useFocusRing();\n\n return (\n <Tooltip.Root enterDelay={500}>\n <Tooltip.Trigger asChild>\n <button\n type=\"button\"\n tabIndex={0}\n aria-label={ariaLabel ?? 'Download'}\n {...focusProps}\n className={joinClassNames([\n 'tw-outline-none tw-rounded',\n isFocused &&\n 'tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none',\n ])}\n onClick={onDownload}\n onPointerDown={(e) => e.preventDefault()}\n data-test-id=\"download-button\"\n >\n <span className=\"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line\">\n <IconArrowCircleDown size=\"16\" />\n </span>\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content side=\"top\">Download</Tooltip.Content>\n </Tooltip.Root>\n );\n};\n"],"names":["DownloadButton","onDownload","ariaLabel","isFocused","focusProps","useFocusRing","jsxs","Tooltip","jsx","joinClassNames","e","IconArrowCircleDown"],"mappings":";;;;;AAUO,MAAMA,IAAiB,CAAC,EAAE,YAAAC,GAAY,WAAAC,QAAqC;AAC9E,QAAM,EAAE,WAAAC,GAAW,YAAAC,EAAA,IAAeC,EAAA;AAElC,SACI,gBAAAC,EAACC,EAAQ,MAAR,EAAa,YAAY,KACtB,UAAA;AAAA,IAAA,gBAAAC,EAACD,EAAQ,SAAR,EAAgB,SAAO,IACpB,UAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,MAAK;AAAA,QACL,UAAU;AAAA,QACV,cAAYN,KAAa;AAAA,QACxB,GAAGE;AAAA,QACJ,WAAWK,EAAe;AAAA,UACtB;AAAA,UACAN,KACI;AAAA,QAAA,CACP;AAAA,QACD,SAASF;AAAA,QACT,eAAe,CAACS,MAAMA,EAAE,eAAA;AAAA,QACxB,gBAAa;AAAA,QAEb,UAAA,gBAAAF,EAAC,UAAK,WAAU,0SACZ,4BAACG,GAAA,EAAoB,MAAK,MAAK,EAAA,CACnC;AAAA,MAAA;AAAA,IAAA,GAER;AAAA,sBACCJ,EAAQ,SAAR,EAAgB,MAAK,OAAM,UAAA,WAAA,CAAQ;AAAA,EAAA,GACxC;AAER;"}
|