@akinon/ui-upload 1.5.3 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ export declare function UploadItem({ props, originNode, file, fileList, actions,
9
9
  akinonNode: (typeof componentMap)[keyof typeof componentMap];
10
10
  }>;
11
11
  }): React.JSX.Element;
12
- declare function ImageItem({ file, onPreview, prefixClsWithoutHash, actions, originNode }: UploadItemProps): React.JSX.Element;
13
- declare function TextItem({ file, prefixClsWithoutHash, actions }: UploadItemProps): React.JSX.Element;
12
+ declare function ImageItem({ file, onPreview, prefixClsWithoutHash, actions, originNode, props }: UploadItemProps): React.JSX.Element;
13
+ declare function TextItem({ file, prefixClsWithoutHash, actions, props }: UploadItemProps): React.JSX.Element;
14
14
  export {};
15
15
  //# sourceMappingURL=item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/item.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,QAAA,MAAM,YAAY;;;CAGR,CAAC;AAEX,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,SAAS,EACT,SAAqE,EACtE,EAAE,eAAe,GAAG;IACnB,SAAS,CAAC,EACN,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,GAChD,KAAK,CAAC,aAAa,CACjB,eAAe,GAAG;QAChB,UAAU,EAAE,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;KAC9D,CACF,CAAC;CACP,qBAiBA;AAED,iBAAS,SAAS,CAAC,EACjB,IAAI,EACJ,SAAS,EACT,oBAAoB,EACpB,OAAO,EACP,UAAU,EACX,EAAE,eAAe,qBA2BjB;AAED,iBAAS,QAAQ,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,EAAE,eAAe,qBA4CzE"}
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/item.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,SAAS,CAAC;AAE5D,QAAA,MAAM,YAAY;;;CAGR,CAAC;AAkBX,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,SAAS,EACT,SAAqE,EACtE,EAAE,eAAe,GAAG;IACnB,SAAS,CAAC,EACN,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,GAChD,KAAK,CAAC,aAAa,CACjB,eAAe,GAAG;QAChB,UAAU,EAAE,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;KAC9D,CACF,CAAC;CACP,qBAiBA;AAED,iBAAS,SAAS,CAAC,EACjB,IAAI,EACJ,SAAS,EACT,oBAAoB,EACpB,OAAO,EACP,UAAU,EACV,KAAK,EACN,EAAE,eAAe,qBAyCjB;AAED,iBAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,oBAAoB,EACpB,OAAO,EACP,KAAK,EACN,EAAE,eAAe,qBAgDjB"}
package/dist/cjs/item.js CHANGED
@@ -11,32 +11,49 @@ const componentMap = {
11
11
  'picture-card': ImageItem,
12
12
  text: TextItem
13
13
  };
14
+ function getIconFlags(showUploadList) {
15
+ if (showUploadList === false) {
16
+ return { showRemoveIcon: false, showPreviewIcon: false };
17
+ }
18
+ if (typeof showUploadList === 'object') {
19
+ return {
20
+ showRemoveIcon: showUploadList.showRemoveIcon !== false,
21
+ showPreviewIcon: showUploadList.showPreviewIcon !== false
22
+ };
23
+ }
24
+ // undefined or true → default: show
25
+ return { showRemoveIcon: true, showPreviewIcon: true };
26
+ }
14
27
  function UploadItem({ props, originNode, file, fileList, actions, prefixClsWithoutHash, onPreview, Component = componentMap[props.listType] }) {
15
28
  if (Component) {
16
29
  return (react_1.default.createElement(Component, { akinonNode: componentMap[props.listType], originNode: originNode, props: props, file: file, fileList: fileList, actions: actions, prefixClsWithoutHash: prefixClsWithoutHash, onPreview: onPreview }));
17
30
  }
18
31
  return originNode;
19
32
  }
20
- function ImageItem({ file, onPreview, prefixClsWithoutHash, actions, originNode }) {
21
- return file.thumbUrl ? (react_1.default.createElement("div", { className: (0, clsx_1.default)(`${prefixClsWithoutHash}-list-item`, `${prefixClsWithoutHash}-list-item-${file.status}-border`), onClick: () => {
22
- actions.preview();
23
- } },
24
- react_1.default.createElement(ui_image_1.Image, Object.assign({ src: file.thumbUrl }, (onPreview && { preview: false }))),
25
- react_1.default.createElement("div", { className: `${prefixClsWithoutHash}-list-item-actions` },
26
- react_1.default.createElement(icons_1.Icon, { icon: "bin", size: 12, color: "black", onClick: e => {
33
+ function ImageItem({ file, onPreview, prefixClsWithoutHash, actions, originNode, props }) {
34
+ const { showRemoveIcon, showPreviewIcon } = getIconFlags(props.showUploadList);
35
+ return file.thumbUrl ? (react_1.default.createElement("div", { className: (0, clsx_1.default)(`${prefixClsWithoutHash}-list-item`, `${prefixClsWithoutHash}-list-item-${file.status}-border`), onClick: showPreviewIcon
36
+ ? () => {
37
+ actions.preview();
38
+ }
39
+ : undefined },
40
+ react_1.default.createElement(ui_image_1.Image, Object.assign({ src: file.thumbUrl }, ((onPreview || !showPreviewIcon) && { preview: false }))),
41
+ showRemoveIcon && (react_1.default.createElement("div", { className: `${prefixClsWithoutHash}-list-item-actions` },
42
+ react_1.default.createElement(icons_1.Icon, { cursor: "pointer", icon: "bin", size: 12, color: "black", onClick: e => {
27
43
  e.stopPropagation();
28
44
  actions.remove();
29
- } })))) : (originNode);
45
+ } }))))) : (originNode);
30
46
  }
31
- function TextItem({ file, prefixClsWithoutHash, actions }) {
47
+ function TextItem({ file, prefixClsWithoutHash, actions, props }) {
48
+ const { showRemoveIcon } = getIconFlags(props.showUploadList);
32
49
  return (react_1.default.createElement("div", { className: (0, clsx_1.default)(`${prefixClsWithoutHash}-list-item`, `${prefixClsWithoutHash}-list-item-${file.status}-border`) },
33
50
  react_1.default.createElement(ui_layout_1.Flex, { flex: 1, justify: "between", align: "center", gap: 8 },
34
51
  react_1.default.createElement(ui_layout_1.Flex, { align: "center", gap: 10, flex: 1 },
35
- react_1.default.createElement("div", { className: `${prefixClsWithoutHash}-list-item-actions` },
52
+ showRemoveIcon && (react_1.default.createElement("div", { className: `${prefixClsWithoutHash}-list-item-actions` },
36
53
  react_1.default.createElement(icons_1.Icon, { cursor: "pointer", icon: "bin", size: 13, color: "var(--color-azure-500)", onClick: e => {
37
54
  e.stopPropagation();
38
55
  actions.remove();
39
- } })),
56
+ } }))),
40
57
  react_1.default.createElement("div", { className: `${prefixClsWithoutHash}-list-item-name` }, file.name)),
41
58
  file.status === 'error' && (
42
59
  // TODO: pass proper error messages
@@ -9,7 +9,7 @@ export declare function UploadItem({ props, originNode, file, fileList, actions,
9
9
  akinonNode: (typeof componentMap)[keyof typeof componentMap];
10
10
  }>;
11
11
  }): React.JSX.Element;
12
- declare function ImageItem({ file, onPreview, prefixClsWithoutHash, actions, originNode }: UploadItemProps): React.JSX.Element;
13
- declare function TextItem({ file, prefixClsWithoutHash, actions }: UploadItemProps): React.JSX.Element;
12
+ declare function ImageItem({ file, onPreview, prefixClsWithoutHash, actions, originNode, props }: UploadItemProps): React.JSX.Element;
13
+ declare function TextItem({ file, prefixClsWithoutHash, actions, props }: UploadItemProps): React.JSX.Element;
14
14
  export {};
15
15
  //# sourceMappingURL=item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/item.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,M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,EACjB,IAAI,EACJ,SAAS,EACT,oBAAoB,EACpB,OAAO,EACP,UAAU,EACV,KAAK,EACN,EAAE,eAAe,qBAyCjB;AAED,iBAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,oBAAoB,EACpB,OAAO,EACP,KAAK,EACN,EAAE,eAAe,qBAgDjB"}
package/dist/esm/item.js CHANGED
@@ -8,32 +8,49 @@ const componentMap = {
8
8
  'picture-card': ImageItem,
9
9
  text: TextItem
10
10
  };
11
+ function getIconFlags(showUploadList) {
12
+ if (showUploadList === false) {
13
+ return { showRemoveIcon: false, showPreviewIcon: false };
14
+ }
15
+ if (typeof showUploadList === 'object') {
16
+ return {
17
+ showRemoveIcon: showUploadList.showRemoveIcon !== false,
18
+ showPreviewIcon: showUploadList.showPreviewIcon !== false
19
+ };
20
+ }
21
+ // undefined or true → default: show
22
+ return { showRemoveIcon: true, showPreviewIcon: true };
23
+ }
11
24
  export function UploadItem({ props, originNode, file, fileList, actions, prefixClsWithoutHash, onPreview, Component = componentMap[props.listType] }) {
12
25
  if (Component) {
13
26
  return (React.createElement(Component, { akinonNode: componentMap[props.listType], originNode: originNode, props: props, file: file, fileList: fileList, actions: actions, prefixClsWithoutHash: prefixClsWithoutHash, onPreview: onPreview }));
14
27
  }
15
28
  return originNode;
16
29
  }
17
- function ImageItem({ file, onPreview, prefixClsWithoutHash, actions, originNode }) {
18
- return file.thumbUrl ? (React.createElement("div", { className: clsx(`${prefixClsWithoutHash}-list-item`, `${prefixClsWithoutHash}-list-item-${file.status}-border`), onClick: () => {
19
- actions.preview();
20
- } },
21
- React.createElement(Image, Object.assign({ src: file.thumbUrl }, (onPreview && { preview: false }))),
22
- React.createElement("div", { className: `${prefixClsWithoutHash}-list-item-actions` },
23
- React.createElement(Icon, { icon: "bin", size: 12, color: "black", onClick: e => {
30
+ function ImageItem({ file, onPreview, prefixClsWithoutHash, actions, originNode, props }) {
31
+ const { showRemoveIcon, showPreviewIcon } = getIconFlags(props.showUploadList);
32
+ return file.thumbUrl ? (React.createElement("div", { className: clsx(`${prefixClsWithoutHash}-list-item`, `${prefixClsWithoutHash}-list-item-${file.status}-border`), onClick: showPreviewIcon
33
+ ? () => {
34
+ actions.preview();
35
+ }
36
+ : undefined },
37
+ React.createElement(Image, Object.assign({ src: file.thumbUrl }, ((onPreview || !showPreviewIcon) && { preview: false }))),
38
+ showRemoveIcon && (React.createElement("div", { className: `${prefixClsWithoutHash}-list-item-actions` },
39
+ React.createElement(Icon, { cursor: "pointer", icon: "bin", size: 12, color: "black", onClick: e => {
24
40
  e.stopPropagation();
25
41
  actions.remove();
26
- } })))) : (originNode);
42
+ } }))))) : (originNode);
27
43
  }
28
- function TextItem({ file, prefixClsWithoutHash, actions }) {
44
+ function TextItem({ file, prefixClsWithoutHash, actions, props }) {
45
+ const { showRemoveIcon } = getIconFlags(props.showUploadList);
29
46
  return (React.createElement("div", { className: clsx(`${prefixClsWithoutHash}-list-item`, `${prefixClsWithoutHash}-list-item-${file.status}-border`) },
30
47
  React.createElement(Flex, { flex: 1, justify: "between", align: "center", gap: 8 },
31
48
  React.createElement(Flex, { align: "center", gap: 10, flex: 1 },
32
- React.createElement("div", { className: `${prefixClsWithoutHash}-list-item-actions` },
49
+ showRemoveIcon && (React.createElement("div", { className: `${prefixClsWithoutHash}-list-item-actions` },
33
50
  React.createElement(Icon, { cursor: "pointer", icon: "bin", size: 13, color: "var(--color-azure-500)", onClick: e => {
34
51
  e.stopPropagation();
35
52
  actions.remove();
36
- } })),
53
+ } }))),
37
54
  React.createElement("div", { className: `${prefixClsWithoutHash}-list-item-name` }, file.name)),
38
55
  file.status === 'error' && (
39
56
  // TODO: pass proper error messages
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-upload",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
@@ -12,12 +12,12 @@
12
12
  "@ant-design/cssinjs": "^1.24.0",
13
13
  "antd": "^5.27.0",
14
14
  "clsx": "^2.1.1",
15
- "@akinon/icons": "1.3.2",
16
15
  "@akinon/ui-image": "1.1.8",
17
16
  "@akinon/ui-layout": "1.7.13",
18
- "@akinon/ui-progress": "1.2.10",
19
17
  "@akinon/ui-theme": "1.3.1",
20
- "@akinon/ui-tooltip": "1.4.10"
18
+ "@akinon/ui-progress": "1.2.10",
19
+ "@akinon/ui-tooltip": "1.4.10",
20
+ "@akinon/icons": "1.3.2"
21
21
  },
22
22
  "devDependencies": {
23
23
  "clean-package": "2.2.0",