@trackunit/react-compound-components 0.0.220 → 0.0.221

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/index.cjs.js CHANGED
@@ -190,7 +190,7 @@ const ImageCollection = (props) => {
190
190
  const { imageIds, actions, emptyPlaceholderActionLabel, additionalItemClassName, uploading } = props;
191
191
  const [openImageId, setOpenImageId] = React.useState(imageIds[0]);
192
192
  const [isDeleting, setIsDeleting] = React.useState(false);
193
- const { width } = reactComponents.useResize();
193
+ const { isLg } = reactComponents.useViewportSize();
194
194
  const fileInputRef = React.useRef(null);
195
195
  const imageGalleryRef = React.useRef(null);
196
196
  const uploadButton = React.useMemo(() => (actions === null || actions === void 0 ? void 0 : actions.upload) ? (jsxRuntime.jsx("div", { className: "flex justify-end", children: jsxRuntime.jsx(reactComponents.Button, { loading: uploading, onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: actions.upload.label }) })) : null, [actions === null || actions === void 0 ? void 0 : actions.upload, uploading]);
@@ -242,7 +242,7 @@ const ImageCollection = (props) => {
242
242
  id, }) => (jsxRuntime.jsx("img", { alt: "full", className: tailwindMerge.twMerge(additionalItemClassName, "w-[100%]", "object-contain"), "data-testid": `image-${id}`, loading: "lazy", sizes: "(max-width: 480px) 480px, 800px", src: original, srcSet: srcSet })), renderThumbInner: ({ thumbnail,
243
243
  // Typing of the library is not flexible enough to add id, which is only used for the unit tests
244
244
  // @ts-ignore
245
- id, }) => jsxRuntime.jsx("img", { alt: "thumbnail", "data-testid": `thumbnail-${id}`, loading: "lazy", src: thumbnail }), showFullscreenButton: false, showPlayButton: false, showThumbnails: width > 768,
245
+ id, }) => jsxRuntime.jsx("img", { alt: "thumbnail", "data-testid": `thumbnail-${id}`, loading: "lazy", src: thumbnail }), showFullscreenButton: false, showPlayButton: false, showThumbnails: isLg,
246
246
  // reduce sliding around during deletion
247
247
  slideDuration: isDeleting ? 0 : 200, ...props }), uploadButton, (actions === null || actions === void 0 ? void 0 : actions.remove) ? (jsxRuntime.jsx(reactComponents.Button, { className: "absolute right-2 top-2", loading: isDeleting, onClick: onRemove, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "Trash", size: "small" }), variant: "secondary-danger", children: actions.remove.label })) : null] })) : ((_a = actions === null || actions === void 0 ? void 0 : actions.upload) === null || _a === void 0 ? void 0 : _a.onUpload) ? (uploading ? (jsxRuntime.jsx(reactComponents.Spinner, {})) : (jsxRuntime.jsx(reactFormComponents.DropZone, { accept: ACCEPT_FOR_IMAGES, className: "h-screen", dataTestId: "site-images-dropzone", filesSelected: actions.upload.onUpload, label: emptyPlaceholderActionLabel, multiple: true }))) : null, jsxRuntime.jsx("input", {
248
248
  // Users can still select other files on mobile devices
package/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-l
3
3
  import { ConfirmationDialogProvider } from '@trackunit/react-core-hooks';
4
4
  import * as React from 'react';
5
5
  import { useState, useRef, useMemo, useEffect, useCallback } from 'react';
6
- import { Card, CardHeader, CardBody, CardFooter, Button, useResize, Icon, Spinner } from '@trackunit/react-components';
6
+ import { Card, CardHeader, CardBody, CardFooter, Button, useViewportSize, Icon, Spinner } from '@trackunit/react-components';
7
7
  import { Modal } from '@trackunit/react-modal';
8
8
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
9
9
  import ImageGallery from 'react-image-gallery';
@@ -170,7 +170,7 @@ const ImageCollection = (props) => {
170
170
  const { imageIds, actions, emptyPlaceholderActionLabel, additionalItemClassName, uploading } = props;
171
171
  const [openImageId, setOpenImageId] = useState(imageIds[0]);
172
172
  const [isDeleting, setIsDeleting] = useState(false);
173
- const { width } = useResize();
173
+ const { isLg } = useViewportSize();
174
174
  const fileInputRef = useRef(null);
175
175
  const imageGalleryRef = useRef(null);
176
176
  const uploadButton = useMemo(() => (actions === null || actions === void 0 ? void 0 : actions.upload) ? (jsx("div", { className: "flex justify-end", children: jsx(Button, { loading: uploading, onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: actions.upload.label }) })) : null, [actions === null || actions === void 0 ? void 0 : actions.upload, uploading]);
@@ -222,7 +222,7 @@ const ImageCollection = (props) => {
222
222
  id, }) => (jsx("img", { alt: "full", className: twMerge(additionalItemClassName, "w-[100%]", "object-contain"), "data-testid": `image-${id}`, loading: "lazy", sizes: "(max-width: 480px) 480px, 800px", src: original, srcSet: srcSet })), renderThumbInner: ({ thumbnail,
223
223
  // Typing of the library is not flexible enough to add id, which is only used for the unit tests
224
224
  // @ts-ignore
225
- id, }) => jsx("img", { alt: "thumbnail", "data-testid": `thumbnail-${id}`, loading: "lazy", src: thumbnail }), showFullscreenButton: false, showPlayButton: false, showThumbnails: width > 768,
225
+ id, }) => jsx("img", { alt: "thumbnail", "data-testid": `thumbnail-${id}`, loading: "lazy", src: thumbnail }), showFullscreenButton: false, showPlayButton: false, showThumbnails: isLg,
226
226
  // reduce sliding around during deletion
227
227
  slideDuration: isDeleting ? 0 : 200, ...props }), uploadButton, (actions === null || actions === void 0 ? void 0 : actions.remove) ? (jsx(Button, { className: "absolute right-2 top-2", loading: isDeleting, onClick: onRemove, prefix: jsx(Icon, { name: "Trash", size: "small" }), variant: "secondary-danger", children: actions.remove.label })) : null] })) : ((_a = actions === null || actions === void 0 ? void 0 : actions.upload) === null || _a === void 0 ? void 0 : _a.onUpload) ? (uploading ? (jsx(Spinner, {})) : (jsx(DropZone, { accept: ACCEPT_FOR_IMAGES, className: "h-screen", dataTestId: "site-images-dropzone", filesSelected: actions.upload.onUpload, label: emptyPlaceholderActionLabel, multiple: true }))) : null, jsx("input", {
228
228
  // Users can still select other files on mobile devices
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-compound-components",
3
- "version": "0.0.220",
3
+ "version": "0.0.221",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {