@webiny/admin-ui 0.0.0-unstable.9f53ea597d → 0.0.0-unstable.a4f3e4ea8b
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/DataTable/DataTable.js +6 -3
- package/DataTable/DataTable.js.map +1 -1
- package/DataTable/components/ColumnsVisibility.js +1 -0
- package/DataTable/components/ColumnsVisibility.js.map +1 -1
- package/DatePicker/DatePicker.d.ts +5 -2
- package/DatePicker/DatePicker.js +10 -2
- package/DatePicker/DatePicker.js.map +1 -1
- package/DatePicker/primitives/DateTimePicker.js +9 -14
- package/DatePicker/primitives/DateTimePicker.js.map +1 -1
- package/DatePicker/utils/dateHelpers.d.ts +1 -1
- package/DatePicker/utils/dateHelpers.js +2 -1
- package/DatePicker/utils/dateHelpers.js.map +1 -1
- package/DatePicker/utils/timezoneHelpers.d.ts +3 -0
- package/DatePicker/utils/timezoneHelpers.js +32 -0
- package/DatePicker/utils/timezoneHelpers.js.map +1 -0
- package/DropdownMenu/components/DropdownMenuItem.d.ts +5 -0
- package/DropdownMenu/components/DropdownMenuItem.js +3 -2
- package/DropdownMenu/components/DropdownMenuItem.js.map +1 -1
- package/FilePicker/primitives/components/previews/ItemActions.js +1 -1
- package/FilePicker/primitives/components/previews/ItemActions.js.map +1 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/FileType.d.ts +5 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/FileType.js +45 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/FileType.js.map +1 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.d.ts +5 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.js +14 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.js.map +1 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js +52 -11
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js.map +1 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.d.ts +5 -4
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js +9 -66
- package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js.map +1 -1
- package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.d.ts +11 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js +24 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js.map +1 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.d.ts +10 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js +46 -0
- package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js.map +1 -0
- package/FilePicker/primitives/components/previews/TruncatedFileName.d.ts +7 -0
- package/FilePicker/primitives/components/previews/TruncatedFileName.js +20 -0
- package/FilePicker/primitives/components/previews/TruncatedFileName.js.map +1 -0
- package/FilePicker/primitives/components/previews/fileName.d.ts +4 -0
- package/FilePicker/primitives/components/previews/fileName.js +26 -0
- package/FilePicker/primitives/components/previews/fileName.js.map +1 -0
- package/FilePicker/primitives/components/previews/index.d.ts +1 -0
- package/FilePicker/primitives/components/previews/index.js +1 -0
- package/Link/Link.d.ts +1 -1
- package/Link/Link.js +1 -1
- package/Link/Link.js.map +1 -1
- package/Sidebar/components/SidebarContent.js +1 -1
- package/Sidebar/components/SidebarContent.js.map +1 -1
- package/Sidebar/components/SidebarRoot.js +1 -1
- package/Sidebar/components/SidebarRoot.js.map +1 -1
- package/Sidebar/components/items/SidebarMenuSubButton.js +8 -5
- package/Sidebar/components/items/SidebarMenuSubButton.js.map +1 -1
- package/Sidebar/components/items/SidebarMenuSubItem.js +3 -3
- package/Sidebar/components/items/SidebarMenuSubItem.js.map +1 -1
- package/Tree/useTree.js +6 -2
- package/Tree/useTree.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePicker/primitives/components/previews/ItemActions.js","sources":["../../../../../src/FilePicker/primitives/components/previews/ItemActions.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as ReplaceIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as TrashIcon } from \"@webiny/icons/delete.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { cn } from \"~/utils.js\";\n\ninterface ItemActionsProps extends React.HTMLAttributes<HTMLDivElement> {\n onRemoveItem?: () => void;\n onEditItem?: () => void;\n onReplaceItem?: () => void;\n disabled?: boolean;\n small?: boolean;\n}\n\nconst ItemActions = ({\n disabled,\n onRemoveItem,\n onEditItem,\n onReplaceItem,\n small,\n className,\n ...props\n}: ItemActionsProps) => {\n const iconSize = small ? \"default\" : \"lg\";\n const buttonSize = small ? \"xs\" : \"sm\";\n\n return (\n <div {...props} className={cn(\"flex justify-center items-center gap-xs\", className)}>\n {
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/ItemActions.js","sources":["../../../../../src/FilePicker/primitives/components/previews/ItemActions.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as ReplaceIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as TrashIcon } from \"@webiny/icons/delete.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { cn } from \"~/utils.js\";\n\ninterface ItemActionsProps extends React.HTMLAttributes<HTMLDivElement> {\n onRemoveItem?: () => void;\n onEditItem?: () => void;\n onReplaceItem?: () => void;\n disabled?: boolean;\n small?: boolean;\n}\n\nconst ItemActions = ({\n disabled,\n onRemoveItem,\n onEditItem,\n onReplaceItem,\n small,\n className,\n ...props\n}: ItemActionsProps) => {\n const iconSize = small ? \"default\" : \"lg\";\n const buttonSize = small ? \"xs\" : \"sm\";\n\n return (\n <div {...props} className={cn(\"flex justify-center items-center gap-xs\", className)}>\n {onReplaceItem && (\n <IconButton\n icon={\n <Icon\n icon={<ReplaceIcon />}\n label={\"Replace\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onReplaceItem}\n disabled={disabled}\n />\n )}\n\n {onEditItem && (\n <IconButton\n icon={\n <Icon\n icon={<EditIcon />}\n label={\"Edit\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onEditItem}\n disabled={disabled}\n />\n )}\n\n {onRemoveItem && (\n <IconButton\n icon={\n <Icon\n icon={<TrashIcon />}\n label={\"Remove\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onRemoveItem}\n disabled={disabled}\n />\n )}\n </div>\n );\n};\n\nexport { ItemActions, type ItemActionsProps };\n"],"names":["ItemActions","disabled","onRemoveItem","onEditItem","onReplaceItem","small","className","props","iconSize","buttonSize","cn","IconButton","Icon","ReplaceIcon","EditIcon","TrashIcon"],"mappings":";;;;;;;AAgBA,MAAMA,cAAc,CAAC,EACjBC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,aAAa,EACbC,KAAK,EACLC,SAAS,EACT,GAAGC,OACY;IACf,MAAMC,WAAWH,QAAQ,YAAY;IACrC,MAAMI,aAAaJ,QAAQ,OAAO;IAElC,OAAO,WAAP,GACI,oBAAC;QAAK,GAAGE,KAAK;QAAE,WAAWG,GAAG,2CAA2CJ;OACpEF,iBAAiB,WAAjBA,GACG,oBAACO,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACC,gBAAWA;YAClB,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAMJ;QACN,UAAUD;QACV,SAASJ;QACT,UAAUH;QAIjBE,cAAc,WAAdA,GACG,oBAACQ,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACE,yBAAQA;YACf,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAML;QACN,UAAUD;QACV,SAASL;QACT,UAAUF;QAIjBC,gBAAgB,WAAhBA,GACG,oBAACS,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACG,2BAASA;YAChB,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAMN;QACN,UAAUD;QACV,SAASN;QACT,UAAUD;;AAK9B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { FileItemFormatted } from "../../../../../FilePicker/index.js";
|
|
3
|
+
type FileTypeProps = Pick<FileItemFormatted, "mimeType" | "name">;
|
|
4
|
+
declare const FileType: ({ mimeType, name }: FileTypeProps) => React.JSX.Element;
|
|
5
|
+
export { FileType, type FileTypeProps };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import csv from "../assets/csv.js";
|
|
3
|
+
import doc from "../assets/doc.js";
|
|
4
|
+
import docx from "../assets/docx.js";
|
|
5
|
+
import file from "../assets/file.js";
|
|
6
|
+
import pdf from "../assets/pdf.js";
|
|
7
|
+
import ppt from "../assets/ppt.js";
|
|
8
|
+
import pptx from "../assets/pptx.js";
|
|
9
|
+
import txt from "../assets/txt.js";
|
|
10
|
+
import xls from "../assets/xls.js";
|
|
11
|
+
import xlsx from "../assets/xlsx.js";
|
|
12
|
+
const FileType = ({ mimeType = "", name })=>{
|
|
13
|
+
const getMimeTypeSrc = (mimeType)=>{
|
|
14
|
+
switch(mimeType){
|
|
15
|
+
case "text/csv":
|
|
16
|
+
return csv;
|
|
17
|
+
case "application/msword":
|
|
18
|
+
return doc;
|
|
19
|
+
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
|
20
|
+
return docx;
|
|
21
|
+
case "application/pdf":
|
|
22
|
+
return pdf;
|
|
23
|
+
case "application/vnd.ms-powerpoint":
|
|
24
|
+
return ppt;
|
|
25
|
+
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
|
26
|
+
return pptx;
|
|
27
|
+
case "text/plain":
|
|
28
|
+
return txt;
|
|
29
|
+
case "application/vnd.ms-excel":
|
|
30
|
+
return xls;
|
|
31
|
+
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
|
32
|
+
return xlsx;
|
|
33
|
+
default:
|
|
34
|
+
return file;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/ react.createElement("img", {
|
|
38
|
+
src: getMimeTypeSrc(mimeType),
|
|
39
|
+
alt: name,
|
|
40
|
+
className: "size-full object-contain p-sm-extra"
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export { FileType };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=FileType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/FileType.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/FileType.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\n\nimport csvThumb from \"../assets/csv.svg\";\nimport docThumb from \"../assets/doc.svg\";\nimport docxThumb from \"../assets/docx.svg\";\nimport fileThumb from \"../assets/file.svg\";\nimport pdfThumb from \"../assets/pdf.svg\";\nimport pptThumb from \"../assets/ppt.svg\";\nimport pptxThumb from \"../assets/pptx.svg\";\nimport txtThumb from \"../assets/txt.svg\";\nimport xlsThumb from \"../assets/xls.svg\";\nimport xlsxThumb from \"../assets/xlsx.svg\";\n\ntype FileTypeProps = Pick<FileItemFormatted, \"mimeType\" | \"name\">;\n\nconst FileType = ({ mimeType = \"\", name }: FileTypeProps) => {\n const getMimeTypeSrc = (mimeType: string) => {\n switch (mimeType) {\n case \"text/csv\": // .csv\n return csvThumb;\n case \"application/msword\": // .doc\n return docThumb;\n case \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": // .docx\n return docxThumb;\n case \"application/pdf\": // .pdf\n return pdfThumb;\n case \"application/vnd.ms-powerpoint\": // .ppt\n return pptThumb;\n case \"application/vnd.openxmlformats-officedocument.presentationml.presentation\": // .pptx\n return pptxThumb;\n case \"text/plain\": // .txt\n return txtThumb;\n case \"application/vnd.ms-excel\": // .xls\n return xlsThumb;\n case \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": // .xlsx\n return xlsxThumb;\n default:\n return fileThumb;\n }\n };\n\n return (\n <img\n src={getMimeTypeSrc(mimeType)}\n alt={name}\n className=\"size-full object-contain p-sm-extra\"\n />\n );\n};\n\nexport { FileType, type FileTypeProps };\n"],"names":["FileType","mimeType","name","getMimeTypeSrc","csvThumb","docThumb","docxThumb","pdfThumb","pptThumb","pptxThumb","txtThumb","xlsThumb","xlsxThumb","fileThumb"],"mappings":";;;;;;;;;;;AAgBA,MAAMA,WAAW,CAAC,EAAEC,WAAW,EAAE,EAAEC,IAAI,EAAiB;IACpD,MAAMC,iBAAiB,CAACF;QACpB,OAAQA;YACJ,KAAK;gBACD,OAAOG;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX;gBACI,OAAOC;QACf;IACJ;IAEA,OAAO,WAAP,GACI,oBAAC;QACG,KAAKV,eAAeF;QACpB,KAAKC;QACL,WAAU;;AAGtB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { FileItemFormatted } from "../../../../../FilePicker/index.js";
|
|
3
|
+
type PlaceholderProps = Pick<FileItemFormatted, "name">;
|
|
4
|
+
declare const Placeholder: ({ name }: PlaceholderProps) => React.JSX.Element;
|
|
5
|
+
export { Placeholder, type PlaceholderProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { ReactComponent } from "@webiny/icons/image.svg";
|
|
3
|
+
import { Icon } from "../../../../../Icon/index.js";
|
|
4
|
+
const Placeholder = ({ name })=>/*#__PURE__*/ react.createElement("div", {
|
|
5
|
+
className: "size-full flex justify-center items-center bg-transparent"
|
|
6
|
+
}, /*#__PURE__*/ react.createElement(Icon, {
|
|
7
|
+
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
8
|
+
label: name,
|
|
9
|
+
size: "lg",
|
|
10
|
+
color: "neutral-light"
|
|
11
|
+
}));
|
|
12
|
+
export { Placeholder };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=Placeholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/Placeholder.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as PlaceholderIcon } from \"@webiny/icons/image.svg\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\n\ntype PlaceholderProps = Pick<FileItemFormatted, \"name\">;\n\nconst Placeholder = ({ name }: PlaceholderProps) => {\n return (\n <div className={\"size-full flex justify-center items-center bg-transparent\"}>\n <Icon icon={<PlaceholderIcon />} label={name} size={\"lg\"} color={\"neutral-light\"} />\n </div>\n );\n};\n\nexport { Placeholder, type PlaceholderProps };\n"],"names":["Placeholder","name","Icon","PlaceholderIcon"],"mappings":";;;AAOA,MAAMA,cAAc,CAAC,EAAEC,IAAI,EAAoB,GACpC,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACC,MAAIA;QAAC,oBAAM,oBAACC,gBAAeA;QAAK,OAAOF;QAAM,MAAM;QAAM,OAAO"}
|
|
@@ -1,37 +1,78 @@
|
|
|
1
1
|
import react from "react";
|
|
2
|
+
import bytes from "bytes";
|
|
2
3
|
import { cn, makeDecoratable } from "../../../../../utils.js";
|
|
4
|
+
import { Text } from "../../../../../Text/index.js";
|
|
3
5
|
import { RichItemThumbnail } from "./RichItemThumbnail.js";
|
|
6
|
+
import { ThumbnailActions } from "./ThumbnailActions.js";
|
|
4
7
|
import { ItemDescription } from "../ItemDescription.js";
|
|
5
8
|
import { ItemActions } from "../ItemActions.js";
|
|
9
|
+
import { TruncatedFileName } from "../TruncatedFileName.js";
|
|
6
10
|
import { previewVariants } from "../variants.js";
|
|
7
|
-
const DecoratableRichItemPreview = ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props })
|
|
11
|
+
const DecoratableRichItemPreview = ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props })=>{
|
|
12
|
+
const actions = {
|
|
13
|
+
onRemoveItem,
|
|
14
|
+
onReplaceItem,
|
|
15
|
+
onEditItem,
|
|
16
|
+
disabled
|
|
17
|
+
};
|
|
18
|
+
const formattedSize = value.size ? bytes.format(value.size, {
|
|
19
|
+
unitSeparator: " ",
|
|
20
|
+
decimalPlaces: 0
|
|
21
|
+
}) : "";
|
|
22
|
+
const details = [
|
|
23
|
+
value.mimeType,
|
|
24
|
+
formattedSize
|
|
25
|
+
].filter(Boolean).join(" - ");
|
|
26
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
8
27
|
"data-testid": "image-preview",
|
|
9
|
-
className: cn("w-full rounded-md", previewVariants({
|
|
28
|
+
className: cn("w-full rounded-md @container", previewVariants({
|
|
10
29
|
variant,
|
|
11
30
|
disabled
|
|
12
31
|
}), className),
|
|
13
32
|
...props
|
|
14
33
|
}, /*#__PURE__*/ react.createElement("div", {
|
|
15
34
|
"data-role": "select-image",
|
|
16
|
-
className: "
|
|
35
|
+
className: "@min-[280px]:hidden"
|
|
17
36
|
}, /*#__PURE__*/ react.createElement("div", {
|
|
18
|
-
className: "flex
|
|
37
|
+
className: "flex flex-col gap-xs p-xs"
|
|
38
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
39
|
+
className: "group relative cursor-pointer",
|
|
40
|
+
onClick: onReplaceItem
|
|
41
|
+
}, /*#__PURE__*/ react.createElement(RichItemThumbnail, {
|
|
42
|
+
...value,
|
|
43
|
+
variant: "banner",
|
|
44
|
+
disabled: disabled,
|
|
45
|
+
preview: preview,
|
|
46
|
+
renderImage: renderImage
|
|
47
|
+
}), /*#__PURE__*/ react.createElement(ThumbnailActions, actions)), /*#__PURE__*/ react.createElement("div", {
|
|
48
|
+
className: "flex flex-col gap-xxs min-w-0 px-xxs pb-xxs"
|
|
49
|
+
}, /*#__PURE__*/ react.createElement(TruncatedFileName, {
|
|
50
|
+
name: value.name,
|
|
51
|
+
className: disabled ? "text-neutral-disabled" : "text-neutral-primary"
|
|
52
|
+
}), details ? /*#__PURE__*/ react.createElement(Text, {
|
|
53
|
+
size: "sm",
|
|
54
|
+
className: cn("truncate", disabled ? "text-neutral-disabled" : "text-neutral-muted")
|
|
55
|
+
}, details) : null))), /*#__PURE__*/ react.createElement("div", {
|
|
56
|
+
"data-role": "select-image",
|
|
57
|
+
className: "hidden @min-[280px]:flex items-center gap-sm-extra min-w-0"
|
|
58
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
59
|
+
className: "shrink-0 cursor-pointer",
|
|
19
60
|
onClick: onReplaceItem
|
|
20
61
|
}, /*#__PURE__*/ react.createElement(RichItemThumbnail, {
|
|
21
62
|
...value,
|
|
22
63
|
disabled: disabled,
|
|
23
64
|
preview: preview,
|
|
24
65
|
renderImage: renderImage
|
|
25
|
-
}), /*#__PURE__*/ react.createElement(ItemDescription, {
|
|
66
|
+
})), /*#__PURE__*/ react.createElement(ItemDescription, {
|
|
26
67
|
item: value,
|
|
27
|
-
disabled: disabled
|
|
28
|
-
})), /*#__PURE__*/ react.createElement(ItemActions, {
|
|
29
|
-
onRemoveItem: onRemoveItem,
|
|
30
|
-
onReplaceItem: onReplaceItem,
|
|
31
|
-
onEditItem: onEditItem,
|
|
32
68
|
disabled: disabled,
|
|
33
|
-
|
|
69
|
+
onClick: onReplaceItem,
|
|
70
|
+
className: "grow basis-0 cursor-pointer"
|
|
71
|
+
}), /*#__PURE__*/ react.createElement(ItemActions, {
|
|
72
|
+
...actions,
|
|
73
|
+
className: "ml-auto pr-sm-extra"
|
|
34
74
|
})));
|
|
75
|
+
};
|
|
35
76
|
const RichItemPreview = makeDecoratable("RichItemPreview", DecoratableRichItemPreview);
|
|
36
77
|
export { RichItemPreview };
|
|
37
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn, makeDecoratable } from \"~/utils.js\";\nimport { RichItemThumbnail } from \"./RichItemThumbnail.js\";\nimport { ItemDescription } from \"../ItemDescription.js\";\nimport { ItemActions } from \"~/FilePicker/primitives/components/previews/ItemActions.js\";\nimport { previewVariants } from \"../variants.js\";\nimport type { FilePreviewDefaultProps } from \"../../types.js\";\n\ntype RichItemPreviewProps = FilePreviewDefaultProps & {\n preview?: \"thumbnail\" | \"file-type\" | \"placeholder\";\n /** Optional custom image renderer for the thumbnail (e.g. a cropped preview). */\n renderImage?: (args: { url: string; name: string }) => React.ReactNode;\n};\n\nconst DecoratableRichItemPreview = ({\n className,\n disabled,\n onRemoveItem,\n onReplaceItem,\n onEditItem,\n value,\n variant,\n preview,\n renderImage,\n ...props\n}: RichItemPreviewProps) => {\n return (\n <div\n data-testid=\"image-preview\"\n className={cn(\"w-full rounded-md\"
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport { cn, makeDecoratable } from \"~/utils.js\";\nimport { Text } from \"~/Text/index.js\";\nimport { RichItemThumbnail } from \"./RichItemThumbnail.js\";\nimport { ThumbnailActions } from \"./ThumbnailActions.js\";\nimport { ItemDescription } from \"../ItemDescription.js\";\nimport { ItemActions } from \"~/FilePicker/primitives/components/previews/ItemActions.js\";\nimport { TruncatedFileName } from \"../TruncatedFileName.js\";\nimport { previewVariants } from \"../variants.js\";\nimport type { FilePreviewDefaultProps } from \"../../types.js\";\n\ntype RichItemPreviewProps = FilePreviewDefaultProps & {\n preview?: \"thumbnail\" | \"file-type\" | \"placeholder\";\n /** Optional custom image renderer for the thumbnail (e.g. a cropped preview). */\n renderImage?: (args: { url: string; name: string }) => React.ReactNode;\n};\n\nconst DecoratableRichItemPreview = ({\n className,\n disabled,\n onRemoveItem,\n onReplaceItem,\n onEditItem,\n value,\n variant,\n preview,\n renderImage,\n ...props\n}: RichItemPreviewProps) => {\n const actions = { onRemoveItem, onReplaceItem, onEditItem, disabled };\n\n const formattedSize = value.size\n ? bytes.format(value.size, { unitSeparator: \" \", decimalPlaces: 0 })\n : \"\";\n const details = [value.mimeType, formattedSize].filter(Boolean).join(\" - \");\n\n return (\n <div\n data-testid=\"image-preview\"\n className={cn(\n \"w-full rounded-md @container\",\n previewVariants({ variant, disabled }),\n className\n )}\n {...props}\n >\n {/* Stacked layout for narrow containers (below 280px). */}\n <div data-role=\"select-image\" className={\"@min-[280px]:hidden\"}>\n <div className={\"flex flex-col gap-xs p-xs\"}>\n <div className={\"group relative cursor-pointer\"} onClick={onReplaceItem}>\n <RichItemThumbnail\n {...value}\n variant={\"banner\"}\n disabled={disabled}\n preview={preview}\n renderImage={renderImage}\n />\n <ThumbnailActions {...actions} />\n </div>\n\n <div className={\"flex flex-col gap-xxs min-w-0 px-xxs pb-xxs\"}>\n <TruncatedFileName\n name={value.name}\n className={disabled ? \"text-neutral-disabled\" : \"text-neutral-primary\"}\n />\n {details ? (\n <Text\n size=\"sm\"\n className={cn(\n \"truncate\",\n disabled ? \"text-neutral-disabled\" : \"text-neutral-muted\"\n )}\n >\n {details}\n </Text>\n ) : null}\n </div>\n </div>\n </div>\n\n {/* Side-by-side layout for wider containers (280px+). */}\n <div\n data-role=\"select-image\"\n className={\"hidden @min-[280px]:flex items-center gap-sm-extra min-w-0\"}\n >\n <div className={\"shrink-0 cursor-pointer\"} onClick={onReplaceItem}>\n <RichItemThumbnail\n {...value}\n disabled={disabled}\n preview={preview}\n renderImage={renderImage}\n />\n </div>\n\n <ItemDescription\n item={value}\n disabled={disabled}\n onClick={onReplaceItem}\n className={\"grow basis-0 cursor-pointer\"}\n />\n\n <ItemActions {...actions} className={\"ml-auto pr-sm-extra\"} />\n </div>\n </div>\n );\n};\n\nconst RichItemPreview = makeDecoratable(\"RichItemPreview\", DecoratableRichItemPreview);\n\nexport { RichItemPreview, type RichItemPreviewProps };\n"],"names":["DecoratableRichItemPreview","className","disabled","onRemoveItem","onReplaceItem","onEditItem","value","variant","preview","renderImage","props","actions","formattedSize","bytes","details","Boolean","cn","previewVariants","RichItemThumbnail","ThumbnailActions","TruncatedFileName","Text","ItemDescription","ItemActions","RichItemPreview","makeDecoratable"],"mappings":";;;;;;;;;;AAkBA,MAAMA,6BAA6B,CAAC,EAChCC,SAAS,EACTC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,WAAW,EACX,GAAGC,OACgB;IACnB,MAAMC,UAAU;QAAER;QAAcC;QAAeC;QAAYH;IAAS;IAEpE,MAAMU,gBAAgBN,MAAM,IAAI,GAC1BO,MAAM,MAAM,CAACP,MAAM,IAAI,EAAE;QAAE,eAAe;QAAK,eAAe;IAAE,KAChE;IACN,MAAMQ,UAAU;QAACR,MAAM,QAAQ;QAAEM;KAAc,CAAC,MAAM,CAACG,SAAS,IAAI,CAAC;IAErE,OAAO,WAAP,GACI,oBAAC;QACG,eAAY;QACZ,WAAWC,GACP,gCACAC,gBAAgB;YAAEV;YAASL;QAAS,IACpCD;QAEH,GAAGS,KAAK;qBAGT,oBAAC;QAAI,aAAU;QAAe,WAAW;qBACrC,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;QAAiC,SAASN;qBACtD,oBAACc,mBAAiBA;QACb,GAAGZ,KAAK;QACT,SAAS;QACT,UAAUJ;QACV,SAASM;QACT,aAAaC;sBAEjB,oBAACU,kBAAqBR,WAAAA,WAAAA,GAG1B,oBAAC;QAAI,WAAW;qBACZ,oBAACS,mBAAiBA;QACd,MAAMd,MAAM,IAAI;QAChB,WAAWJ,WAAW,0BAA0B;QAEnDY,UAAU,WAAVA,GACG,oBAACO,MAAIA;QACD,MAAK;QACL,WAAWL,GACP,YACAd,WAAW,0BAA0B;OAGxCY,WAEL,uBAMhB,oBAAC;QACG,aAAU;QACV,WAAW;qBAEX,oBAAC;QAAI,WAAW;QAA2B,SAASV;qBAChD,oBAACc,mBAAiBA;QACb,GAAGZ,KAAK;QACT,UAAUJ;QACV,SAASM;QACT,aAAaC;uBAIrB,oBAACa,iBAAeA;QACZ,MAAMhB;QACN,UAAUJ;QACV,SAASE;QACT,WAAW;sBAGf,oBAACmB,aAAWA;QAAE,GAAGZ,OAAO;QAAE,WAAW;;AAIrD;AAEA,MAAMa,kBAAkBC,gBAAgB,mBAAmBzB"}
|
|
@@ -5,14 +5,15 @@ type RichItemThumbnailProps = Omit<React.HTMLAttributes<HTMLDivElement>, "childr
|
|
|
5
5
|
preview?: RichItemPreviewProps["preview"];
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* or when it returns a falsy value.
|
|
8
|
+
* `tile` is the fixed square that sits beside the file details; `banner` spans the full
|
|
9
|
+
* width of a stacked layout, where the panel is too narrow to afford a column for it.
|
|
11
10
|
*/
|
|
11
|
+
variant?: "tile" | "banner";
|
|
12
|
+
/** Optional custom image renderer for the thumbnail (e.g. a cropped preview). */
|
|
12
13
|
renderImage?: (args: {
|
|
13
14
|
url: string;
|
|
14
15
|
name: string;
|
|
15
16
|
}) => React.ReactNode;
|
|
16
17
|
};
|
|
17
|
-
declare const RichItemThumbnail: ({ url, name, className, mimeType, preview, disabled, renderImage }: RichItemThumbnailProps) => React.JSX.Element;
|
|
18
|
+
declare const RichItemThumbnail: ({ url, name, className, mimeType, preview, disabled, variant, renderImage }: RichItemThumbnailProps) => React.JSX.Element;
|
|
18
19
|
export { RichItemThumbnail, type RichItemThumbnailProps };
|
|
@@ -1,74 +1,17 @@
|
|
|
1
1
|
import react from "react";
|
|
2
|
-
import { ReactComponent } from "@webiny/icons/image.svg";
|
|
3
|
-
import { Icon } from "../../../../../Icon/index.js";
|
|
4
2
|
import { cn } from "../../../../../utils.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import pdf from "../assets/pdf.js";
|
|
10
|
-
import ppt from "../assets/ppt.js";
|
|
11
|
-
import pptx from "../assets/pptx.js";
|
|
12
|
-
import txt from "../assets/txt.js";
|
|
13
|
-
import xls from "../assets/xls.js";
|
|
14
|
-
import xlsx from "../assets/xlsx.js";
|
|
15
|
-
const Thumbnail = ({ url, name })=>/*#__PURE__*/ react.createElement("div", {
|
|
16
|
-
className: "size-full bg-neutral-muted"
|
|
17
|
-
}, /*#__PURE__*/ react.createElement("img", {
|
|
18
|
-
src: url,
|
|
19
|
-
alt: name,
|
|
20
|
-
className: "size-full object-cover"
|
|
21
|
-
}));
|
|
22
|
-
const FileType = ({ mimeType = "", name })=>{
|
|
23
|
-
const getMimeTypeSrc = (mimeType)=>{
|
|
24
|
-
switch(mimeType){
|
|
25
|
-
case "text/csv":
|
|
26
|
-
return csv;
|
|
27
|
-
case "application/msword":
|
|
28
|
-
return doc;
|
|
29
|
-
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
|
30
|
-
return docx;
|
|
31
|
-
case "application/pdf":
|
|
32
|
-
return pdf;
|
|
33
|
-
case "application/vnd.ms-powerpoint":
|
|
34
|
-
return ppt;
|
|
35
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
|
36
|
-
return pptx;
|
|
37
|
-
case "text/plain":
|
|
38
|
-
return txt;
|
|
39
|
-
case "application/vnd.ms-excel":
|
|
40
|
-
return xls;
|
|
41
|
-
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
|
42
|
-
return xlsx;
|
|
43
|
-
default:
|
|
44
|
-
return file;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
return /*#__PURE__*/ react.createElement("img", {
|
|
48
|
-
src: getMimeTypeSrc(mimeType),
|
|
49
|
-
alt: name,
|
|
50
|
-
className: "size-full p-sm-extra"
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
const Placeholder = ({ name })=>/*#__PURE__*/ react.createElement("div", {
|
|
54
|
-
className: "size-full flex justify-center items-center bg-transparent"
|
|
55
|
-
}, /*#__PURE__*/ react.createElement(Icon, {
|
|
56
|
-
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
57
|
-
label: name,
|
|
58
|
-
size: "lg",
|
|
59
|
-
color: "neutral-light"
|
|
60
|
-
}));
|
|
61
|
-
const RichItemThumbnail = ({ url, name, className, mimeType, preview, disabled, renderImage })=>{
|
|
3
|
+
import { FileType } from "./FileType.js";
|
|
4
|
+
import { Placeholder } from "./Placeholder.js";
|
|
5
|
+
import { Thumbnail } from "./Thumbnail.js";
|
|
6
|
+
const RichItemThumbnail = ({ url, name, className, mimeType, preview, disabled, variant = "tile", renderImage })=>{
|
|
62
7
|
const isImage = mimeType?.startsWith("image/");
|
|
63
|
-
const customImage = "function" == typeof renderImage ? renderImage({
|
|
64
|
-
url,
|
|
65
|
-
name
|
|
66
|
-
}) : false;
|
|
67
8
|
return /*#__PURE__*/ react.createElement("div", {
|
|
68
|
-
className: cn("
|
|
69
|
-
}, "thumbnail" === preview || isImage ?
|
|
9
|
+
className: cn("rounded-sm overflow-hidden relative", "banner" === variant ? "w-full h-[96px]" : "size-[56px] m-xs", disabled && "[&_img]:filter [&_img]:grayscale [&_img]:opacity-50", className)
|
|
10
|
+
}, "thumbnail" === preview || isImage ? /*#__PURE__*/ react.createElement(Thumbnail, {
|
|
70
11
|
url: url,
|
|
71
|
-
name: name
|
|
12
|
+
name: name,
|
|
13
|
+
fit: "banner" === variant ? "contain" : "cover",
|
|
14
|
+
renderImage: renderImage
|
|
72
15
|
}) : "placeholder" === preview ? /*#__PURE__*/ react.createElement(Placeholder, {
|
|
73
16
|
name: name
|
|
74
17
|
}) : /*#__PURE__*/ react.createElement(FileType, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.tsx"],"sourcesContent":["import React from \"react\";\nimport
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\nimport { cn } from \"~/utils.js\";\nimport type { RichItemPreviewProps } from \"~/FilePicker/primitives/components/index.js\";\nimport { FileType } from \"./FileType.js\";\nimport { Placeholder } from \"./Placeholder.js\";\nimport { Thumbnail } from \"./Thumbnail.js\";\n\ntype RichItemThumbnailProps = Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> &\n FileItemFormatted & {\n preview?: RichItemPreviewProps[\"preview\"];\n disabled?: boolean;\n /**\n * `tile` is the fixed square that sits beside the file details; `banner` spans the full\n * width of a stacked layout, where the panel is too narrow to afford a column for it.\n */\n variant?: \"tile\" | \"banner\";\n /** Optional custom image renderer for the thumbnail (e.g. a cropped preview). */\n renderImage?: (args: { url: string; name: string }) => React.ReactNode;\n };\n\nconst RichItemThumbnail = ({\n url,\n name,\n className,\n mimeType,\n preview,\n disabled,\n variant = \"tile\",\n renderImage\n}: RichItemThumbnailProps) => {\n const isImage = mimeType?.startsWith(\"image/\");\n\n return (\n <div\n className={cn(\n \"rounded-sm overflow-hidden relative\",\n variant === \"banner\" ? \"w-full h-[96px]\" : \"size-[56px] m-xs\",\n disabled && \"[&_img]:filter [&_img]:grayscale [&_img]:opacity-50\",\n className\n )}\n >\n {preview === \"thumbnail\" || isImage ? (\n <Thumbnail\n url={url}\n name={name}\n fit={variant === \"banner\" ? \"contain\" : \"cover\"}\n renderImage={renderImage}\n />\n ) : preview === \"placeholder\" ? (\n <Placeholder name={name} />\n ) : (\n <FileType mimeType={mimeType} name={name} />\n )}\n </div>\n );\n};\n\nexport { RichItemThumbnail, type RichItemThumbnailProps };\n"],"names":["RichItemThumbnail","url","name","className","mimeType","preview","disabled","variant","renderImage","isImage","cn","Thumbnail","Placeholder","FileType"],"mappings":";;;;;AAqBA,MAAMA,oBAAoB,CAAC,EACvBC,GAAG,EACHC,IAAI,EACJC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,QAAQ,EACRC,UAAU,MAAM,EAChBC,WAAW,EACU;IACrB,MAAMC,UAAUL,UAAU,WAAW;IAErC,OAAO,WAAP,GACI,oBAAC;QACG,WAAWM,GACP,uCACAH,AAAY,aAAZA,UAAuB,oBAAoB,oBAC3CD,YAAY,uDACZH;OAGHE,AAAY,gBAAZA,WAA2BI,UAAU,WAAVA,GACxB,oBAACE,WAASA;QACN,KAAKV;QACL,MAAMC;QACN,KAAKK,AAAY,aAAZA,UAAuB,YAAY;QACxC,aAAaC;SAEjBH,AAAY,kBAAZA,UAA4B,WAAhB,GACZ,oBAACO,aAAWA;QAAC,MAAMV;uBAEnB,oBAACW,UAAQA;QAAC,UAAUT;QAAU,MAAMF;;AAIpD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { FileItemFormatted } from "../../../../../FilePicker/index.js";
|
|
3
|
+
type ThumbnailProps = Pick<FileItemFormatted, "url" | "name"> & {
|
|
4
|
+
fit: "cover" | "contain";
|
|
5
|
+
renderImage?: (args: {
|
|
6
|
+
url: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}) => React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare const Thumbnail: ({ url, name, fit, renderImage }: ThumbnailProps) => React.JSX.Element;
|
|
11
|
+
export { Thumbnail, type ThumbnailProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
const Thumbnail = ({ url, name, fit, renderImage })=>{
|
|
3
|
+
const customImage = "function" == typeof renderImage ? renderImage({
|
|
4
|
+
url,
|
|
5
|
+
name
|
|
6
|
+
}) : false;
|
|
7
|
+
if ("contain" === fit) return /*#__PURE__*/ react.createElement("div", {
|
|
8
|
+
className: "size-full p-xs bg-neutral-muted flex items-center justify-center"
|
|
9
|
+
}, customImage || /*#__PURE__*/ react.createElement("img", {
|
|
10
|
+
src: url,
|
|
11
|
+
alt: name,
|
|
12
|
+
className: "max-h-full max-w-full rounded-xs"
|
|
13
|
+
}));
|
|
14
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
15
|
+
className: "size-full bg-neutral-muted"
|
|
16
|
+
}, customImage || /*#__PURE__*/ react.createElement("img", {
|
|
17
|
+
src: url,
|
|
18
|
+
alt: name,
|
|
19
|
+
className: "size-full object-cover"
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
export { Thumbnail };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=Thumbnail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\n\ntype ThumbnailProps = Pick<FileItemFormatted, \"url\" | \"name\"> & {\n fit: \"cover\" | \"contain\";\n renderImage?: (args: { url: string; name: string }) => React.ReactNode;\n};\n\nconst Thumbnail = ({ url, name, fit, renderImage }: ThumbnailProps) => {\n const customImage = typeof renderImage === \"function\" ? renderImage({ url, name }) : false;\n\n if (fit === \"contain\") {\n return (\n <div className={\"size-full p-xs bg-neutral-muted flex items-center justify-center\"}>\n {customImage || (\n <img src={url} alt={name} className={\"max-h-full max-w-full rounded-xs\"} />\n )}\n </div>\n );\n }\n\n return (\n <div className={\"size-full bg-neutral-muted\"}>\n {customImage || <img src={url} alt={name} className={\"size-full object-cover\"} />}\n </div>\n );\n};\n\nexport { Thumbnail, type ThumbnailProps };\n"],"names":["Thumbnail","url","name","fit","renderImage","customImage"],"mappings":";AAQA,MAAMA,YAAY,CAAC,EAAEC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,WAAW,EAAkB;IAC9D,MAAMC,cAAc,AAAuB,cAAvB,OAAOD,cAA6BA,YAAY;QAAEH;QAAKC;IAAK,KAAK;IAErF,IAAIC,AAAQ,cAARA,KACA,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACXE,eAAe,WAAfA,GACG,oBAAC;QAAI,KAAKJ;QAAK,KAAKC;QAAM,WAAW;;IAMrD,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACXG,eAAe,WAAfA,GAAe,oBAAC;QAAI,KAAKJ;QAAK,KAAKC;QAAM,WAAW;;AAGjE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ThumbnailActionsProps {
|
|
3
|
+
onRemoveItem?: () => void;
|
|
4
|
+
onEditItem?: () => void;
|
|
5
|
+
onReplaceItem?: () => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const ThumbnailActions: ({ className, disabled, onEditItem, onRemoveItem, onReplaceItem }: ThumbnailActionsProps) => React.JSX.Element;
|
|
10
|
+
export { ThumbnailActions, type ThumbnailActionsProps };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import react, { useCallback } from "react";
|
|
2
|
+
import { ReactComponent } from "@webiny/icons/file_upload.svg";
|
|
3
|
+
import { ReactComponent as edit_svg_ReactComponent } from "@webiny/icons/edit.svg";
|
|
4
|
+
import { ReactComponent as delete_svg_ReactComponent } from "@webiny/icons/delete.svg";
|
|
5
|
+
import { IconButton } from "../../../../../Button/index.js";
|
|
6
|
+
import { Tooltip } from "../../../../../Tooltip/index.js";
|
|
7
|
+
import { cn } from "../../../../../utils.js";
|
|
8
|
+
const Action = ({ icon, label, onAction, disabled })=>{
|
|
9
|
+
const onClick = useCallback((event)=>{
|
|
10
|
+
event.stopPropagation();
|
|
11
|
+
onAction();
|
|
12
|
+
}, [
|
|
13
|
+
onAction
|
|
14
|
+
]);
|
|
15
|
+
return /*#__PURE__*/ react.createElement(Tooltip, {
|
|
16
|
+
content: label,
|
|
17
|
+
trigger: /*#__PURE__*/ react.createElement(IconButton, {
|
|
18
|
+
variant: "tertiary",
|
|
19
|
+
size: "sm",
|
|
20
|
+
icon: icon,
|
|
21
|
+
onClick: onClick,
|
|
22
|
+
disabled: disabled
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const ThumbnailActions = ({ className, disabled, onEditItem, onRemoveItem, onReplaceItem })=>/*#__PURE__*/ react.createElement("div", {
|
|
27
|
+
className: cn("invisible group-hover:visible", "flex items-center gap-xxs", "absolute top-xs-plus right-xs-plus", className)
|
|
28
|
+
}, onReplaceItem && /*#__PURE__*/ react.createElement(Action, {
|
|
29
|
+
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
30
|
+
label: "Replace",
|
|
31
|
+
onAction: onReplaceItem,
|
|
32
|
+
disabled: disabled
|
|
33
|
+
}), onEditItem && /*#__PURE__*/ react.createElement(Action, {
|
|
34
|
+
icon: /*#__PURE__*/ react.createElement(edit_svg_ReactComponent, null),
|
|
35
|
+
label: "Edit",
|
|
36
|
+
onAction: onEditItem,
|
|
37
|
+
disabled: disabled
|
|
38
|
+
}), onRemoveItem && /*#__PURE__*/ react.createElement(Action, {
|
|
39
|
+
icon: /*#__PURE__*/ react.createElement(delete_svg_ReactComponent, null),
|
|
40
|
+
label: "Remove",
|
|
41
|
+
onAction: onRemoveItem,
|
|
42
|
+
disabled: disabled
|
|
43
|
+
}));
|
|
44
|
+
export { ThumbnailActions };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=ThumbnailActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { ReactComponent as ReplaceIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as TrashIcon } from \"@webiny/icons/delete.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Tooltip } from \"~/Tooltip/index.js\";\nimport { cn } from \"~/utils.js\";\n\ninterface ActionProps {\n icon: React.JSX.Element;\n label: string;\n onAction: () => void;\n disabled?: boolean;\n}\n\nconst Action = ({ icon, label, onAction, disabled }: ActionProps) => {\n const onClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n onAction();\n },\n [onAction]\n );\n\n return (\n <Tooltip\n content={label}\n trigger={\n <IconButton\n variant={\"tertiary\"}\n size={\"sm\"}\n icon={icon}\n onClick={onClick}\n disabled={disabled}\n />\n }\n />\n );\n};\n\ninterface ThumbnailActionsProps {\n onRemoveItem?: () => void;\n onEditItem?: () => void;\n onReplaceItem?: () => void;\n disabled?: boolean;\n className?: string;\n}\n\nconst ThumbnailActions = ({\n className,\n disabled,\n onEditItem,\n onRemoveItem,\n onReplaceItem\n}: ThumbnailActionsProps) => {\n return (\n <div\n className={cn(\n \"invisible group-hover:visible\",\n \"flex items-center gap-xxs\",\n \"absolute top-xs-plus right-xs-plus\",\n className\n )}\n >\n {onReplaceItem && (\n <Action\n icon={<ReplaceIcon />}\n label={\"Replace\"}\n onAction={onReplaceItem}\n disabled={disabled}\n />\n )}\n {onEditItem && (\n <Action\n icon={<EditIcon />}\n label={\"Edit\"}\n onAction={onEditItem}\n disabled={disabled}\n />\n )}\n {onRemoveItem && (\n <Action\n icon={<TrashIcon />}\n label={\"Remove\"}\n onAction={onRemoveItem}\n disabled={disabled}\n />\n )}\n </div>\n );\n};\n\nexport { ThumbnailActions, type ThumbnailActionsProps };\n"],"names":["Action","icon","label","onAction","disabled","onClick","useCallback","event","Tooltip","IconButton","ThumbnailActions","className","onEditItem","onRemoveItem","onReplaceItem","cn","ReplaceIcon","EditIcon","TrashIcon"],"mappings":";;;;;;;AAeA,MAAMA,SAAS,CAAC,EAAEC,IAAI,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAe;IAC5D,MAAMC,UAAUC,YACZ,CAACC;QACGA,MAAM,eAAe;QACrBJ;IACJ,GACA;QAACA;KAAS;IAGd,OAAO,WAAP,GACI,oBAACK,SAAOA;QACJ,SAASN;QACT,uBACI,oBAACO,YAAUA;YACP,SAAS;YACT,MAAM;YACN,MAAMR;YACN,SAASI;YACT,UAAUD;;;AAK9B;AAUA,MAAMM,mBAAmB,CAAC,EACtBC,SAAS,EACTP,QAAQ,EACRQ,UAAU,EACVC,YAAY,EACZC,aAAa,EACO,GACb,WAAP,GACI,oBAAC;QACG,WAAWC,GACP,iCACA,6BACA,sCACAJ;OAGHG,iBAAiB,WAAjBA,GACG,oBAACd,QAAMA;QACH,oBAAM,oBAACgB,gBAAWA;QAClB,OAAO;QACP,UAAUF;QACV,UAAUV;QAGjBQ,cAAc,WAAdA,GACG,oBAACZ,QAAMA;QACH,oBAAM,oBAACiB,yBAAQA;QACf,OAAO;QACP,UAAUL;QACV,UAAUR;QAGjBS,gBAAgB,WAAhBA,GACG,oBAACb,QAAMA;QACH,oBAAM,oBAACkB,2BAASA;QAChB,OAAO;QACP,UAAUL;QACV,UAAUT"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface TruncatedFileNameProps {
|
|
3
|
+
name: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const TruncatedFileName: ({ name, className }: TruncatedFileNameProps) => React.JSX.Element;
|
|
7
|
+
export { TruncatedFileName, type TruncatedFileNameProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { Text } from "../../../../Text/index.js";
|
|
3
|
+
import { cn } from "../../../../utils.js";
|
|
4
|
+
import { splitFileName } from "./fileName.js";
|
|
5
|
+
const TruncatedFileName = ({ name, className })=>{
|
|
6
|
+
const { head, tail } = splitFileName(name);
|
|
7
|
+
return /*#__PURE__*/ react.createElement(Text, {
|
|
8
|
+
size: "sm",
|
|
9
|
+
as: "div",
|
|
10
|
+
className: cn("flex min-w-0", className),
|
|
11
|
+
title: name
|
|
12
|
+
}, /*#__PURE__*/ react.createElement("span", {
|
|
13
|
+
className: "truncate"
|
|
14
|
+
}, head), tail ? /*#__PURE__*/ react.createElement("span", {
|
|
15
|
+
className: "shrink-0 whitespace-pre"
|
|
16
|
+
}, tail) : null);
|
|
17
|
+
};
|
|
18
|
+
export { TruncatedFileName };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=TruncatedFileName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/TruncatedFileName.js","sources":["../../../../../src/FilePicker/primitives/components/previews/TruncatedFileName.tsx"],"sourcesContent":["import React from \"react\";\nimport { Text } from \"~/Text/index.js\";\nimport { cn } from \"~/utils.js\";\nimport { splitFileName } from \"./fileName.js\";\n\ninterface TruncatedFileNameProps {\n name: string;\n className?: string;\n}\n\nconst TruncatedFileName = ({ name, className }: TruncatedFileNameProps) => {\n const { head, tail } = splitFileName(name);\n\n return (\n <Text size=\"sm\" as=\"div\" className={cn(\"flex min-w-0\", className)} title={name}>\n <span className={\"truncate\"}>{head}</span>\n {tail ? <span className={\"shrink-0 whitespace-pre\"}>{tail}</span> : null}\n </Text>\n );\n};\n\nexport { TruncatedFileName, type TruncatedFileNameProps };\n"],"names":["TruncatedFileName","name","className","head","tail","splitFileName","Text","cn"],"mappings":";;;;AAUA,MAAMA,oBAAoB,CAAC,EAAEC,IAAI,EAAEC,SAAS,EAA0B;IAClE,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAE,GAAGC,cAAcJ;IAErC,OAAO,WAAP,GACI,oBAACK,MAAIA;QAAC,MAAK;QAAK,IAAG;QAAM,WAAWC,GAAG,gBAAgBL;QAAY,OAAOD;qBACtE,oBAAC;QAAK,WAAW;OAAaE,OAC7BC,OAAO,WAAPA,GAAO,oBAAC;QAAK,WAAW;OAA4BA,QAAe;AAGhF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const TAIL_STEM_CHARS = 3;
|
|
2
|
+
const splitFileName = (name)=>{
|
|
3
|
+
const dot = name.lastIndexOf(".");
|
|
4
|
+
if (dot <= 0) return {
|
|
5
|
+
head: name,
|
|
6
|
+
tail: ""
|
|
7
|
+
};
|
|
8
|
+
const cut = dot - Math.min(TAIL_STEM_CHARS, dot);
|
|
9
|
+
if (cut <= 0) return {
|
|
10
|
+
head: name,
|
|
11
|
+
tail: ""
|
|
12
|
+
};
|
|
13
|
+
const head = name.slice(0, cut);
|
|
14
|
+
const tail = name.slice(cut);
|
|
15
|
+
if (head.length <= tail.length) return {
|
|
16
|
+
head: name,
|
|
17
|
+
tail: ""
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
head,
|
|
21
|
+
tail
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export { splitFileName };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=fileName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilePicker/primitives/components/previews/fileName.js","sources":["../../../../../src/FilePicker/primitives/components/previews/fileName.ts"],"sourcesContent":["const TAIL_STEM_CHARS = 3;\n\nexport const splitFileName = (name: string) => {\n const dot = name.lastIndexOf(\".\");\n\n if (dot <= 0) {\n return { head: name, tail: \"\" };\n }\n\n const cut = dot - Math.min(TAIL_STEM_CHARS, dot);\n\n if (cut <= 0) {\n return { head: name, tail: \"\" };\n }\n\n const head = name.slice(0, cut);\n const tail = name.slice(cut);\n\n if (head.length <= tail.length) {\n return { head: name, tail: \"\" };\n }\n\n return { head, tail };\n};\n"],"names":["TAIL_STEM_CHARS","splitFileName","name","dot","cut","Math","head","tail"],"mappings":"AAAA,MAAMA,kBAAkB;AAEjB,MAAMC,gBAAgB,CAACC;IAC1B,MAAMC,MAAMD,KAAK,WAAW,CAAC;IAE7B,IAAIC,OAAO,GACP,OAAO;QAAE,MAAMD;QAAM,MAAM;IAAG;IAGlC,MAAME,MAAMD,MAAME,KAAK,GAAG,CAACL,iBAAiBG;IAE5C,IAAIC,OAAO,GACP,OAAO;QAAE,MAAMF;QAAM,MAAM;IAAG;IAGlC,MAAMI,OAAOJ,KAAK,KAAK,CAAC,GAAGE;IAC3B,MAAMG,OAAOL,KAAK,KAAK,CAACE;IAExB,IAAIE,KAAK,MAAM,IAAIC,KAAK,MAAM,EAC1B,OAAO;QAAE,MAAML;QAAM,MAAM;IAAG;IAGlC,OAAO;QAAEI;QAAMC;IAAK;AACxB"}
|
package/Link/Link.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type VariantProps } from "../utils.js";
|
|
3
3
|
import { LinkComponentProps } from "./LinkComponent.js";
|
|
4
|
-
declare const linkVariants: (props?: ({
|
|
4
|
+
export declare const linkVariants: (props?: ({
|
|
5
5
|
size?: "inherit" | "lg" | "md" | "sm" | "xl" | null | undefined;
|
|
6
6
|
variant?: "primary" | "primary-negative" | "secondary" | "secondary-negative" | null | undefined;
|
|
7
7
|
underline?: boolean | null | undefined;
|
package/Link/Link.js
CHANGED