@frontify/guideline-blocks-settings 0.30.0 → 0.30.2

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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # @frontify/guideline-blocks-settings
2
2
 
3
+ ## 0.30.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#687](https://github.com/Frontify/brand-sdk/pull/687) [`b044981`](https://github.com/Frontify/brand-sdk/commit/b0449814d55554e82507e1341d0f42a35f17a5e5) Thanks [@ragi96](https://github.com/ragi96)! - chore(Attachments): replace deprecated functions with hooks
8
+
9
+ - [#696](https://github.com/Frontify/brand-sdk/pull/696) [`edc00b0`](https://github.com/Frontify/brand-sdk/commit/edc00b0cb1b04753e1563231eb1e28f9e7d05670) Thanks [@SamCreasey](https://github.com/SamCreasey)! - fix(Attachments): Add line-height class to `AttachmentsButtonTrigger`.
10
+
11
+ - [#695](https://github.com/Frontify/brand-sdk/pull/695) [`d7764c1`](https://github.com/Frontify/brand-sdk/commit/d7764c129ee1d61aaed4ce519e70eb5d0984bfec) Thanks [@ragi96](https://github.com/ragi96)! - chore: bump @frontify/fondue to v12.0.0-beta.395
12
+
13
+ - [#689](https://github.com/Frontify/brand-sdk/pull/689) [`6c34c1c`](https://github.com/Frontify/brand-sdk/commit/6c34c1c8e354f95bb873a70bceef0939198574c4) Thanks [@fulopdaniel](https://github.com/fulopdaniel)! - feat(Attachments): temporarily disable sorting
14
+
15
+ - Updated dependencies [[`d79e69a`](https://github.com/Frontify/brand-sdk/commit/d79e69a1c6d8f901b7f91866a92fd0d99363f07d), [`d7764c1`](https://github.com/Frontify/brand-sdk/commit/d7764c129ee1d61aaed4ce519e70eb5d0984bfec)]:
16
+ - @frontify/sidebar-settings@0.9.0
17
+
18
+ ## 0.30.1
19
+
20
+ ### Patch Changes
21
+
22
+ - [#691](https://github.com/Frontify/brand-sdk/pull/691) [`2a2f106`](https://github.com/Frontify/brand-sdk/commit/2a2f106c0f79c7d43dfddf3d0193fa9eeb7835a3) Thanks [@SamCreasey](https://github.com/SamCreasey)! - Toolbar components and types have been made available in build
23
+
24
+ - [#692](https://github.com/Frontify/brand-sdk/pull/692) [`43866c2`](https://github.com/Frontify/brand-sdk/commit/43866c28fa470d5dbf4e61a7d42796904629fead) Thanks [@SamCreasey](https://github.com/SamCreasey)! - BlockItemToolbar: Force line-height to be 1 on toolbar items to prevent wrapping element height from being miscalculated.
25
+
26
+ - Updated dependencies [[`3fa74ba`](https://github.com/Frontify/brand-sdk/commit/3fa74badfedd8c52661f23e0528dc35d8a10062d)]:
27
+ - @frontify/app-bridge@3.0.2
28
+ - @frontify/sidebar-settings@0.8.3
29
+
3
30
  ## 0.30.0
4
31
 
5
32
  ### Minor Changes
@@ -1,145 +1,126 @@
1
- import { jsxs as b, jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as A, useState as j, useEffect as I } from "react";
3
- import { useFileInput as D, useAssetUpload as E } from "@frontify/app-bridge";
4
- import { useSortable as M } from "@dnd-kit/sortable";
5
- import { useFocusRing as P } from "@react-aria/focus";
6
- import { LoadingCircle as V, LoadingCircleSize as B, FOCUS_STYLE as L, IconGrabHandle20 as U, Flyout as $, FlyoutPlacement as O, Button as T, IconPen20 as X, ButtonEmphasis as G, ActionMenu as H, MenuItemContentSize as f, IconArrowCircleUp20 as _, IconImageStack20 as Y, MenuItemStyle as q, IconTrashBin20 as J, IconImage24 as K, IconPlayFrame24 as Q, IconMusicNote24 as W, IconDocument24 as Z } from "@frontify/fondue";
7
- import { joinClassNames as h } from "../../utilities/react/joinClassNames.es.js";
8
- const tt = (e) => e === "IMAGE" ? /* @__PURE__ */ t(K, {}) : e === "VIDEO" ? /* @__PURE__ */ t(Q, {}) : e === "AUDIO" ? /* @__PURE__ */ t(W, {}) : /* @__PURE__ */ t(Z, {}), y = A(
1
+ import { jsxs as g, jsx as t } from "react/jsx-runtime";
2
+ import { forwardRef as F, useState as z, useEffect as v } from "react";
3
+ import { useFileInput as A, useAssetUpload as R } from "@frontify/app-bridge";
4
+ import { useSortable as D } from "@dnd-kit/sortable";
5
+ import { LoadingCircle as M, LoadingCircleSize as j, Flyout as B, FlyoutPlacement as E, Button as P, IconPen20 as V, ButtonEmphasis as $, ActionMenu as L, MenuItemContentSize as f, IconArrowCircleUp20 as O, IconImageStack20 as U, MenuItemStyle as X, IconTrashBin20 as T, IconImage24 as G, IconPlayFrame24 as H, IconMusicNote24 as _, IconDocument24 as q } from "@frontify/fondue";
6
+ import { joinClassNames as I } from "../../utilities/react/joinClassNames.es.js";
7
+ const J = (e) => e === "IMAGE" ? /* @__PURE__ */ t(G, {}) : e === "VIDEO" ? /* @__PURE__ */ t(H, {}) : e === "AUDIO" ? /* @__PURE__ */ t(_, {}) : /* @__PURE__ */ t(q, {}), y = F(
9
8
  ({
10
9
  item: e,
11
10
  isEditing: s,
12
- draggableProps: c,
13
- transformStyle: u,
14
- isDragging: o,
15
- isOverlay: a,
16
- isLoading: n,
17
- onDelete: d,
18
- onReplaceWithBrowse: m,
19
- onReplaceWithUpload: S,
11
+ transformStyle: c,
12
+ isDragging: r,
13
+ isOverlay: i,
14
+ isLoading: m,
15
+ onDelete: l,
16
+ onReplaceWithBrowse: d,
17
+ onReplaceWithUpload: u,
20
18
  onDownload: w
21
- }, k) => {
22
- const [r, i] = j(), [C, { selectedFiles: l }] = D({ multiple: !0, accept: "image/*" }), [N, { results: g, doneAll: p }] = E(), { focusProps: F, isFocusVisible: v } = P();
23
- I(() => {
24
- l && N(l[0]);
25
- }, [l]), I(() => {
26
- p && S(g[0]);
27
- }, [p, g]);
28
- const z = n || l && !p;
29
- return /* @__PURE__ */ b(
19
+ }, b) => {
20
+ const [a, o] = z(), [S, { selectedFiles: n }] = A({ multiple: !0, accept: "image/*" }), [C, { results: h, doneAll: p }] = R();
21
+ v(() => {
22
+ n && C(n[0]);
23
+ }, [n]), v(() => {
24
+ p && u(h[0]);
25
+ }, [p, h]);
26
+ const N = m || n && !p;
27
+ return /* @__PURE__ */ g(
30
28
  "button",
31
29
  {
32
30
  "aria-label": "Download attachment",
33
31
  "data-test-id": "attachments-item",
34
32
  onClick: () => w == null ? void 0 : w(),
35
- ref: k,
33
+ ref: b,
36
34
  style: {
37
- ...u,
38
- opacity: o && !a ? 0.3 : 1,
35
+ ...c,
36
+ opacity: r && !i ? 0.3 : 1,
39
37
  fontFamily: "var(-f-theme-settings-body-font-family)"
40
38
  },
41
- className: h([
39
+ className: I([
42
40
  "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",
43
- o ? "tw-bg-box-neutral-hover" : ""
41
+ r ? "tw-bg-box-neutral-hover" : ""
44
42
  ]),
45
43
  children: [
46
- /* @__PURE__ */ t("div", { className: "tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover", children: z ? /* @__PURE__ */ t(V, { size: B.Small }) : tt(e.objectType) }),
47
- /* @__PURE__ */ b("div", { className: "tw-text-s tw-flex-1 tw-min-w-0", children: [
44
+ /* @__PURE__ */ t("div", { className: "tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover", children: N ? /* @__PURE__ */ t(M, { size: j.Small }) : J(e.objectType) }),
45
+ /* @__PURE__ */ g("div", { className: "tw-text-s tw-flex-1 tw-min-w-0", children: [
48
46
  /* @__PURE__ */ t("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: e.title }),
49
47
  /* @__PURE__ */ t("div", { className: "tw-text-text-weak", children: `${e.fileSizeHumanReadable} - ${e.extension}` })
50
48
  ] }),
51
- s && /* @__PURE__ */ b(
49
+ s && /* @__PURE__ */ t(
52
50
  "div",
53
51
  {
54
52
  "data-test-id": "attachments-actionbar",
55
- className: h([
53
+ className: I([
56
54
  "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",
57
- a || (r == null ? void 0 : r.id) === e.id ? "tw-opacity-100" : "tw-opacity-0"
55
+ i || (a == null ? void 0 : a.id) === e.id ? "tw-opacity-100" : "tw-opacity-0"
58
56
  ]),
59
- children: [
60
- /* @__PURE__ */ t(
61
- "button",
62
- {
63
- ...F,
64
- ...c,
65
- "aria-label": "Drag attachment",
66
- className: h([
67
- " 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 ",
68
- o || a ? "tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed" : "tw-cursor-grab hover:tw-bg-button-background-hover",
69
- v && L,
70
- v && "tw-z-[2]"
71
- ]),
72
- children: /* @__PURE__ */ t(U, {})
73
- }
74
- ),
75
- /* @__PURE__ */ t("div", { "data-test-id": "attachments-actionbar-flyout", children: /* @__PURE__ */ t(
76
- $,
77
- {
78
- placement: O.Right,
79
- isOpen: (r == null ? void 0 : r.id) === e.id,
80
- fitContent: !0,
81
- legacyFooter: !1,
82
- onOpenChange: (x) => i(x ? e : void 0),
83
- trigger: (x, R) => /* @__PURE__ */ t(
84
- T,
85
- {
86
- ref: R,
87
- icon: /* @__PURE__ */ t(X, {}),
88
- emphasis: G.Default,
89
- onClick: () => i(e)
90
- }
91
- ),
92
- children: /* @__PURE__ */ t(
93
- H,
94
- {
95
- menuBlocks: [
96
- {
97
- id: "menu",
98
- menuItems: [
99
- {
100
- id: "upload",
101
- size: f.XSmall,
102
- title: "Replace with upload",
103
- onClick: () => {
104
- C(), i(void 0);
105
- },
106
- initialValue: !0,
107
- decorator: /* @__PURE__ */ t("div", { className: "tw-mr-2", children: /* @__PURE__ */ t(_, {}) })
57
+ children: /* @__PURE__ */ t("div", { "data-test-id": "attachments-actionbar-flyout", children: /* @__PURE__ */ t(
58
+ B,
59
+ {
60
+ placement: E.Right,
61
+ isOpen: (a == null ? void 0 : a.id) === e.id,
62
+ fitContent: !0,
63
+ legacyFooter: !1,
64
+ onOpenChange: (x) => o(x ? e : void 0),
65
+ trigger: (x, k) => /* @__PURE__ */ t(
66
+ P,
67
+ {
68
+ ref: k,
69
+ icon: /* @__PURE__ */ t(V, {}),
70
+ emphasis: $.Default,
71
+ onClick: () => o(e)
72
+ }
73
+ ),
74
+ children: /* @__PURE__ */ t(
75
+ L,
76
+ {
77
+ menuBlocks: [
78
+ {
79
+ id: "menu",
80
+ menuItems: [
81
+ {
82
+ id: "upload",
83
+ size: f.XSmall,
84
+ title: "Replace with upload",
85
+ onClick: () => {
86
+ S(), o(void 0);
108
87
  },
109
- {
110
- id: "asset",
111
- size: f.XSmall,
112
- title: "Replace with asset",
113
- onClick: () => {
114
- m(), i(void 0);
115
- },
116
- initialValue: !0,
117
- decorator: /* @__PURE__ */ t("div", { className: "tw-mr-2", children: /* @__PURE__ */ t(Y, {}) })
118
- }
119
- ]
120
- },
121
- {
122
- id: "menu-delete",
123
- menuItems: [
124
- {
125
- id: "delete",
126
- size: f.XSmall,
127
- title: "Delete",
128
- style: q.Danger,
129
- onClick: () => {
130
- d(), i(void 0);
131
- },
132
- initialValue: !0,
133
- decorator: /* @__PURE__ */ t("div", { className: "tw-mr-2", children: /* @__PURE__ */ t(J, {}) })
134
- }
135
- ]
136
- }
137
- ]
138
- }
139
- )
140
- }
141
- ) })
142
- ]
88
+ initialValue: !0,
89
+ decorator: /* @__PURE__ */ t("div", { className: "tw-mr-2", children: /* @__PURE__ */ t(O, {}) })
90
+ },
91
+ {
92
+ id: "asset",
93
+ size: f.XSmall,
94
+ title: "Replace with asset",
95
+ onClick: () => {
96
+ d(), o(void 0);
97
+ },
98
+ initialValue: !0,
99
+ decorator: /* @__PURE__ */ t("div", { className: "tw-mr-2", children: /* @__PURE__ */ t(U, {}) })
100
+ }
101
+ ]
102
+ },
103
+ {
104
+ id: "menu-delete",
105
+ menuItems: [
106
+ {
107
+ id: "delete",
108
+ size: f.XSmall,
109
+ title: "Delete",
110
+ style: X.Danger,
111
+ onClick: () => {
112
+ l(), o(void 0);
113
+ },
114
+ initialValue: !0,
115
+ decorator: /* @__PURE__ */ t("div", { className: "tw-mr-2", children: /* @__PURE__ */ t(T, {}) })
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ )
122
+ }
123
+ ) })
143
124
  }
144
125
  )
145
126
  ]
@@ -148,27 +129,27 @@ const tt = (e) => e === "IMAGE" ? /* @__PURE__ */ t(K, {}) : e === "VIDEO" ? /*
148
129
  }
149
130
  );
150
131
  y.displayName = "AttachmentItem";
151
- const st = (e) => {
152
- const { attributes: s, listeners: c, setNodeRef: u, transform: o, transition: a, isDragging: n } = M({
132
+ const et = (e) => {
133
+ const { attributes: s, listeners: c, setNodeRef: r, transform: i, transition: m, isDragging: l } = D({
153
134
  id: e.item.id
154
135
  }), d = {
155
- transform: o ? `translate(${o.x}px, ${o.y}px)` : "",
156
- transition: a,
157
- zIndex: n ? 2 : 1
158
- }, m = { ...s, ...c };
136
+ transform: i ? `translate(${i.x}px, ${i.y}px)` : "",
137
+ transition: m,
138
+ zIndex: l ? 2 : 1
139
+ }, u = { ...s, ...c };
159
140
  return /* @__PURE__ */ t(
160
141
  y,
161
142
  {
162
- ref: u,
163
- isDragging: n,
143
+ ref: r,
144
+ isDragging: l,
164
145
  transformStyle: d,
165
- draggableProps: m,
146
+ draggableProps: u,
166
147
  ...e
167
148
  }
168
149
  );
169
150
  };
170
151
  export {
171
152
  y as AttachmentItem,
172
- st as SortableAttachmentItem
153
+ et as SortableAttachmentItem
173
154
  };
174
155
  //# 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 { MutableRefObject, forwardRef, useEffect, useState } from 'react';\nimport { Asset, useAssetUpload, useFileInput } from '@frontify/app-bridge';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { useFocusRing } from '@react-aria/focus';\n\nimport {\n ActionMenu,\n Button,\n ButtonEmphasis,\n FOCUS_STYLE,\n Flyout,\n FlyoutPlacement,\n IconArrowCircleUp20,\n IconDocument24,\n IconGrabHandle20,\n IconImage24,\n IconImageStack20,\n IconMusicNote24,\n IconPen20,\n IconPlayFrame24,\n IconTrashBin20,\n LoadingCircle,\n LoadingCircleSize,\n MenuItemContentSize,\n MenuItemStyle,\n} from '@frontify/fondue';\nimport { AttachmentItemProps, SortableAttachmentItemProps } from './types';\nimport { joinClassNames } from '../../utilities';\n\nconst getDecorator = (type: string) => {\n if (type === 'IMAGE') {\n return <IconImage24 />;\n } else if (type === 'VIDEO') {\n return <IconPlayFrame24 />;\n } else if (type === 'AUDIO') {\n return <IconMusicNote24 />;\n } else {\n return <IconDocument24 />;\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 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={() => 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 ? (\n <LoadingCircle size={LoadingCircleSize.Small} />\n ) : (\n getDecorator(item.objectType)\n )}\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 <IconGrabHandle20 />\n </button>\n <div data-test-id=\"attachments-actionbar-flyout\">\n <Flyout\n placement={FlyoutPlacement.Right}\n isOpen={selectedAsset?.id === item.id}\n fitContent\n legacyFooter={false}\n onOpenChange={(isOpen) => setSelectedAsset(isOpen ? item : undefined)}\n trigger={(_, ref) => (\n <Button\n ref={ref as MutableRefObject<HTMLButtonElement>}\n icon={<IconPen20 />}\n emphasis={ButtonEmphasis.Default}\n onClick={() => setSelectedAsset(item)}\n />\n )}\n >\n <ActionMenu\n menuBlocks={[\n {\n id: 'menu',\n menuItems: [\n {\n id: 'upload',\n size: MenuItemContentSize.XSmall,\n title: 'Replace with upload',\n onClick: () => {\n openFileDialog();\n setSelectedAsset(undefined);\n },\n\n initialValue: true,\n decorator: (\n <div className=\"tw-mr-2\">\n <IconArrowCircleUp20 />\n </div>\n ),\n },\n\n {\n id: 'asset',\n size: MenuItemContentSize.XSmall,\n title: 'Replace with asset',\n onClick: () => {\n onReplaceWithBrowse();\n setSelectedAsset(undefined);\n },\n initialValue: true,\n decorator: (\n <div className=\"tw-mr-2\">\n <IconImageStack20 />\n </div>\n ),\n },\n ],\n },\n {\n id: 'menu-delete',\n menuItems: [\n {\n id: 'delete',\n size: MenuItemContentSize.XSmall,\n title: 'Delete',\n style: MenuItemStyle.Danger,\n onClick: () => {\n onDelete();\n setSelectedAsset(undefined);\n },\n\n initialValue: true,\n decorator: (\n <div className=\"tw-mr-2\">\n <IconTrashBin20 />\n </div>\n ),\n },\n ],\n },\n ]}\n />\n </Flyout>\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","IconImage24","IconPlayFrame24","IconMusicNote24","IconDocument24","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","jsx","LoadingCircle","LoadingCircleSize","FOCUS_STYLE","IconGrabHandle20","Flyout","FlyoutPlacement","isOpen","_","Button","IconPen20","ButtonEmphasis","ActionMenu","MenuItemContentSize","IconArrowCircleUp20","IconImageStack20","MenuItemStyle","IconTrashBin20","SortableAttachmentItem","props","attributes","listeners","setNodeRef","transform","transition","useSortable"],"mappings":";;;;;;;AA+BA,MAAMA,KAAe,CAACC,MACdA,MAAS,4BACDC,GAAY,CAAA,CAAA,IACbD,MAAS,4BACRE,GAAgB,CAAA,CAAA,IACjBF,MAAS,4BACRG,GAAgB,CAAA,CAAA,sBAEhBC,GAAe,CAAA,CAAA,GAIlBC,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,KAEJC,MACC;AACD,UAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA4B,GAChE,CAACC,GAAgB,EAAE,eAAAC,EAAA,CAAe,IAAIC,EAAa,EAAE,UAAU,IAAM,QAAQ,UAAW,CAAA,GACxF,CAACC,GAAY,EAAE,SAASC,GAAe,SAAAC,EAAS,CAAA,IAAIC,KACpD,EAAE,YAAAC,GAAY,gBAAAC,EAAe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AAGC,EAAU;AAGjD,SAAA,gBAAArB;AAAA,IAAC/B;AAAA,IAAA;AAAA,MACG,KAAKqD;AAAA,MACL,YAAA/C;AAAA,MACA,gBAAAD;AAAA,MACA,gBAAAD;AAAA,MACC,GAAG8C;AAAA,IAAA;AAAA,EAAA;AAGhB;"}
1
+ {"version":3,"file":"AttachmentItem.es.js","sources":["../../../src/components/Attachments/AttachmentItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { MutableRefObject, forwardRef, useEffect, useState } from 'react';\nimport { Asset, useAssetUpload, useFileInput } from '@frontify/app-bridge';\nimport { useSortable } from '@dnd-kit/sortable';\n\nimport {\n ActionMenu,\n Button,\n ButtonEmphasis,\n Flyout,\n FlyoutPlacement,\n IconArrowCircleUp20,\n IconDocument24,\n IconImage24,\n IconImageStack20,\n IconMusicNote24,\n IconPen20,\n IconPlayFrame24,\n IconTrashBin20,\n LoadingCircle,\n LoadingCircleSize,\n MenuItemContentSize,\n MenuItemStyle,\n} from '@frontify/fondue';\nimport { AttachmentItemProps, SortableAttachmentItemProps } from './types';\nimport { joinClassNames } from '../../utilities';\n\nconst getDecorator = (type: string) => {\n if (type === 'IMAGE') {\n return <IconImage24 />;\n } else if (type === 'VIDEO') {\n return <IconPlayFrame24 />;\n } else if (type === 'AUDIO') {\n return <IconMusicNote24 />;\n } else {\n return <IconDocument24 />;\n }\n};\n\nexport const AttachmentItem = forwardRef<HTMLButtonElement, AttachmentItemProps>(\n (\n {\n item,\n isEditing,\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 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={() => 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 ? (\n <LoadingCircle size={LoadingCircleSize.Small} />\n ) : (\n getDecorator(item.objectType)\n )}\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 <div data-test-id=\"attachments-actionbar-flyout\">\n <Flyout\n placement={FlyoutPlacement.Right}\n isOpen={selectedAsset?.id === item.id}\n fitContent\n legacyFooter={false}\n onOpenChange={(isOpen) => setSelectedAsset(isOpen ? item : undefined)}\n trigger={(_, ref) => (\n <Button\n ref={ref as MutableRefObject<HTMLButtonElement>}\n icon={<IconPen20 />}\n emphasis={ButtonEmphasis.Default}\n onClick={() => setSelectedAsset(item)}\n />\n )}\n >\n <ActionMenu\n menuBlocks={[\n {\n id: 'menu',\n menuItems: [\n {\n id: 'upload',\n size: MenuItemContentSize.XSmall,\n title: 'Replace with upload',\n onClick: () => {\n openFileDialog();\n setSelectedAsset(undefined);\n },\n\n initialValue: true,\n decorator: (\n <div className=\"tw-mr-2\">\n <IconArrowCircleUp20 />\n </div>\n ),\n },\n\n {\n id: 'asset',\n size: MenuItemContentSize.XSmall,\n title: 'Replace with asset',\n onClick: () => {\n onReplaceWithBrowse();\n setSelectedAsset(undefined);\n },\n initialValue: true,\n decorator: (\n <div className=\"tw-mr-2\">\n <IconImageStack20 />\n </div>\n ),\n },\n ],\n },\n {\n id: 'menu-delete',\n menuItems: [\n {\n id: 'delete',\n size: MenuItemContentSize.XSmall,\n title: 'Delete',\n style: MenuItemStyle.Danger,\n onClick: () => {\n onDelete();\n setSelectedAsset(undefined);\n },\n\n initialValue: true,\n decorator: (\n <div className=\"tw-mr-2\">\n <IconTrashBin20 />\n </div>\n ),\n },\n ],\n },\n ]}\n />\n </Flyout>\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","IconImage24","IconPlayFrame24","IconMusicNote24","IconDocument24","AttachmentItem","forwardRef","item","isEditing","transformStyle","isDragging","isOverlay","isLoading","onDelete","onReplaceWithBrowse","onReplaceWithUpload","onDownload","ref","selectedAsset","setSelectedAsset","useState","openFileDialog","selectedFiles","useFileInput","uploadFile","uploadResults","doneAll","useAssetUpload","useEffect","showLoadingCircle","jsxs","joinClassNames","jsx","LoadingCircle","LoadingCircleSize","Flyout","FlyoutPlacement","isOpen","_","Button","IconPen20","ButtonEmphasis","ActionMenu","MenuItemContentSize","IconArrowCircleUp20","IconImageStack20","MenuItemStyle","IconTrashBin20","SortableAttachmentItem","props","attributes","listeners","setNodeRef","transform","transition","useSortable","draggableProps"],"mappings":";;;;;;AA4BA,MAAMA,IAAe,CAACC,MACdA,MAAS,4BACDC,GAAY,CAAA,CAAA,IACbD,MAAS,4BACRE,GAAgB,CAAA,CAAA,IACjBF,MAAS,4BACRG,GAAgB,CAAA,CAAA,sBAEhBC,GAAe,CAAA,CAAA,GAIlBC,IAAiBC;AAAA,EAC1B,CACI;AAAA,IACI,MAAAC;AAAA,IACA,WAAAC;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,KAEJC,MACC;AACD,UAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA4B,GAChE,CAACC,GAAgB,EAAE,eAAAC,EAAA,CAAe,IAAIC,EAAa,EAAE,UAAU,IAAM,QAAQ,UAAW,CAAA,GACxF,CAACC,GAAY,EAAE,SAASC,GAAe,SAAAC,EAAS,CAAA,IAAIC;AAE1D,IAAAC,EAAU,MAAM;AACZ,MAAIN,KACWE,EAAAF,EAAc,CAAC,CAAC;AAAA,IAC/B,GAED,CAACA,CAAa,CAAC,GAElBM,EAAU,MAAM;AACZ,MAAIF,KACoBX,EAAAU,EAAc,CAAC,CAAC;AAAA,IACxC,GAED,CAACC,GAASD,CAAa,CAAC;AAErB,UA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AAAa,EAAA,OAAA,EAAI,WAAU,WACX,UAAA,gBAAAA,EAACe,IAAe,CAAA,GACpB;AAAA,4BAER;AAAA,0BACJ;AAAA,wBACJ;AAAA,sBACJ;AAAA,oBAAA;AAAA,kBACJ;AAAA,gBAAA;AAAA,cAAA,GAER;AAAA,YAAA;AAAA,UACJ;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIhB;AACJ;AAEA1C,EAAe,cAAc;AAEhB,MAAA2C,KAAyB,CAACC,MAAuC;AACpE,QAAA,EAAE,YAAAC,GAAY,WAAAC,GAAW,YAAAC,GAAY,WAAAC,GAAW,YAAAC,GAAY,YAAA5C,MAAe6C,EAAY;AAAA,IACzF,IAAIN,EAAM,KAAK;AAAA,EAAA,CAClB,GAEKxC,IAAiB;AAAA,IACnB,WAAW4C,IAAY,aAAaA,EAAU,CAAC,OAAOA,EAAU,CAAC,QAAQ;AAAA,IACzE,YAAAC;AAAA,IACA,QAAQ5C,IAAa,IAAI;AAAA,EAAA,GAGvB8C,IAAiB,EAAE,GAAGN,GAAY,GAAGC,EAAU;AAGjD,SAAA,gBAAAnB;AAAA,IAAC3B;AAAA,IAAA;AAAA,MACG,KAAK+C;AAAA,MACL,YAAA1C;AAAA,MACA,gBAAAD;AAAA,MACA,gBAAA+C;AAAA,MACC,GAAGP;AAAA,IAAA;AAAA,EAAA;AAGhB;"}
@@ -1,142 +1,142 @@
1
1
  import { jsx as n, jsxs as y } from "react/jsx-runtime";
2
2
  import { useState as d, useEffect as w } from "react";
3
- import { useSensors as X, useSensor as U, PointerSensor as Y, KeyboardSensor as Z, DndContext as _, closestCenter as $, DragOverlay as tt } from "@dnd-kit/core";
4
- import { restrictToWindowEdges as et } from "@dnd-kit/modifiers";
5
- import { SortableContext as ot, rectSortingStrategy as nt, arrayMove as st } from "@dnd-kit/sortable";
6
- import { useEditorState as it, useAssetUpload as lt } from "@frontify/app-bridge";
7
- import { LegacyTooltip as dt, TooltipPosition as at, Flyout as rt, FlyoutPlacement as ct, AssetInput as ut, AssetInputSize as ht } from "@frontify/fondue";
8
- import { SortableAttachmentItem as mt, AttachmentItem as gt } from "./AttachmentItem.es.js";
9
- import { AttachmentsButtonTrigger as pt } from "./AttachmentsButtonTrigger.es.js";
10
- const Dt = ({
3
+ import { useSensors as Z, useSensor as T, PointerSensor as _, KeyboardSensor as $, DndContext as tt, closestCenter as et, DragOverlay as ot } from "@dnd-kit/core";
4
+ import { restrictToWindowEdges as nt } from "@dnd-kit/modifiers";
5
+ import { SortableContext as st, rectSortingStrategy as it, arrayMove as dt } from "@dnd-kit/sortable";
6
+ import { useEditorState as at, useAssetChooser as lt, useAssetUpload as rt } from "@frontify/app-bridge";
7
+ import { LegacyTooltip as ct, TooltipPosition as ut, Flyout as gt, FlyoutPlacement as pt, AssetInput as ht, AssetInputSize as mt } from "@frontify/fondue";
8
+ import { SortableAttachmentItem as ft, AttachmentItem as yt } from "./AttachmentItem.es.js";
9
+ import { AttachmentsButtonTrigger as wt } from "./AttachmentsButtonTrigger.es.js";
10
+ const Et = ({
11
11
  items: a = [],
12
- onDelete: A,
13
- onReplaceWithBrowse: W,
14
- onReplaceWithUpload: T,
15
- onBrowse: N,
16
- onUpload: P,
17
- onSorted: R,
18
- appBridge: i,
19
- triggerComponent: j = pt,
20
- isOpen: I,
21
- onOpenChange: k
12
+ onDelete: I,
13
+ onReplaceWithBrowse: N,
14
+ onReplaceWithUpload: P,
15
+ onBrowse: R,
16
+ onUpload: B,
17
+ onSorted: j,
18
+ appBridge: g,
19
+ triggerComponent: k = wt,
20
+ isOpen: A,
21
+ onOpenChange: z
22
22
  }) => {
23
- const [o, S] = d(a), [z, V] = d(!1), K = X(U(Y), U(Z)), [v, x] = d(void 0), [C, m] = d(!1), [r, u] = d([]), [g, M] = d(null), h = it(i), D = I !== void 0, p = D ? I : z, l = o == null ? void 0 : o.find((t) => t.id === v), [q, { results: b, doneAll: F }] = lt({
24
- onUploadProgress: () => !C && m(!0)
25
- }), c = (t) => {
26
- const e = D ? k : V;
23
+ const [o, S] = d(a), [V, K] = d(!1), M = Z(T(_), T($)), [v, x] = d(void 0), [C, p] = d(!1), [l, c] = d([]), [h, q] = d(null), u = at(g), { openAssetChooser: D, closeAssetChooser: b } = lt(g), F = A !== void 0, m = F ? A : V, i = o == null ? void 0 : o.find((t) => t.id === v), [G, { results: E, doneAll: L }] = rt({
24
+ onUploadProgress: () => !C && p(!0)
25
+ }), r = (t) => {
26
+ const e = F ? z : K;
27
27
  e == null || e(t);
28
28
  };
29
29
  w(() => {
30
30
  S(a);
31
31
  }, [a]), w(() => {
32
- g && (m(!0), q(g));
33
- }, [g]), w(() => {
32
+ h && (p(!0), G(h));
33
+ }, [h]), w(() => {
34
34
  (async () => {
35
- F && (await P(b), m(!1));
35
+ L && (await B(E), p(!1));
36
36
  })();
37
- }, [F, b]);
38
- const B = () => {
39
- c(!1), i.openAssetChooser(
37
+ }, [L, E]);
38
+ const H = () => {
39
+ r(!1), D(
40
40
  (t) => {
41
- N(t), i.closeAssetChooser(), c(!0);
41
+ R(t), b(), r(!0);
42
42
  },
43
43
  {
44
44
  multiSelection: !0,
45
45
  selectedValueIds: o.map((t) => t.id)
46
46
  }
47
47
  );
48
- }, E = (t) => {
49
- c(!1), i.openAssetChooser(
48
+ }, O = (t) => {
49
+ r(!1), D(
50
50
  async (e) => {
51
- c(!0), i.closeAssetChooser(), u([...r, t.id]), await W(t, e[0]), u(r.filter((s) => s !== t.id));
51
+ r(!0), b(), c([...l, t.id]), await N(t, e[0]), c(l.filter((s) => s !== t.id));
52
52
  },
53
53
  {
54
54
  multiSelection: !1,
55
55
  selectedValueIds: o.map((e) => e.id)
56
56
  }
57
57
  );
58
- }, L = async (t, e) => {
59
- u([...r, t.id]), await T(t, e), u(r.filter((s) => s !== t.id));
60
- }, G = (t) => {
58
+ }, U = async (t, e) => {
59
+ c([...l, t.id]), await P(t, e), c(l.filter((s) => s !== t.id));
60
+ }, J = (t) => {
61
61
  const { active: e } = t;
62
62
  x(e.id);
63
- }, H = (t) => {
63
+ }, Q = (t) => {
64
64
  const { active: e, over: s } = t;
65
65
  if (s && e.id !== s.id && o) {
66
- const J = o.findIndex((f) => f.id === e.id), Q = o.findIndex((f) => f.id === s.id), O = st(o, J, Q);
67
- S(O), R(O);
66
+ const X = o.findIndex((f) => f.id === e.id), Y = o.findIndex((f) => f.id === s.id), W = dt(o, X, Y);
67
+ S(W), j(W);
68
68
  }
69
69
  x(void 0);
70
70
  };
71
- return h || ((o == null ? void 0 : o.length) ?? 0) > 0 ? /* @__PURE__ */ n(
72
- dt,
71
+ return u || ((o == null ? void 0 : o.length) ?? 0) > 0 ? /* @__PURE__ */ n(
72
+ ct,
73
73
  {
74
74
  withArrow: !0,
75
- position: at.Top,
75
+ position: ut.Top,
76
76
  content: "Attachments",
77
- disabled: p,
77
+ disabled: m,
78
78
  enterDelay: 500,
79
79
  triggerElement: /* @__PURE__ */ n("div", { "data-test-id": "attachments-flyout-button", children: /* @__PURE__ */ n(
80
- rt,
80
+ gt,
81
81
  {
82
- placement: ct.BottomRight,
83
- onOpenChange: (t) => c(l ? !0 : t),
84
- isOpen: p,
82
+ placement: pt.BottomRight,
83
+ onOpenChange: (t) => r(i ? !0 : t),
84
+ isOpen: m,
85
85
  hug: !1,
86
86
  fitContent: !0,
87
87
  legacyFooter: !1,
88
- trigger: /* @__PURE__ */ n(j, { isFlyoutOpen: p, children: /* @__PURE__ */ n("div", { children: a.length > 0 ? a.length : "Add" }) }),
88
+ trigger: /* @__PURE__ */ n(k, { isFlyoutOpen: m, children: /* @__PURE__ */ n("div", { children: a.length > 0 ? a.length : "Add" }) }),
89
89
  children: /* @__PURE__ */ y("div", { className: "tw-w-[300px]", "data-test-id": "attachments-flyout-content", children: [
90
90
  o.length > 0 && /* @__PURE__ */ y(
91
- _,
91
+ tt,
92
92
  {
93
- sensors: K,
94
- collisionDetection: $,
95
- onDragStart: G,
96
- onDragEnd: H,
97
- modifiers: [et],
93
+ sensors: M,
94
+ collisionDetection: et,
95
+ onDragStart: J,
96
+ onDragEnd: Q,
97
+ modifiers: [nt],
98
98
  children: [
99
- /* @__PURE__ */ n(ot, { items: o, strategy: nt, children: /* @__PURE__ */ n("div", { className: "tw-border-b tw-border-b-line", children: o.map((t) => /* @__PURE__ */ n(
100
- mt,
99
+ /* @__PURE__ */ n(st, { items: o, strategy: it, children: /* @__PURE__ */ n("div", { className: "tw-border-b tw-border-b-line", children: o.map((t) => /* @__PURE__ */ n(
100
+ ft,
101
101
  {
102
- isEditing: h,
103
- isLoading: r.includes(t.id),
102
+ isEditing: u,
103
+ isLoading: l.includes(t.id),
104
104
  item: t,
105
- onDelete: () => A(t),
106
- onReplaceWithBrowse: () => E(t),
107
- onReplaceWithUpload: (e) => L(t, e),
108
- onDownload: () => i.dispatch({
105
+ onDelete: () => I(t),
106
+ onReplaceWithBrowse: () => O(t),
107
+ onReplaceWithUpload: (e) => U(t, e),
108
+ onDownload: () => g.dispatch({
109
109
  name: "downloadAsset",
110
110
  payload: t
111
111
  })
112
112
  },
113
113
  t.id
114
114
  )) }) }),
115
- /* @__PURE__ */ n(tt, { children: l && /* @__PURE__ */ n(
116
- gt,
115
+ /* @__PURE__ */ n(ot, { children: i && /* @__PURE__ */ n(
116
+ yt,
117
117
  {
118
118
  isOverlay: !0,
119
- isEditing: h,
120
- item: l,
119
+ isEditing: u,
120
+ item: i,
121
121
  isDragging: !0,
122
- onDelete: () => A(l),
123
- onReplaceWithBrowse: () => E(l),
124
- onReplaceWithUpload: (t) => L(l, t)
122
+ onDelete: () => I(i),
123
+ onReplaceWithBrowse: () => O(i),
124
+ onReplaceWithUpload: (t) => U(i, t)
125
125
  },
126
126
  v
127
127
  ) })
128
128
  ]
129
129
  }
130
130
  ),
131
- h && /* @__PURE__ */ y("div", { className: "tw-px-5 tw-py-3", children: [
131
+ u && /* @__PURE__ */ y("div", { className: "tw-px-5 tw-py-3", children: [
132
132
  /* @__PURE__ */ n("div", { className: "tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4", children: "Add attachments" }),
133
133
  /* @__PURE__ */ n(
134
- ut,
134
+ ht,
135
135
  {
136
136
  isLoading: C,
137
- size: ht.Small,
138
- onUploadClick: (t) => M(t),
139
- onLibraryClick: B
137
+ size: mt.Small,
138
+ onUploadClick: (t) => q(t),
139
+ onLibraryClick: H
140
140
  }
141
141
  )
142
142
  ] })
@@ -147,6 +147,6 @@ const Dt = ({
147
147
  ) : null;
148
148
  };
149
149
  export {
150
- Dt as Attachments
150
+ Et as Attachments
151
151
  };
152
152
  //# sourceMappingURL=Attachments.es.js.map