@jobber/components 6.121.0 → 6.122.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.
@@ -38,8 +38,7 @@ function Gallery({ files, size = "base", max, onDelete }) {
38
38
  React.createElement(LightBox.LightBox, { open: lightboxOpen, images: images, imageIndex: lightboxIndex, onRequestClose: handleLightboxClose })));
39
39
  function handleThumbnailClicked(index) {
40
40
  return tslib_es6.__awaiter(this, void 0, void 0, function* () {
41
- if (files[index].type.startsWith("image/") &&
42
- Thumbnail.isPreviewableImage(files[index])) {
41
+ if (Thumbnail.isPreviewableImage(files[index].type)) {
43
42
  handleLightboxOpen(index);
44
43
  }
45
44
  else {
@@ -69,7 +68,7 @@ function generateImagesArray(files) {
69
68
  const filesToImageIndex = [];
70
69
  let imageIndex = 0;
71
70
  for (let i = 0; i < files.length; i++) {
72
- if (files[i].type.startsWith("image/") && Thumbnail.isPreviewableImage(files[i])) {
71
+ if (Thumbnail.isPreviewableImage(files[i].type)) {
73
72
  images.push({ title: files[i].name, url: yield getFileSrc(files[i]) });
74
73
  filesToImageIndex.push(imageIndex);
75
74
  imageIndex++;
@@ -36,8 +36,7 @@ function Gallery({ files, size = "base", max, onDelete }) {
36
36
  React__default.createElement(LightBox, { open: lightboxOpen, images: images, imageIndex: lightboxIndex, onRequestClose: handleLightboxClose })));
37
37
  function handleThumbnailClicked(index) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
- if (files[index].type.startsWith("image/") &&
40
- isPreviewableImage(files[index])) {
39
+ if (isPreviewableImage(files[index].type)) {
41
40
  handleLightboxOpen(index);
42
41
  }
43
42
  else {
@@ -67,7 +66,7 @@ function generateImagesArray(files) {
67
66
  const filesToImageIndex = [];
68
67
  let imageIndex = 0;
69
68
  for (let i = 0; i < files.length; i++) {
70
- if (files[i].type.startsWith("image/") && isPreviewableImage(files[i])) {
69
+ if (isPreviewableImage(files[i].type)) {
71
70
  images.push({ title: files[i].name, url: yield getFileSrc(files[i]) });
72
71
  filesToImageIndex.push(imageIndex);
73
72
  imageIndex++;
@@ -64,19 +64,25 @@ function isSafari(userAgent) {
64
64
  return getClientBrowser(userAgent) === "Apple Safari";
65
65
  }
66
66
 
67
- function isPreviewableImage(file) {
67
+ function isPreviewableImage(type) {
68
+ if (!type || !type.startsWith("image/"))
69
+ return false;
68
70
  const userAgent = typeof document === "undefined" ? "" : window.navigator.userAgent;
69
- const nonHeicImage = !file.type.startsWith("image/heic");
70
- const nonSVGImage = !file.type.startsWith("image/svg");
71
- const nonVendorImage = !/^image\/(vnd[.-]|x-)/i.test(file.type);
72
- return (nonHeicImage || isSafari(userAgent)) && nonSVGImage && nonVendorImage;
71
+ const isHeic = type.startsWith("image/heic");
72
+ const isSVG = type.startsWith("image/svg");
73
+ const isVendor = /^image\/(vnd[.-]|x-)/i.test(type);
74
+ if (isSVG || isVendor)
75
+ return false;
76
+ if (isHeic && !isSafari(userAgent))
77
+ return false;
78
+ return true;
73
79
  }
74
80
 
75
81
  function Thumbnail({ compact = false, size, file, UNSAFE_className, UNSAFE_style, }) {
76
82
  const { name, type } = file;
77
83
  const iconName = getIconNameFromType(type);
78
84
  const hasName = Boolean(name) && compact;
79
- if (type.startsWith("image/") && isPreviewableImage(file)) {
85
+ if (isPreviewableImage(type)) {
80
86
  return (React.createElement(InternalThumbnailImage, { file: file, UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style }));
81
87
  }
82
88
  return (React.createElement("div", { className: classnames(styles$1.content, styles$1[size], {
@@ -62,19 +62,25 @@ function isSafari(userAgent) {
62
62
  return getClientBrowser(userAgent) === "Apple Safari";
63
63
  }
64
64
 
65
- function isPreviewableImage(file) {
65
+ function isPreviewableImage(type) {
66
+ if (!type || !type.startsWith("image/"))
67
+ return false;
66
68
  const userAgent = typeof document === "undefined" ? "" : window.navigator.userAgent;
67
- const nonHeicImage = !file.type.startsWith("image/heic");
68
- const nonSVGImage = !file.type.startsWith("image/svg");
69
- const nonVendorImage = !/^image\/(vnd[.-]|x-)/i.test(file.type);
70
- return (nonHeicImage || isSafari(userAgent)) && nonSVGImage && nonVendorImage;
69
+ const isHeic = type.startsWith("image/heic");
70
+ const isSVG = type.startsWith("image/svg");
71
+ const isVendor = /^image\/(vnd[.-]|x-)/i.test(type);
72
+ if (isSVG || isVendor)
73
+ return false;
74
+ if (isHeic && !isSafari(userAgent))
75
+ return false;
76
+ return true;
71
77
  }
72
78
 
73
79
  function Thumbnail({ compact = false, size, file, UNSAFE_className, UNSAFE_style, }) {
74
80
  const { name, type } = file;
75
81
  const iconName = getIconNameFromType(type);
76
82
  const hasName = Boolean(name) && compact;
77
- if (type.startsWith("image/") && isPreviewableImage(file)) {
83
+ if (isPreviewableImage(type)) {
78
84
  return (React__default.createElement(InternalThumbnailImage, { file: file, UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style }));
79
85
  }
80
86
  return (React__default.createElement("div", { className: classnames(styles$1.content, styles$1[size], {
package/dist/index.cjs CHANGED
@@ -347,6 +347,7 @@ exports.Tab = Tabs.Tab;
347
347
  exports.Tabs = Tabs.Tabs;
348
348
  exports.Text = Text.Text;
349
349
  exports.Thumbnail = Thumbnail.Thumbnail;
350
+ exports.isPreviewableImage = Thumbnail.isPreviewableImage;
350
351
  exports.Tiles = Tiles.Tiles;
351
352
  exports.Toast = showToast.Toast;
352
353
  exports.showToast = showToast.showToast;
package/dist/index.d.mts CHANGED
@@ -87,3 +87,4 @@ export * from "./Toast";
87
87
  export * from "./Tooltip";
88
88
  export * from "./Typography";
89
89
  export * from "./utils/isNormalClick";
90
+ export * from "./utils/isPreviewableImage";
package/dist/index.d.ts CHANGED
@@ -87,3 +87,4 @@ export * from "./Toast";
87
87
  export * from "./Tooltip";
88
88
  export * from "./Typography";
89
89
  export * from "./utils/isNormalClick";
90
+ export * from "./utils/isPreviewableImage";
package/dist/index.mjs CHANGED
@@ -89,7 +89,7 @@ export { S as Switch } from './Switch-es.js';
89
89
  export { B as Body, C as Cell, b as CellCurrency, a as CellNumeric, F as Footer, H as Header, R as Row, T as Table } from './Body-es.js';
90
90
  export { a as Tab, T as Tabs } from './Tabs-es.js';
91
91
  export { T as Text } from './Text-es.js';
92
- export { T as Thumbnail } from './Thumbnail-es.js';
92
+ export { T as Thumbnail, i as isPreviewableImage } from './Thumbnail-es.js';
93
93
  export { T as Tiles } from './Tiles-es.js';
94
94
  export { T as Toast, s as showToast } from './showToast-es.js';
95
95
  export { T as Tooltip } from './Tooltip-es.js';
@@ -1,3 +1 @@
1
- export declare function isPreviewableImage(file: {
2
- type: string;
3
- }): boolean;
1
+ export declare function isPreviewableImage(type: string | null | undefined): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.121.0",
3
+ "version": "6.122.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -562,5 +562,5 @@
562
562
  "> 1%",
563
563
  "IE 10"
564
564
  ],
565
- "gitHead": "9305629cc1a6d8f32d9e4ef9e0d08df12fb92e89"
565
+ "gitHead": "4bffde0a5fa5640eca3c01031fb5e7a678e90136"
566
566
  }